CogVLM
is a powerful
open-source visual language model
(
VLM
). CogVLM-17B has 10 billion vision parameters and 7 billion language parameters. CogVLM-17B achieves state-of-the-art performance on 10 classic cross-modal benchmarks, including NoCaps, Flicker30k captioning, RefCOCO, RefCOCO+, RefCOCOg, Visual7W, GQA, ScienceQA, VizWiz VQA and TDIUC, and rank the 2nd on VQAv2, OKVQA, TextVQA, COCO captioning, etc.,
surpassing or matching PaLI-X 55B
. CogVLM can also
chat with you
about images.
快速开始(Qiuckstart)
import torch
from PIL import Image
from transformers import AutoModelForCausalLM, LlamaTokenizer
tokenizer = LlamaTokenizer.from_pretrained('lmsys/vicuna-7b-v1.5')
model = AutoModelForCausalLM.from_pretrained(
'THUDM/cogvlm-grounding-generalist-hf',
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
trust_remote_code=True
).to('cuda').eval()
query = 'Can you provide a description of the image and include the coordinates [[x0,y0,x1,y1]] for each mentioned object?'
image = Image.open(requests.get('https://github.com/THUDM/CogVLM/blob/main/examples/4.jpg?raw=true', stream=True).raw).convert('RGB')
inputs = model.build_conversation_input_ids(tokenizer, query=query, images=[image])
inputs = {
'input_ids': inputs['input_ids'].unsqueeze(0).to('cuda'),
'token_type_ids': inputs['token_type_ids'].unsqueeze(0).to('cuda'),
'attention_mask': inputs['attention_mask'].unsqueeze(0).to('cuda'),
'images': [[inputs['images'][0].to('cuda').to(torch.bfloat16)]],
}
gen_kwargs = {"max_length": 2048, "do_sample": False}
with torch.no_grad():
outputs = model.generate(**inputs, **gen_kwargs)
outputs = outputs[:, inputs['input_ids'].shape[1]:]
print(tokenizer.decode(outputs[0]))
方法(Method)
CogVLM 模型包括四个基本组件:视觉变换器(ViT)编码器、MLP适配器、预训练的大型语言模型(GPT)和一个
视觉专家模块
。更多细节请参见
Paper
。
CogVLM model comprises four fundamental components: a vision transformer (ViT) encoder, an MLP adapter, a pretrained large language model (GPT), and a
visual expert module
. See
Paper
for more details.
The code in this repository is open source under the
Apache-2.0 license
, while the use of the CogVLM model weights must comply with the
Model License
.
引用(Citation)
If you find our work helpful, please consider citing the following papers
@article{wang2023cogvlm,
title={CogVLM: Visual Expert for Pretrained Language Models},
author={Weihan Wang and Qingsong Lv and Wenmeng Yu and Wenyi Hong and Ji Qi and Yan Wang and Junhui Ji and Zhuoyi Yang and Lei Zhao and Xixuan Song and Jiazheng Xu and Bin Xu and Juanzi Li and Yuxiao Dong and Ming Ding and Jie Tang},
year={2023},
eprint={2311.03079},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Runs of zai-org cogvlm-grounding-generalist-hf on huggingface.co
502
Total runs
0
24-hour runs
61
3-day runs
120
7-day runs
141
30-day runs
More Information About cogvlm-grounding-generalist-hf huggingface.co Model
cogvlm-grounding-generalist-hf huggingface.co
cogvlm-grounding-generalist-hf huggingface.co is an AI model on huggingface.co that provides cogvlm-grounding-generalist-hf's model effect (), which can be used instantly with this zai-org cogvlm-grounding-generalist-hf model. huggingface.co supports a free trial of the cogvlm-grounding-generalist-hf model, and also provides paid use of the cogvlm-grounding-generalist-hf. Support call cogvlm-grounding-generalist-hf model through api, including Node.js, Python, http.
cogvlm-grounding-generalist-hf huggingface.co is an online trial and call api platform, which integrates cogvlm-grounding-generalist-hf's modeling effects, including api services, and provides a free online trial of cogvlm-grounding-generalist-hf, you can try cogvlm-grounding-generalist-hf online for free by clicking the link below.
zai-org cogvlm-grounding-generalist-hf online free url in huggingface.co:
cogvlm-grounding-generalist-hf is an open source model from GitHub that offers a free installation service, and any user can find cogvlm-grounding-generalist-hf on GitHub to install. At the same time, huggingface.co provides the effect of cogvlm-grounding-generalist-hf install, users can directly use cogvlm-grounding-generalist-hf installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
cogvlm-grounding-generalist-hf install url in huggingface.co: