InternVL-Chat-V1-1 / README.md
czczup's picture
Update README.md
360c87d verified
|
raw
history blame
7.54 kB
metadata
license: mit
datasets:
  - laion/laion2B-en
  - laion/laion-coco
  - laion/laion2B-multi
  - kakaobrain/coyo-700m
  - conceptual_captions
  - wanng/wukong100m
pipeline_tag: visual-question-answering

Model Card for InternVL-Chat-Chinese-V1.1

What is InternVL?

[Paper] [GitHub] [Chat Demo]

InternVL scales up the ViT to 6B parameters and aligns it with LLM.

It is the largest open-source vision/vision-language foundation model (14B) to date, achieving 32 state-of-the-art performances on a wide range of tasks such as visual perception, cross-modal retrieval, multimodal dialogue, etc.

image/png

Model Details

  • Model Type: multimodal chatbot

  • Model Stats:

    • Architecture: InternViT-6B + MLP + LLaMA2-13B
    • Params: 19B
    • Image size: 448 x 448
    • Number of visual tokens: 256
  • Training Strategy:

    • Pretraining Stage
      • Learnable Component: InternViT-6B + MLP
      • Data: Trained on 72M samples, including COYO, LAION, CC12M, CC3M, SBU, Wukong, GRIT, Objects365, OpenImages, and OCR data.
      • Note: In this stage, we load the pretrained weights of InternViT-6B-224px and interpolate its position embedding to the size corresponding to 448 x 448 pixels. Moreover, in order to reduce the number of visual tokens, we use a pixel shuffle to reduce 1024 tokens to 256 tokens.
    • SFT Stage
      • Learnable Component: MLP + LLM
      • Data: A comprehensive collection of open-source SFT datasets, along with their Chinese translation versions, totaling approximately 6M samples.

Model Usage

We provide a minimum code example to run InternVL-Chat using only the transformers library.

You also can use our online demo for a quick experience of this model.

Note: If you meet this error ImportError: This modeling file requires the following packages that were not found in your environment: fastchat, please run pip install fschat.

import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor
from transformers import AutoTokenizer

path = "OpenGVLab/InternVL-Chat-Chinese-V1-1"
# If your GPU has more than 40G memory, you can put the entire model on a single GPU.
model = AutoModel.from_pretrained(
    path,
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).eval().cuda()
# Otherwise, you need to set device_map='auto' to use multiple GPUs for inference.
# model = AutoModel.from_pretrained(
#     path,
#     torch_dtype=torch.bfloat16,
#     low_cpu_mem_usage=True,
#     trust_remote_code=True,
#     device_map='auto').eval()

tokenizer = AutoTokenizer.from_pretrained(path)
image = Image.open('./examples/image2.jpg').convert('RGB')
image = image.resize((448, 448))
image_processor = CLIPImageProcessor.from_pretrained(path)

pixel_values = image_processor(images=image, return_tensors='pt').pixel_values
pixel_values = pixel_values.to(torch.bfloat16).cuda()

generation_config = dict(
    num_beams=1,
    max_new_tokens=512,
    do_sample=False,
)

question = "请详细描述图片"
response = model.chat(tokenizer, pixel_values, question, generation_config)

Examples

In this update, InternVL-Chat has improved support for Chinese and OCR.

As you can see, although the Lynyrd Skynyrd in the image has some letters that are out of the camera's lens, and TOUR's T is blocked, the model is still able to recognize it correctly.

image/png

This model can also conduct in-depth analysis of AAAI's official website and identify important information in the web page.

image/png

Evaluation

MultiModal Benchmark

* Training set observed.

MathVista
(testmini)
MMB
(dev/test)
MMB−CN
(dev/test)
MMMU
(val/test)
CMMMU
(val/test)
MMVP MME POPE Tiny LVLM SEEDv1
(image)
LLaVA Wild MM−Vet
34.5 76.7 / 75.4 71.9 / 70.3 39.1 / 35.3 34.8 / 34.0 44.7 1675.1 / 348.6 87.1 343.2 73.2 73.2 46.7

Image Captioning & Visual Question Answering

* Training set observed.

COCO
(test)
Flickr30K
(test)
NoCaps
(val)
VQAv2
(testdev)
OKVQA
(val)
TextVQA
(val)
VizWiz
(val/test)
AI2D
(test)
GQA
(test)
ScienceQA
(image)
142.2* 85.3 120.8 80.9* 64.1* 65.9 59.0 / 57.3 72.2* 62.5* 90.1*
  • We found that incorrect images were used for training and testing in AI2D, meaning that for problems where abcLabel is True, abc_images were not utilized. We have now corrected the images used for testing, but the results may still be somewhat lower as a consequence.

Citation

If you find this project useful in your research, please consider citing:

@article{chen2023internvl,
  title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
  author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
  journal={arXiv preprint arXiv:2312.14238},
  year={2023}
}

License

This project is released under the MIT license. Parts of this project contain code and models (e.g., LLaMA2) from other sources, which are subject to their respective licenses.

Llama 2 is licensed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.

Acknowledgement

InternVL is built with reference to the code of the following projects: OpenAI CLIP, Open CLIP, CLIP Benchmark, EVA, InternImage, ViT-Adapter, MMSegmentation, Transformers, DINOv2, BLIP-2, Qwen-VL, and LLaVA-1.5. Thanks for their awesome work!