Home

Awesome

<p align="center"> <img src="https://v1.ax1x.com/2024/08/13/7GXwAh.png" width="500" style="margin-bottom: 0.2;"/> <p> <h3 align="center"> <a href="https://arxiv.org/abs/2311.06607">Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models</a></h3> <h2></h2> <h5 align="center"> Please give us a star ⭐ for the latest update. </h5> <h5 align="center">

arXiv License GitHub issues GitHub closed issues <br>

</h5> <details open><summary>πŸ’‘ Monkey series projects:✨. </summary><p> <!-- may -->

The Monkey series is primarily focused on exploring techniques such as image resolution enhancement and token compression methods to improve the performance of existing multimodal large models. For instance, earlier versions of Monkey and TextMonkey were based on QwenVL, while MiniMonkey is based on InternVL2, among others. Any suggestions that could help us clarify the misunderstandings, especially avoiding the exaggeration of the contributions of the Monkey series, would be greatly appreciated.

[CVPR'24] Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models<br> Zhang Li, Biao Yang, Qiang Liu, Zhiyin Ma, Shuo Zhang, Jingxu Yang, Yabo Sun, Yuliang Liu, Xiang Bai <br> Paper Source_code Demo Detailed Caption Model Weight Model Weight in Wisemodel Demo in Wisemodel

TextMonkey: An OCR-Free Large Multimodal Model for Understanding Document<br> Yuliang Liu, Biao Yang, Qiang Liu, Zhang Li, Zhiyin Ma, Shuo Zhang, Xiang Bai <br> arXiv Source_code Data Model Weight

Mini-Monkey: Multi-Scale Adaptive Cropping for Multimodal Large Language Models<br> Mingxin Huang, Yuliang Liu, Dingkang Liang, Lianwen Jin, Xiang Bai <br> arXiv Source_code Demo Model Weight Model Weight in Wisemodel

News

🐳 Model Zoo

Monkey-Chat

ModelLanguage ModelTransformers(HF)MMBench-TestCCBenchMMESeedBench_IMGMathVista-MiniTestHallusionBench-AvgAI2D TestOCRBench
Monkey-ChatQwev-7BπŸ€—echo840/Monkey-Chat72.4481887.468.934.839.368.5534
Mini-Monkeyinternlm2-chat-1_8bMini-Monkey---75.51881.971.347.338.774.7802

Environment

conda create -n monkey python=3.9
conda activate monkey
git clone https://github.com/Yuliang-Liu/Monkey.git
cd ./Monkey
pip install -r requirements.txt

You can download the corresponding version of flash_attention from https://github.com/Dao-AILab/flash-attention/releases/ and use the following code to install:

pip install flash_attn-2.3.5+cu117torch2.0cxx11abiFALSE-cp39-cp39-linux_x86_64.whl --no-build-isolation

Train

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 for Monkey and finetune_textmonkey.sh for TextMonkey.

The json file used for Monkey training can be downloaded at Link.

Inference

Run the inference code for Monkey and Monkey-Chat:

python ./inference.py --model_path MODEL_PATH  --image_path IMAGE_PATH  --question "YOUR_QUESTION"

Demo

Demo is fast and easy to use. Simply uploading an image from your desktop or phone, or capture one directly. Demo_chat is also launched as an upgraded version of the original demo to deliver an enhanced interactive experience.

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:

  1. Make sure you have configured the environment.
  2. You can choose to use the demo offline or online:

For TextMonkey you can download the model weight from Model Weight and run the demo code:

python demo_textmonkey.py -c model_path

Before 14/11/2023, we have observed that for some random pictures Monkey can achieve more accurate results than GPT4V.
<br>

<p align="center"> <img src="https://v1.ax1x.com/2024/04/13/7yS2yq.jpg" width="666"/> <p> <br>

Before 31/1/2024, Monkey-chat achieved the fifth rank in the Multimodal Model category on OpenCompass. <br>

<p align="center"> <img src="https://v1.ax1x.com/2024/04/13/7yShXL.jpg" width="666"/> <p> <br>

Dataset

You can download the training and testing data used by monkey from Monkey_Data.

The json file used for Monkey training can be downloaded at Link.

The data from our multi-level description generation method is now open-sourced and available for download at Link. We already upload the images used in multi-level description. Examples:

<br> <p align="center"> <img src="https://v1.ax1x.com/2024/04/13/7yS6Ss.jpg" width="666"/> <p> <br>

You can download train images of Monkey from Train. Extraction code: 4hdh

You can download test images and jsonls of Monkey from Test. Extraction code: 5h71

The images are from CC3M, COCO Caption, TextCaps, VQAV2, OKVQA, GQA, ScienceQA, VizWiz, TextVQA, OCRVQA, ESTVQA, STVQA, AI2D and DUE_Benchmark. When using the data, it is necessary to comply with the protocols of the original dataset.

Evaluate

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:

  1. Make sure you have configured the environment.
  2. Modify sys.path.append("pathto/Monkey") to the project path.
  3. Prepare the datasets required for evaluation.
  4. Run the evaluation code.

Take ESTVQA as an example:

β”œβ”€β”€ data
|	β”œβ”€β”€ estvqa
|		β”œβ”€β”€ test_image
|			β”œβ”€β”€ {image_path0}
|			β”œβ”€β”€ {image_path1}
|				  Β·
|				  Β·
|	β”œβ”€β”€ estvqa.jsonl
{"image": "data/estvqa/test_image/011364.jpg", "question": "What is this store?", "answer": "pizzeria", "question_id": 0}
ds_collections = {
	'estvqa_test': {
		'test': 'data/estvqa/estvqa.jsonl',
		'metric': 'anls',
		'max_new_tokens': 100,
	},
	...
}
bash eval/eval.sh 'EVAL_PTH' 'SAVE_NAME'

Citing Monkey

If you wish to refer to the baseline results published here, please use the following BibTeX entries:

@inproceedings{li2023monkey,
  title={Monkey: Image Resolution and Text Label Are Important Things for Large Multi-modal Models},
  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},
  booktitle={proceedings of the IEEE/CVF conference on computer vision and pattern recognition},
  year={2024}
}
@article{liu2024textmonkey,
  title={TextMonkey: An OCR-Free Large Multimodal Model for Understanding Document},
  author={Liu, Yuliang and Yang, Biao and Liu, Qiang and Li, Zhang and Ma, Zhiyin and Zhang, Shuo and Bai, Xiang},
  journal={arXiv preprint arXiv:2403.04473},
  year={2024}
}
@article{huang2024mini,
  title={Mini-Monkey: Multi-Scale Adaptive Cropping for Multimodal Large Language Models},
  author={Huang, Mingxin and Liu, Yuliang and Liang, Dingkang and Jin, Lianwen and Bai, Xiang},
  journal={arXiv preprint arXiv:2408.02034},
  year={2024}
}

Acknowledgement

Qwen-VL, LLAMA, LLaVA, OpenCompass, InternLM, InternVL.

Copyright

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!