Image-Text-to-Text
Transformers
Safetensors
qwen2_5_omni
text-to-audio
omni-modal
video-captioning
instruction-following
audio-visual
qwen2.5-omni
conversational
Instructions to use NJU-LINK/OmniCaptioner-IF-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NJU-LINK/OmniCaptioner-IF-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="NJU-LINK/OmniCaptioner-IF-3B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("NJU-LINK/OmniCaptioner-IF-3B") model = AutoModelForMultimodalLM.from_pretrained("NJU-LINK/OmniCaptioner-IF-3B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NJU-LINK/OmniCaptioner-IF-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NJU-LINK/OmniCaptioner-IF-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NJU-LINK/OmniCaptioner-IF-3B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/NJU-LINK/OmniCaptioner-IF-3B
- SGLang
How to use NJU-LINK/OmniCaptioner-IF-3B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "NJU-LINK/OmniCaptioner-IF-3B" \ --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": "NJU-LINK/OmniCaptioner-IF-3B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
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 "NJU-LINK/OmniCaptioner-IF-3B" \ --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": "NJU-LINK/OmniCaptioner-IF-3B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use NJU-LINK/OmniCaptioner-IF-3B with Docker Model Runner:
docker model run hf.co/NJU-LINK/OmniCaptioner-IF-3B
Update model card README
Browse files
README.md
CHANGED
|
@@ -1,52 +1,119 @@
|
|
| 1 |
---
|
| 2 |
-
frameworks:
|
| 3 |
-
- Pytorch
|
| 4 |
license: apache-2.0
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
##如 nlp、cv、audio、multi-modal
|
| 15 |
-
#- nlp
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
##如 CIDEr、Blue、ROUGE 等
|
| 23 |
-
#- CIDEr
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
##各种自定义,包括 pretrained、fine-tuned、instruction-tuned、RL-tuned 等训练方法和其他
|
| 27 |
-
#- pretrained
|
| 28 |
|
| 29 |
-
#tools:
|
| 30 |
-
##如 vllm、fastchat、llamacpp、AdaSeq 等
|
| 31 |
-
#- vllm
|
| 32 |
-
---
|
| 33 |
-
### 当前模型的贡献者未提供更加详细的模型介绍。模型文件和权重,可浏览“模型文件”页面获取。
|
| 34 |
-
#### 您可以通过如下git clone命令,或者ModelScope SDK来下载模型
|
| 35 |
-
|
| 36 |
-
SDK下载
|
| 37 |
```bash
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
```
|
|
|
|
|
|
|
|
|
|
| 41 |
```python
|
| 42 |
-
|
| 43 |
-
from
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
```
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: image-text-to-text
|
| 5 |
+
tags:
|
| 6 |
+
- omni-modal
|
| 7 |
+
- video-captioning
|
| 8 |
+
- instruction-following
|
| 9 |
+
- audio-visual
|
| 10 |
+
- qwen2.5-omni
|
| 11 |
+
---
|
| 12 |
|
| 13 |
+
# **OmniCaptioner-IF-3B**
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
[](https://github.com/wang-jiahao/OmniCap-IF)
|
| 16 |
+
|
| 17 |
+
[](https://nju-link.github.io/OmniCap-IF/)
|
| 18 |
+
|
| 19 |
+
[](https://arxiv.org/abs/2606.xxxxx)
|
| 20 |
+
|
| 21 |
+
[](https://huggingface.co/datasets/NJU-LINK/OmniCap-IF-54K)
|
| 22 |
+
|
| 23 |
+
[](https://huggingface.co/datasets/NJU-LINK/OmniCap-IF)
|
| 24 |
|
| 25 |
+
## Quick Start
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
### Installation
|
|
|
|
|
|
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
```bash
|
| 30 |
+
conda create -n omnicap_if python=3.12
|
| 31 |
+
conda activate omnicap_if
|
| 32 |
+
pip install torch torchvision
|
| 33 |
+
pip install transformers==4.57.1
|
| 34 |
+
pip install accelerate
|
| 35 |
+
pip install flash-attn --no-build-isolation
|
| 36 |
+
pip install qwen-omni-utils[decord] -U
|
| 37 |
```
|
| 38 |
+
|
| 39 |
+
### Usage
|
| 40 |
+
|
| 41 |
```python
|
| 42 |
+
import torch
|
| 43 |
+
from transformers import Qwen2_5OmniForConditionalGeneration, Qwen2_5OmniProcessor
|
| 44 |
+
from qwen_omni_utils import process_mm_info
|
| 45 |
+
|
| 46 |
+
MODEL_ID = "wang-jiahao/OmniCaptioner-IF-3B"
|
| 47 |
+
VIDEO_PATH = "example_video.mp4"
|
| 48 |
+
INSTRUCTION = (
|
| 49 |
+
"Please describe this video in a Markdown table with columns "
|
| 50 |
+
"'Timestamp', 'Visual Action', and 'Audio Content'. Include precise timestamps "
|
| 51 |
+
"and mention the key audio-visual events."
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
MAX_PIXELS = 297920
|
| 55 |
+
VIDEO_MAX_PIXELS = 297920
|
| 56 |
+
|
| 57 |
+
model = Qwen2_5OmniForConditionalGeneration.from_pretrained(
|
| 58 |
+
MODEL_ID,
|
| 59 |
+
torch_dtype=torch.bfloat16,
|
| 60 |
+
device_map="cuda",
|
| 61 |
+
attn_implementation="flash_attention_2"
|
| 62 |
+
)
|
| 63 |
+
processor = Qwen2_5OmniProcessor.from_pretrained(MODEL_ID)
|
| 64 |
+
model.disable_talker()
|
| 65 |
+
|
| 66 |
+
conversation = [
|
| 67 |
+
{
|
| 68 |
+
"role": "user",
|
| 69 |
+
"content": [
|
| 70 |
+
{"type": "text", "text": INSTRUCTION},
|
| 71 |
+
{
|
| 72 |
+
"type": "video",
|
| 73 |
+
"video": VIDEO_PATH,
|
| 74 |
+
"max_pixels": MAX_PIXELS,
|
| 75 |
+
"max_frames": 160,
|
| 76 |
+
"fps": 1.0,
|
| 77 |
+
"video_max_pixels": VIDEO_MAX_PIXELS
|
| 78 |
+
}
|
| 79 |
+
],
|
| 80 |
+
},
|
| 81 |
+
]
|
| 82 |
+
|
| 83 |
+
text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
|
| 84 |
+
audios, images, videos = process_mm_info(conversation, use_audio_in_video=True)
|
| 85 |
+
|
| 86 |
+
inputs = processor(
|
| 87 |
+
text=text,
|
| 88 |
+
audio=audios,
|
| 89 |
+
images=images,
|
| 90 |
+
videos=videos,
|
| 91 |
+
return_tensors="pt",
|
| 92 |
+
padding=True,
|
| 93 |
+
use_audio_in_video=True
|
| 94 |
+
)
|
| 95 |
+
inputs = inputs.to(model.device).to(model.dtype)
|
| 96 |
+
|
| 97 |
+
with torch.inference_mode():
|
| 98 |
+
text_ids = model.generate(
|
| 99 |
+
**inputs,
|
| 100 |
+
use_audio_in_video=True,
|
| 101 |
+
return_audio=False,
|
| 102 |
+
thinker_max_new_tokens=1536,
|
| 103 |
+
talker_max_tokens=1536
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
response = processor.decode(text_ids[0][inputs.input_ids[0].size(0):], skip_special_tokens=True)
|
| 107 |
+
print(response)
|
| 108 |
```
|
| 109 |
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
```bibtex
|
| 113 |
+
@article{wang2026omnicapif,
|
| 114 |
+
title = {OmniCap-IF: Benchmarking and Improving Instruction Following Abilities for Omni-Video Captioning},
|
| 115 |
+
author = {Wang, Jiahao and Ping, An and Wang, Yanghai and Zhang, Yuanxing and Li, Shihao and Bian, Hanyan and Ren, Yichi and Zhang, Yize and Wang, Han and Chen, Haowen and Li, Junze and Wang, Jiaqi and Hu, Yiyang and Xu, Zhuze and Zhang, Zijie and Liu, Jiaheng},
|
| 116 |
+
journal = {Preprint},
|
| 117 |
+
year = {2026}
|
| 118 |
+
}
|
| 119 |
+
```
|