HuggingFaceM4/OBELICS
Viewer • Updated • 276M • 9.84k • 168
How to use Infi-MM/infimm-hd with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Infi-MM/infimm-hd", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Infi-MM/infimm-hd", trust_remote_code=True, dtype="auto")How to use Infi-MM/infimm-hd with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Infi-MM/infimm-hd"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Infi-MM/infimm-hd",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Infi-MM/infimm-hd
How to use Infi-MM/infimm-hd with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Infi-MM/infimm-hd" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Infi-MM/infimm-hd",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "Infi-MM/infimm-hd" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Infi-MM/infimm-hd",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Infi-MM/infimm-hd with Docker Model Runner:
docker model run hf.co/Infi-MM/infimm-hd
More detailes can be found in our paper at https://arxiv.org/abs/2403.01487. We have released the pretraining model and the pyotrch code at https://github.com/InfiMM/infimm-hd/. Feel free to build your model from our pretrained model.
Use the code below to get started with the base model:
import torch
from transformers import AutoModelForCausalLM, AutoProcessor
processor = AutoProcessor.from_pretrained("Infi-MM/infimm-hd", trust_remote_code=True)
prompts = [
{
"role": "user",
"content": [
{"image": "/xxx/test.jpg"}, # change it with you image
"Please describe the image in detail.",
],
}
]
inputs = processor(prompts)
# use bf16 and gpu 0
model = AutoModelForCausalLM.from_pretrained(
"Infi-MM/infimm-hd",
torch_dtype=torch.bfloat16,
trust_remote_code=True,
).to(0).eval()
inputs = inputs
inputs["batch_images"] = inputs["batch_images"].to(torch.bfloat16)
for k in inputs:
inputs[k] = inputs[k].to(model.device)
generated_ids = model.generate(
**inputs,
min_new_tokens=0,
max_new_tokens=256,
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_text)
This project is licensed under the CC BY-NC 4.0.
The copyright of the images belongs to the original authors.
See LICENSE for more information.
Please feel free to contact us via email [email protected] if you have any questions.
@misc{liu2024infimmhd,
title={InfiMM-HD: A Leap Forward in High-Resolution Multimodal Understanding},
author={Haogeng Liu and Quanzeng You and Xiaotian Han and Yiqi Wang and Bohan Zhai and Yongfei Liu and Yunzhe Tao and Huaibo Huang and Ran He and Hongxia Yang},
year={2024},
eprint={2403.01487},
archivePrefix={arXiv},
primaryClass={cs.CV}
}