nielsr HF Staff commited on
Commit
c50eb0d
·
verified ·
1 Parent(s): f815e97

Update pipeline tag to visual-document-retrieval

Browse files

This PR updates the `pipeline_tag` metadata to `visual-document-retrieval` which more accurately reflects the model's functionality. The current `image-text-to-text` tag is misleading.

Files changed (1) hide show
  1. README.md +17 -187
README.md CHANGED
@@ -1,22 +1,23 @@
1
  ---
2
- license: apache-2.0
 
3
  language:
4
  - en
5
- pipeline_tag: image-text-to-text
 
 
6
  tags:
7
  - multimodal
8
- library_name: transformers
9
- base_model:
10
- - Qwen/Qwen2-VL-7B
11
  ---
12
 
 
13
  # UGround-V1-7B (Qwen2-VL-Based)
14
 
15
  UGround is a strong GUI visual grounding model trained with a simple recipe. Check our homepage and paper for more details. This work is a collaboration between [OSUNLP](https://x.com/osunlp) and [Orby AI](https://www.orby.ai/).
16
  ![radar](https://osu-nlp-group.github.io/UGround/static/images/radar.png)
17
  - **Homepage:** https://osu-nlp-group.github.io/UGround/
18
  - **Repository:** https://github.com/OSU-NLP-Group/UGround
19
- - **Paper (ICLR'25 Oral):** https://arxiv.org/abs/2410.05243
20
  - **Demo:** https://huggingface.co/spaces/orby-osu/UGround
21
  - **Point of Contact:** [Boyu Gou](mailto:[email protected])
22
 
@@ -228,7 +229,7 @@ We're excited to unveil **Qwen2-VL**, the latest iteration of our Qwen-VL model,
228
  * **Naive Dynamic Resolution**: Unlike before, Qwen2-VL can handle arbitrary image resolutions, mapping them into a dynamic number of visual tokens, offering a more human-like visual processing experience.
229
 
230
  <p align="center">
231
- <img src="https://qianwen-res.oss-accelerate-overseas.aliyuncs.com/Qwen2-VL/qwen2_vl.jpg" width="80%"/>
232
  <p>
233
 
234
  * **Multimodal Rotary Position Embedding (M-ROPE)**: Decomposes positional embedding into parts to capture 1D textual, 2D visual, and 3D video positional information, enhancing its multimodal processing capabilities.
@@ -393,7 +394,12 @@ conversation = [
393
 
394
  # Preprocess the inputs
395
  text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
396
- # Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'
 
 
 
 
 
397
 
398
  inputs = processor(
399
  text=[text_prompt], images=[image], padding=True, return_tensors="pt"
@@ -403,7 +409,7 @@ inputs = inputs.to("cuda")
403
  # Inference: Generation of the output
404
  output_ids = model.generate(**inputs, max_new_tokens=128)
405
  generated_ids = [
406
- output_ids[len(input_ids) :]
407
  for input_ids, output_ids in zip(inputs.input_ids, output_ids)
408
  ]
409
  output_text = processor.batch_decode(
@@ -423,7 +429,7 @@ messages = [
423
  "content": [
424
  {"type": "image", "image": "file:///path/to/image1.jpg"},
425
  {"type": "image", "image": "file:///path/to/image2.jpg"},
426
- {"type": "text", "text": "Identify the similarities between these images."},
427
  ],
428
  }
429
  ]
@@ -512,180 +518,4 @@ generated_ids = model.generate(**inputs, max_new_tokens=128)
512
  generated_ids_trimmed = [
513
  out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
514
  ]
515
- output_text = processor.batch_decode(
516
- generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
517
- )
518
- print(output_text)
519
- ```
520
- </details>
521
-
522
- <details>
523
- <summary>Batch inference</summary>
524
-
525
- ```python
526
- # Sample messages for batch inference
527
- messages1 = [
528
- {
529
- "role": "user",
530
- "content": [
531
- {"type": "image", "image": "file:///path/to/image1.jpg"},
532
- {"type": "image", "image": "file:///path/to/image2.jpg"},
533
- {"type": "text", "text": "What are the common elements in these pictures?"},
534
- ],
535
- }
536
- ]
537
- messages2 = [
538
- {"role": "system", "content": "You are a helpful assistant."},
539
- {"role": "user", "content": "Who are you?"},
540
- ]
541
- # Combine messages for batch processing
542
- messages = [messages1, messages1]
543
-
544
- # Preparation for batch inference
545
- texts = [
546
- processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
547
- for msg in messages
548
- ]
549
- image_inputs, video_inputs = process_vision_info(messages)
550
- inputs = processor(
551
- text=texts,
552
- images=image_inputs,
553
- videos=video_inputs,
554
- padding=True,
555
- return_tensors="pt",
556
- )
557
- inputs = inputs.to("cuda")
558
-
559
- # Batch Inference
560
- generated_ids = model.generate(**inputs, max_new_tokens=128)
561
- generated_ids_trimmed = [
562
- out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
563
- ]
564
- output_texts = processor.batch_decode(
565
- generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
566
- )
567
- print(output_texts)
568
- ```
569
- </details>
570
-
571
- ### More Usage Tips
572
-
573
- For input images, we support local files, base64, and URLs. For videos, we currently only support local files.
574
-
575
- ```python
576
- # You can directly insert a local file path, a URL, or a base64-encoded image into the position where you want in the text.
577
- ## Local file path
578
- messages = [
579
- {
580
- "role": "user",
581
- "content": [
582
- {"type": "image", "image": "file:///path/to/your/image.jpg"},
583
- {"type": "text", "text": "Describe this image."},
584
- ],
585
- }
586
- ]
587
- ## Image URL
588
- messages = [
589
- {
590
- "role": "user",
591
- "content": [
592
- {"type": "image", "image": "http://path/to/your/image.jpg"},
593
- {"type": "text", "text": "Describe this image."},
594
- ],
595
- }
596
- ]
597
- ## Base64 encoded image
598
- messages = [
599
- {
600
- "role": "user",
601
- "content": [
602
- {"type": "image", "image": "data:image;base64,/9j/..."},
603
- {"type": "text", "text": "Describe this image."},
604
- ],
605
- }
606
- ]
607
- ```
608
- #### Image Resolution for performance boost
609
-
610
- The model supports a wide range of resolution inputs. By default, it uses the native resolution for input, but higher resolutions can enhance performance at the cost of more computation. Users can set the minimum and maximum number of pixels to achieve an optimal configuration for their needs, such as a token count range of 256-1280, to balance speed and memory usage.
611
-
612
- ```python
613
- min_pixels = 256 * 28 * 28
614
- max_pixels = 1280 * 28 * 28
615
- processor = AutoProcessor.from_pretrained(
616
- "Qwen/Qwen2-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels
617
- )
618
- ```
619
-
620
- Besides, We provide two methods for fine-grained control over the image size input to the model:
621
-
622
- 1. Define min_pixels and max_pixels: Images will be resized to maintain their aspect ratio within the range of min_pixels and max_pixels.
623
-
624
- 2. Specify exact dimensions: Directly set `resized_height` and `resized_width`. These values will be rounded to the nearest multiple of 28.
625
-
626
- ```python
627
- # min_pixels and max_pixels
628
- messages = [
629
- {
630
- "role": "user",
631
- "content": [
632
- {
633
- "type": "image",
634
- "image": "file:///path/to/your/image.jpg",
635
- "resized_height": 280,
636
- "resized_width": 420,
637
- },
638
- {"type": "text", "text": "Describe this image."},
639
- ],
640
- }
641
- ]
642
- # resized_height and resized_width
643
- messages = [
644
- {
645
- "role": "user",
646
- "content": [
647
- {
648
- "type": "image",
649
- "image": "file:///path/to/your/image.jpg",
650
- "min_pixels": 50176,
651
- "max_pixels": 50176,
652
- },
653
- {"type": "text", "text": "Describe this image."},
654
- ],
655
- }
656
- ]
657
- ```
658
-
659
- ## Limitations
660
-
661
- While Qwen2-VL are applicable to a wide range of visual tasks, it is equally important to understand its limitations. Here are some known restrictions:
662
-
663
- 1. Lack of Audio Support: The current model does **not comprehend audio information** within videos.
664
- 2. Data timeliness: Our image dataset is **updated until June 2023**, and information subsequent to this date may not be covered.
665
- 3. Constraints in Individuals and Intellectual Property (IP): The model's capacity to recognize specific individuals or IPs is limited, potentially failing to comprehensively cover all well-known personalities or brands.
666
- 4. Limited Capacity for Complex Instruction: When faced with intricate multi-step instructions, the model's understanding and execution capabilities require enhancement.
667
- 5. Insufficient Counting Accuracy: Particularly in complex scenes, the accuracy of object counting is not high, necessitating further improvements.
668
- 6. Weak Spatial Reasoning Skills: Especially in 3D spaces, the model's inference of object positional relationships is inadequate, making it difficult to precisely judge the relative positions of objects.
669
-
670
- These limitations serve as ongoing directions for model optimization and improvement, and we are committed to continually enhancing the model's performance and scope of application.
671
-
672
-
673
- ## Citation
674
-
675
- If you find our work helpful, feel free to give us a cite.
676
-
677
- ```
678
- @article{Qwen2VL,
679
- title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
680
- author={Wang, Peng and Bai, Shuai and Tan, Sinan and Wang, Shijie and Fan, Zhihao and Bai, Jinze and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Fan, Yang and Dang, Kai and Du, Mengfei and Ren, Xuancheng and Men, Rui and Liu, Dayiheng and Zhou, Chang and Zhou, Jingren and Lin, Junyang},
681
- journal={arXiv preprint arXiv:2409.12191},
682
- year={2024}
683
- }
684
-
685
- @article{Qwen-VL,
686
- title={Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond},
687
- author={Bai, Jinze and Bai, Shuai and Yang, Shusheng and Wang, Shijie and Tan, Sinan and Wang, Peng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
688
- journal={arXiv preprint arXiv:2308.12966},
689
- year={2023}
690
- }
691
- ```
 
1
  ---
2
+ base_model:
3
+ - Qwen/Qwen2-VL-7B
4
  language:
5
  - en
6
+ library_name: transformers
7
+ license: apache-2.0
8
+ pipeline_tag: visual-document-retrieval
9
  tags:
10
  - multimodal
 
 
 
11
  ---
12
 
13
+ ```markdown
14
  # UGround-V1-7B (Qwen2-VL-Based)
15
 
16
  UGround is a strong GUI visual grounding model trained with a simple recipe. Check our homepage and paper for more details. This work is a collaboration between [OSUNLP](https://x.com/osunlp) and [Orby AI](https://www.orby.ai/).
17
  ![radar](https://osu-nlp-group.github.io/UGround/static/images/radar.png)
18
  - **Homepage:** https://osu-nlp-group.github.io/UGround/
19
  - **Repository:** https://github.com/OSU-NLP-Group/UGround
20
+ - **Paper (ICLR'25 Oral):** https://arxiv.org/abs/2504.04716
21
  - **Demo:** https://huggingface.co/spaces/orby-osu/UGround
22
  - **Point of Contact:** [Boyu Gou](mailto:[email protected])
23
 
 
229
  * **Naive Dynamic Resolution**: Unlike before, Qwen2-VL can handle arbitrary image resolutions, mapping them into a dynamic number of visual tokens, offering a more human-like visual processing experience.
230
 
231
  <p align="center">
232
+ <img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-VL/qwen2_vl.jpg" width="80%"/>
233
  <p>
234
 
235
  * **Multimodal Rotary Position Embedding (M-ROPE)**: Decomposes positional embedding into parts to capture 1D textual, 2D visual, and 3D video positional information, enhancing its multimodal processing capabilities.
 
394
 
395
  # Preprocess the inputs
396
  text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
397
+ # Excepted output: '<|im_start|>system
398
+ You are a helpful assistant.<|im_end|>
399
+ <|im_start|>user
400
+ <|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>
401
+ <|im_start|>assistant
402
+ '
403
 
404
  inputs = processor(
405
  text=[text_prompt], images=[image], padding=True, return_tensors="pt"
 
409
  # Inference: Generation of the output
410
  output_ids = model.generate(**inputs, max_new_tokens=128)
411
  generated_ids = [
412
+ out_ids[len(input_ids) :]
413
  for input_ids, output_ids in zip(inputs.input_ids, output_ids)
414
  ]
415
  output_text = processor.batch_decode(
 
429
  "content": [
430
  {"type": "image", "image": "file:///path/to/image1.jpg"},
431
  {"type": "image", "image": "file:///path/to/image2.jpg"},
432
+ {"type": "text", "text": "What are the common elements in these pictures?"},
433
  ],
434
  }
435
  ]
 
518
  generated_ids_trimmed = [
519
  out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
520
  ]
521
+ output_text = processor.