Image-Text-to-Text
English
weizhiwang commited on
Commit
84e9ead
·
verified ·
1 Parent(s): f4836d5

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc
3
+ datasets:
4
+ - weizhiwang/Open-Qwen2VL-Data
5
+ - MAmmoTH-VL/MAmmoTH-VL-Instruct-12M
6
+ language:
7
+ - en
8
+ base_model:
9
+ - Qwen/Qwen2.5-1.5B-Instruct
10
+ - google/siglip-so400m-patch14-384
11
+ pipeline_tag: image-text-to-text
12
+ ---
13
+
14
+ # Model Card for Open-Qwen2VL
15
+
16
+ <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+ <!-- Please follow my reproduced implementation [LLaVA-Unified](https://github.com/Victorwz/LLaVA-Unified) for more details on fine-tuning LLaVA model with Llama-3 as the foundatiaon LLM. -->
20
+
21
+ ## Updates
22
+ <!-- - [5/14/2024] The codebase has been upgraded to llava-next (llava-v1.6). Now it supports the latest llama-3, phi-3, mistral-v0.1-7b models. -->
23
+
24
+ ## Model Details
25
+ <!-- Follows LLavA-1.5 pre-train and supervised fine-tuning pipeline. You do not need to change the LLaVA codebase to accommodate Llama-3. -->
26
+
27
+ ## How to Use
28
+
29
+ Please firstly install Open-Qwen2VL via
30
+ ```
31
+ pip install git+https://github.com/Victorwz/Open-Qwen2VL.git
32
+ ```
33
+
34
+ You can load the model and perform inference as follows:
35
+ ```python
36
+ import requests
37
+ import torch
38
+ from PIL import Image
39
+ from prismatic import load
40
+
41
+ device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
42
+
43
+ # Load a pretrained VLM (either local path, or ID to auto-download from the HF Hub)
44
+ vlm = load("Open-Qwen2VL")
45
+ vlm.to(device, dtype=torch.bfloat16)
46
+
47
+ # Download an image and specify a prompt
48
+ image_url = "https://huggingface.co/adept/fuyu-8b/resolve/main/bus.png"
49
+ # image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB")
50
+ image = [vlm.vision_backbone.image_transform(Image.open(requests.get(image_url, stream=True).raw).convert("RGB")).unsqueeze(0)]
51
+ user_prompt = '<image>' + '\n' + "Describe the image."
52
+
53
+ # Generate!
54
+ generated_text = vlm.generate_batch(
55
+ image,
56
+ [user_prompt],
57
+ do_sample=False,
58
+ max_new_tokens=512,
59
+ min_length=1,
60
+ )
61
+ print(generated_text[0])
62
+ ```
63
+ The image caption results look like:
64
+ ```
65
+ The image depicts a blue and orange bus parked on the side of a street. The bus is a modern, single-decker model, and it is prominently displayed in the foreground. The bus has a digital display at the front, showing the route number "616" and the destination "Morton Best." The bus is labeled with the logo of "Stagecoach," a well-known bus operator in the UK. The bus also features a slogan on its side that reads "Stronger for you," indicating a focus on providing reliable and efficient public transportation.
66
+
67
+ The bus is parked on a grassy area adjacent to a sidewalk. The grass is well-maintained, and there are a few trees planted along the sidewalk, providing some shade. The sidewalk itself is made of concrete and appears to be clean and well-kept.
68
+
69
+ In the background, there are residential buildings, which are typical of a suburban area. These buildings have pitched roofs and are constructed with a mix of brick and plaster. The architecture suggests a typical British suburban neighborhood. The sky above is partly cloudy, with patches of blue sky visible, indicating fair weather.
70
+
71
+ The bus is parked in a designated bus stop area, as indicated by the presence of a bus stop sign and a bus stop shelter, although the shelter is not visible in the image. The bus's license plate is visible and reads "Y600 HJX." The overall scene suggests a typical day in a suburban area where public transportation is readily available for residents.
72
+
73
+ The image does not contain any people, vehicles other than the bus, or any other notable objects. The focus is primarily on the bus and its surroundings. The bus appears to be in good condition, indicating that it is well-maintained and likely in regular use. The presence of the bus stop and the well-kept environment suggest that the area is well-organized and that public transportation is an integral part of the community's daily life.
74
+ ```
75
+
76
+ <!-- # Fine-Tune LLaVA-Llama-3 on Your Visual Instruction Data
77
+ Please refer to our [LLaVA-Unified](https://github.com/Victorwz/LLaVA-Unified) git repo for fine-tuning data preparation and scripts. The data loading function and fastchat conversation template are changed due to a different tokenizer.
78
+
79
+ ## Benchmark Results
80
+
81
+
82
+ | Model | MMMU Val |
83
+ | :-------------------- | :---------------: |
84
+ | LLaVA-v1.5-7B | 35.3 |
85
+ | LLaVA-Llama-3-8B | 36.7 |
86
+
87
+ Please refer to `eval_outputs/LLaVA-Llama-3-8B_mmmu_val.json` for reproduce the benchmark performance on MMMU validation set. -->
88
+
89
+ ## Citation
90
+ <!--
91
+ ```bibtex
92
+ @misc{wang2024llavallama3,
93
+ title={LLaVA-Llama-3-8B: A reproduction towards LLaVA-v1.5 based on Llama-3-8B LLM backbone},
94
+ author={Wang, Weizhi},
95
+ year={2024}
96
+ }
97
+ ``` -->