echo840 commited on
Commit
e6c33dd
β€’
2 Parent(s): 625714b 4a7ff40

Merge branch 'main' of https://huggingface.co/echo840/Monkey into main

Browse files
Files changed (1) hide show
  1. README.md +150 -0
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models
2
+
3
+ <div align="center">
4
+ Zhang Li*, Biao Yang*, Qiang Liu, Zhiyin Ma, Shuo Zhang, Jingxu Yang, Yabo Sun, Yuliang Liu†, Xiang Bai†
5
+ </div>
6
+ <div align="center">
7
+ <strong>Huazhong University of Science and Technology, Kingsoft</strong>
8
+ </div>
9
+ <p align="center">
10
+ <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 | <a href="https://www.wisemodel.cn/models/HUST-VLRLab/Monkey/">Model Weight in wisemodel</a>&nbsp&nbsp
11
+ <!-- | &nbsp&nbsp<a href="Monkey Model">Monkey Models</a>&nbsp | &nbsp <a href="http://huggingface.co/echo840/Monkey">Tutorial</a> -->
12
+ </p>
13
+
14
+ -----
15
+
16
+ **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.
17
+
18
+
19
+ ## Spotlights
20
+
21
+ - **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.
22
+ - **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.
23
+ - **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.
24
+
25
+
26
+ ## Environment
27
+
28
+ ```python
29
+ conda create -n monkey python=3.9
30
+ conda activate monkey
31
+ git clone https://github.com/Yuliang-Liu/Monkey.git
32
+ cd ./Monkey
33
+ pip install -r requirements.txt
34
+ ```
35
+
36
+
37
+ ## Demo
38
+
39
+ [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.
40
+ [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.
41
+
42
+ Before 14/11/2023, we have observed that for some random pictures Monkey can achieve more accurate results than GPT4V.
43
+
44
+
45
+
46
+ 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:
47
+ 1. Make sure you have configured the [environment](#environment).
48
+ 2. You can choose to use the demo offline or online:
49
+ - **Offline:**
50
+ - Download the [Model Weight](http://huggingface.co/echo840/Monkey).
51
+ - Modify `DEFAULT_CKPT_PATH="pathto/Monkey"` in the `demo.py` file to your model weight path.
52
+ - Run the demo using the following command:
53
+ ```
54
+ python demo.py
55
+ ```
56
+ - **Online:**
57
+ - Run the demo and download model weights online with the following command:
58
+ ```
59
+ python demo.py -c echo840/Monkey
60
+ ```
61
+
62
+ 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:
63
+ ```
64
+ query = "Generate the detailed caption in English. Answer:"
65
+ chat_query = "Generate the detailed caption in English. Answer:"
66
+ ```
67
+ - Generate the detailed caption in English.
68
+ - Explain the visual content of the image in great detail.
69
+ - Analyze the image in a comprehensive and detailed manner.
70
+ - Describe the image in as much detail as possible in English without duplicating it.
71
+ - Describe the image in as much detail as possible in English, including as many elements from the image as possible, but without repetition.
72
+
73
+
74
+ ## Dataset
75
+
76
+ 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).
77
+
78
+
79
+ ## Evaluate
80
+
81
+ 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:
82
+
83
+ 1. Make sure you have configured the [environment](#environment).
84
+ 2. Modify `sys.path.append("pathto/Monkey")` to your model weight path.
85
+ 3. Prepare the datasets required for evaluation.
86
+ 4. Run the evaluation code.
87
+
88
+ Take ESTVQA as an example:
89
+ - Prepare data according to the following directory structure:
90
+ ```
91
+ β”œβ”€β”€ data
92
+ | β”œβ”€β”€ estvqa
93
+ | β”œβ”€β”€ test_image
94
+ | β”œβ”€β”€ {image_path0}
95
+ | β”œβ”€β”€ {image_path1}
96
+ | Β·
97
+ | Β·
98
+ | β”œβ”€β”€ estvqa.jsonl
99
+ ```
100
+ - Example of the format of each line of the annotated `.jsonl` file:
101
+ ```
102
+ {"image": "data/estvqa/test_image/011364.jpg", "question": "What is this store?", "answer": "pizzeria", "question_id": 0}
103
+ ```
104
+ - Modify the dictionary `ds_collections`:
105
+ ```
106
+ ds_collections = {
107
+ 'estvqa_test': {
108
+ 'test': 'data/estvqa/estvqa.jsonl',
109
+ 'metric': 'anls',
110
+ 'max_new_tokens': 100,
111
+ },
112
+ ...
113
+ }
114
+ ```
115
+ - Run the following command:
116
+ ```
117
+ bash eval/eval.sh 'EVAL_PTH' 'SAVE_NAME'
118
+ ```
119
+
120
+
121
+ ## Train
122
+
123
+ 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`.
124
+
125
+ **ATTENTION:** Specify the path to your training data, which should be a json file consisting of a list of conversations.
126
+
127
+
128
+
129
+ ## Citing Monkey
130
+ If you wish to refer to the baseline results published here, please use the following BibTeX entries:
131
+
132
+ ```BibTeX
133
+ @article{li2023monkey,
134
+ title={Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models},
135
+ 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},
136
+ journal={arXiv preprint arXiv:2311.06607},
137
+ year={2023}
138
+ }
139
+ ```
140
+
141
+ If you find the Monkey cute, please star. It would be a great encouragement for us.
142
+
143
+
144
+ ## Acknowledgement
145
+
146
+ [Qwen-VL](https://github.com/QwenLM/Qwen-VL.git): the codebase we built upon. Thanks for the authors of Qwen for providing the framework.
147
+
148
+
149
+ ## Copyright
150
+ 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!