Views
No views yet

The Caption3o-XL-2B-Qwen2VL model is a fine-tuned version of Qwen2-VL-2B-Instruct, tailored for Image Captioning and Vision Language Attribution. This variant is designed to generate precise, highly descriptive captions with a focus on defining visual properties, object attributes, and scene details across a wide spectrum of images and aspect ratios.
model type: experimental
[!note] General Query: Caption the image precisely.
| Demo |
|---|
| Image A | Image B |
|---|---|
![]() | ![]() |
1from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4model = Qwen2VLForConditionalGeneration.from_pretrained(
5 "prithivMLmods/Caption3o-XL-2B-Qwen2VL", torch_dtype="auto", device_map="auto"
6)
7
8processor = AutoProcessor.from_pretrained("prithivMLmods/Caption3o-XL-2B-Qwen2VL")
9
10messages = [
11 {
12 "role": "user",
13 "content": [
14 {
15 "type": "image",
16 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
17 },
18 {"type": "text", "text": "Describe this image with detailed attributes and properties."},
19 ],
20 }
21]
22
23text = processor.apply_chat_template(
24 messages, tokenize=False, add_generation_prompt=True
25)
26image_inputs, video_inputs = process_vision_info(messages)
27inputs = processor(
28 text=[text],
29 images=image_inputs,
30 videos=video_inputs,
31 padding=True,
32 return_tensors="pt",
33)
34inputs = inputs.to("cuda")
35
36generated_ids = model.generate(**inputs, max_new_tokens=128)
37generated_ids_trimmed = [
38 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
39]
40output_text = processor.batch_decode(
41 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
42)
43print(output_text)