wang-jiahao commited on
Commit
c52758e
·
verified ·
1 Parent(s): 665c4ed

Update model card README

Browse files
Files changed (1) hide show
  1. README.md +107 -40
README.md CHANGED
@@ -1,52 +1,119 @@
1
  ---
2
- frameworks:
3
- - Pytorch
4
  license: apache-2.0
5
- tags: []
6
- tasks:
7
- - image-text-to-text
8
-
9
- #model-type:
10
- ##如 gpt、phi、llama、chatglm、baichuan 等
11
- #- gpt
 
 
12
 
13
- #domain:
14
- ##如 nlp、cv、audio、multi-modal
15
- #- nlp
16
 
17
- #language:
18
- ##语言代码列表 https://help.aliyun.com/document_detail/215387.html?spm=a2c4g.11186623.0.0.9f8d7467kni6Aa
19
- #- cn
 
 
 
 
 
 
20
 
21
- #metrics:
22
- ##如 CIDEr、Blue、ROUGE 等
23
- #- CIDEr
24
 
25
- #tags:
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
- #安装ModelScope
39
- pip install modelscope
 
 
 
 
 
40
  ```
 
 
 
41
  ```python
42
- #SDK模型下载
43
- from modelscope import snapshot_download
44
- model_dir = snapshot_download('jiahaowang1/OmniCaptioner-IF-3B')
45
- ```
46
- Git下载
47
- ```
48
- #Git模型下载
49
- git clone https://www.modelscope.cn/jiahaowang1/OmniCaptioner-IF-3B.git
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  ```
51
 
52
- <p style="color: lightgrey;">如果您是本模型的贡献者,我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>,及时完善模型卡片内容。</p>
 
 
 
 
 
 
 
 
 
 
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
+ [![GitHub](https://img.shields.io/badge/GitHub-OmniCap--IF-181717?logo=github&logoColor=white)](https://github.com/wang-jiahao/OmniCap-IF)
16
+ &nbsp;
17
+ [![Project Page](https://img.shields.io/badge/Project%20Page-OmniCap--IF-1B2838?logo=githubpages&logoColor=white)](https://nju-link.github.io/OmniCap-IF/)
18
+ &nbsp;
19
+ [![Paper](https://img.shields.io/badge/arXiv-2606.xxxxx-b31b1b)](https://arxiv.org/abs/2606.xxxxx)
20
+ &nbsp;
21
+ [![Trainset](https://img.shields.io/badge/Trainset-OmniCap--IF--54K-059669)](https://huggingface.co/datasets/NJU-LINK/OmniCap-IF-54K)
22
+ &nbsp;
23
+ [![Testset](https://img.shields.io/badge/Testset-OmniCap--IF-d97706)](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
+ ```