echo840 commited on
Commit
d0c56ec
β€’
1 Parent(s): 8d665fa

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +214 -0
README.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models
2
+
3
+
4
+ <br>
5
+ <p align="center">
6
+ <img src="images/logo_monkey.png" width="300"/>
7
+ <p>
8
+ <br>
9
+
10
+ <div align="center">
11
+ Zhang Li*, Biao Yang*, Qiang Liu, Zhiyin Ma, Shuo Zhang, Jingxu Yang, Yabo Sun, Yuliang Liu†, Xiang Bai†
12
+ </div>
13
+ <div align="center">
14
+ <strong>Huazhong University of Science and Technology, Kingsoft</strong>
15
+ </div>
16
+ <p align="center">
17
+ <a href="https://arxiv.org/abs/2311.06607">Paper</a>&nbsp&nbsp | &nbsp&nbsp<a href="http://27.17.252.152:7680/">Demo</a>&nbsp&nbsp | &nbsp&nbsp<a href="http://27.17.252.152:7681/">Demo_chat</a>&nbsp&nbsp | &nbsp&nbsp<a href="http://huggingface.co/datasets/echo840/Detailed_Caption">Detailed Caption</a>&nbsp&nbsp | &nbsp&nbsp<a href="http://huggingface.co/echo840/Monkey">Model Weight</a>&nbsp&nbsp
18
+ <!-- | &nbsp&nbsp<a href="Monkey Model">Monkey Models</a>&nbsp | &nbsp <a href="http://huggingface.co/echo840/Monkey">Tutorial</a> -->
19
+ </p>
20
+
21
+ -----
22
+
23
+ **Monkey** brings a training-efficient approach to effectively improve the input resolution capacity up to 896 x 1344 pixels without pretraining from the start. To bridge the gap between simple text labels and high input resolution, we propose a multi-level description generation method, which automatically provides rich information that can guide the model to learn the contextual association between scenes and objects. With the synergy of these two designs, our model achieved excellent results on multiple benchmarks. By comparing our model with various LMMs, including GPT4V, our model demonstrates promising performance in image captioning by paying attention to textual information and capturing fine details within the images; its improved input resolution also enables remarkable performance in document images with dense text.
24
+
25
+ ## News
26
+ * ```2023.11.25``` πŸš€πŸš€πŸš€ Monkey-chat demo is released, which demonstrates improved results on most datasets. Paper is in preparation.
27
+ * ```2023.11.06``` πŸš€πŸš€πŸš€ Monkey [paper](https://arxiv.org/abs/2311.06607) is released.
28
+
29
+
30
+ ## Spotlights
31
+
32
+ - **Contextual associations.** Our method demonstrates a superior ability to infer the relationships between targets more effectively when answering questions, which results in delivering more comprehensive and insightful results.
33
+ - **Support resolution up to 1344 x 896.** Surpassing the standard 448 x 448 resolution typically employed for LMMs, this significant increase in resolution augments the ability to discern and understand unnoticeable or tightly clustered objects and dense text.
34
+ - **Enhanced general performance.** We carried out testing across 16 diverse datasets, leading to impressive performance by our Monkey model in tasks such as Image Captioning, General Visual Question Answering, Text-centric Visual Question Answering, and Document-oriented Visual Question Answering.
35
+
36
+
37
+ ## Environment
38
+
39
+ ```python
40
+ conda create -n monkey python=3.9
41
+ conda activate monkey
42
+ git clone https://github.com/Yuliang-Liu/Monkey.git
43
+ cd ./Monkey
44
+ pip install -r requirements.txt
45
+ ```
46
+
47
+
48
+ ## Demo
49
+
50
+ [Demo](http://27.17.252.152:7680/) is fast and easy to use. Simply uploading an image from your desktop or phone, or capture one directly.
51
+ [Demo_chat](http://27.17.252.152:7681/) is also launched as an upgraded version of the original demo to deliver an enhanced interactive experience.
52
+
53
+ Before 14/11/2023, we have observed that for some random pictures Monkey can achieve more accurate results than GPT4V.
54
+ <br>
55
+ <p align="center">
56
+ <img src="images/demo_gpt4v_compare4.png" width="900"/>
57
+ <p>
58
+ <br>
59
+
60
+ We also provide the source code and the model weight for the original demo, allowing you to customize certain parameters for a more unique experience. The specific operations are as follows:
61
+ 1. Make sure you have configured the [environment](#environment).
62
+ 2. You can choose to use the demo offline or online:
63
+ - **Offline:**
64
+ - Download the [Model Weight](http://huggingface.co/echo840/Monkey).
65
+ - Modify `DEFAULT_CKPT_PATH="pathto/Monkey"` in the `demo.py` file to your model weight path.
66
+ - Run the demo using the following command:
67
+ ```
68
+ python demo.py
69
+ ```
70
+ - **Online:**
71
+ - Run the demo and download model weights online with the following command:
72
+ ```
73
+ python demo.py -c echo840/Monkey
74
+ ```
75
+
76
+ In order to generate more detailed captions, we provide some prompt examples so that you can conduct more interesting explorations. You can modify these two variables in the `caption` function to implement different prompt inputs for the caption task, as shown below:
77
+ ```
78
+ query = "Generate the detailed caption in English. Answer:"
79
+ chat_query = "Generate the detailed caption in English. Answer:"
80
+ ```
81
+ - Generate the detailed caption in English.
82
+ - Explain the visual content of the image in great detail.
83
+ - Analyze the image in a comprehensive and detailed manner.
84
+ - Describe the image in as much detail as possible in English without duplicating it.
85
+ - Describe the image in as much detail as possible in English, including as many elements from the image as possible, but without repetition.
86
+
87
+
88
+ ## Dataset
89
+
90
+ We have open-sourced the data generated by the multi-level description generation method. You can download it at [Detailed Caption](https://huggingface.co/datasets/echo840/Detailed_Caption).
91
+
92
+
93
+ ## Evaluate
94
+
95
+ We offer evaluation code for 14 Visual Question Answering (VQA) datasets in the `evaluate_vqa.py` file, facilitating a quick verification of results. The specific operations are as follows:
96
+
97
+ 1. Make sure you have configured the [environment](#environment).
98
+ 2. Modify `sys.path.append("pathto/Monkey")` to your model weight path.
99
+ 3. Prepare the datasets required for evaluation.
100
+ 4. Run the evaluation code.
101
+
102
+ Take ESTVQA as an example:
103
+ - Prepare data according to the following directory structure:
104
+ ```
105
+ β”œβ”€β”€ data
106
+ | β”œβ”€β”€ estvqa
107
+ | β”œβ”€β”€ test_image
108
+ | β”œβ”€β”€ {image_path0}
109
+ | β”œβ”€β”€ {image_path1}
110
+ | Β·
111
+ | Β·
112
+ | β”œβ”€β”€ estvqa.jsonl
113
+ ```
114
+ - Example of the format of each line of the annotated `.jsonl` file:
115
+ ```
116
+ {"image": "data/estvqa/test_image/011364.jpg", "question": "What is this store?", "answer": "pizzeria", "question_id": 0}
117
+ ```
118
+ - Modify the dictionary `ds_collections`:
119
+ ```
120
+ ds_collections = {
121
+ 'estvqa_test': {
122
+ 'test': 'data/estvqa/estvqa.jsonl',
123
+ 'metric': 'anls',
124
+ 'max_new_tokens': 100,
125
+ },
126
+ ...
127
+ }
128
+ ```
129
+ - Run the following command:
130
+ ```
131
+ bash eval/eval.sh 'EVAL_PTH' 'SAVE_NAME'
132
+ ```
133
+
134
+
135
+ ## Train
136
+
137
+ We also offer Monkey's model definition and training code, which you can explore above. You can execute the training code through executing `finetune_ds_debug.sh`.
138
+
139
+ **ATTENTION:** Specify the path to your training data, which should be a json file consisting of a list of conversations.
140
+
141
+
142
+ ## Performance
143
+
144
+ <br>
145
+
146
+ <p align="center">
147
+ <img src="images/radar.png" width="800"/>
148
+ <p>
149
+ <br>
150
+
151
+
152
+ ## Cases
153
+
154
+ Our model can accurately describe the details in the image.
155
+
156
+ <br>
157
+ <p align="center">
158
+ <img src="images/caption_1.png" width="700"/>
159
+ <p>
160
+ <br>
161
+
162
+ Our model performs particularly well in dense text question answering tasks. For example, in the dense text of item labels, Monkey can accurately answer various information about the item, and its performance is very impressive compared to other LMMs including GPT4V.
163
+
164
+ <br>
165
+ <p align="center">
166
+ <img src="images/dense_text_1.png" width="700"/>
167
+ <p>
168
+ <br>
169
+
170
+ <br>
171
+ <p align="center">
172
+ <img src="images/dense_text_2.png" width="700"/>
173
+ <p>
174
+ <br>
175
+
176
+ Monkey also performs equally well in daily life scenes. It can complete various Q&A and caption tasks and describe various details in the image in detail, even the inconspicuous watermark.
177
+
178
+ <br>
179
+ <p align="center">
180
+ <img src="images/qa_caption.png" width="700"/>
181
+ <p>
182
+ <br>
183
+
184
+ We qualitatively compare with existing LMMs including GPT4V, Qwen-vl, etc, which shows inspiring results. One can have a try using the provided demo.
185
+
186
+ <br>
187
+ <p align="center">
188
+ <img src="images/compare.png" width="800"/>
189
+ <p>
190
+ <br>
191
+
192
+
193
+ ## Citing Monkey
194
+ If you wish to refer to the baseline results published here, please use the following BibTeX entries:
195
+
196
+ ```BibTeX
197
+ @article{li2023monkey,
198
+ title={Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models},
199
+ author={Li, Zhang and Yang, Biao and Liu, Qiang and Ma, Zhiyin and Zhang, Shuo and Yang, Jingxu and Sun, Yabo and Liu, Yuliang and Bai, Xiang},
200
+ journal={arXiv preprint arXiv:2311.06607},
201
+ year={2023}
202
+ }
203
+ ```
204
+
205
+ If you find the Monkey cute, please star. It would be a great encouragement for us.
206
+
207
+
208
+ ## Acknowledgement
209
+
210
+ [Qwen-VL](https://github.com/QwenLM/Qwen-VL.git): the codebase we built upon. Thanks for the authors of Qwen for providing the framework.
211
+
212
+
213
+ ## Copyright
214
+ We welcome suggestions to help us improve the Monkey. For any query, please contact Dr. Yuliang Liu: ylliu@hust.edu.cn. If you find something interesting, please also feel free to share with us through email or open an issue. Thanks!