BBBBBBCD commited on
Commit
8ac54da
·
verified ·
1 Parent(s): 24ef717

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +379 -194
README.md CHANGED
@@ -3,197 +3,382 @@ library_name: transformers
3
  tags: []
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  tags: []
4
  ---
5
 
6
+ # EgoThinker-v1⚡
7
+ [\[📂 GitHub\]](https://github.com/InternRobotics/EgoThinker)
8
+ [\[📜 Tech Report\]](https://arxiv.org/abs/2510.23569)
9
+
10
+ ⭐️ We will release EgoThinker-v2 later, which supports real-world embodied intelligence and spatial understanding, stay tuned!
11
+
12
+ ## Abstract
13
+
14
+ Egocentric video reasoning focuses on the unseen, egocentric agent who shapes the scene, demanding inference of hidden intentions and fine-grained interactions—areas where current MLLMs struggle. We present EgoThinker, a framework that equips MLLMs with strong egocentric reasoning via spatio-temporal chain-of-thought supervision and a two-stage curriculum. We build EgoRe-5M, a large-scale QA dataset derived from 13M egocentric clips, featuring multi-minute segments with detailed rationales and dense hand–object grounding. Trained with SFT on EgoRe-5M and refined with RFT for better spatio-temporal localization, EgoThinker outperforms prior methods on multiple egocentric benchmarks and yields substantial gains in fine-grained localization tasks.
15
+
16
+
17
+
18
+ ## How to use the model
19
+
20
+ Our EgoThinker-v1 is built from Qwen2-VL-7B-Instruct.
21
+
22
+ ## Quickstart
23
+ We offer a toolkit to help you handle various types of visual input more conveniently. This includes base64, URLs, and interleaved images and videos. You can install it using the following command:
24
+
25
+ ```bash
26
+ pip install qwen-vl-utils
27
+ ```
28
+
29
+ Here we show a code snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
30
+
31
+ ```python
32
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
33
+ from qwen_vl_utils import process_vision_info
34
+ # default: Load the model on the available device(s)
35
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
36
+ "hyf015/EgoThinker-v1", torch_dtype="auto", device_map="auto"
37
+ )
38
+ # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
39
+ # model = Qwen2VLForConditionalGeneration.from_pretrained(
40
+ # "Qwen/Qwen2-VL-7B-Instruct",
41
+ # torch_dtype=torch.bfloat16,
42
+ # attn_implementation="flash_attention_2",
43
+ # device_map="auto",
44
+ # )
45
+ # default processer
46
+ processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
47
+ # The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
48
+ # min_pixels = 256*28*28
49
+ # max_pixels = 1280*28*28
50
+ # processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
51
+ messages = [
52
+ {
53
+ "role": "user",
54
+ "content": [
55
+ {
56
+ "type": "image",
57
+ "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
58
+ },
59
+ {"type": "text", "text": "Describe this image."},
60
+ ],
61
+ }
62
+ ]
63
+ # Preparation for inference
64
+ text = processor.apply_chat_template(
65
+ messages, tokenize=False, add_generation_prompt=True
66
+ )
67
+ image_inputs, video_inputs = process_vision_info(messages)
68
+ inputs = processor(
69
+ text=[text],
70
+ images=image_inputs,
71
+ videos=video_inputs,
72
+ padding=True,
73
+ return_tensors="pt",
74
+ )
75
+ inputs = inputs.to("cuda")
76
+ # Inference: Generation of the output
77
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
78
+ generated_ids_trimmed = [
79
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
80
+ ]
81
+ output_text = processor.batch_decode(
82
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
83
+ )
84
+ print(output_text)
85
+ ```
86
+ <details>
87
+ <summary>Without qwen_vl_utils</summary>
88
+
89
+ ```python
90
+ from PIL import Image
91
+ import requests
92
+ import torch
93
+ from torchvision import io
94
+ from typing import Dict
95
+ from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
96
+ # Load the model in half-precision on the available device(s)
97
+ model = Qwen2VLForConditionalGeneration.from_pretrained(
98
+ "Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
99
+ )
100
+ processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
101
+ # Image
102
+ url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
103
+ image = Image.open(requests.get(url, stream=True).raw)
104
+ conversation = [
105
+ {
106
+ "role": "user",
107
+ "content": [
108
+ {
109
+ "type": "image",
110
+ },
111
+ {"type": "text", "text": "Describe this image."},
112
+ ],
113
+ }
114
+ ]
115
+ # Preprocess the inputs
116
+ text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
117
+ # Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'
118
+ inputs = processor(
119
+ text=[text_prompt], images=[image], padding=True, return_tensors="pt"
120
+ )
121
+ inputs = inputs.to("cuda")
122
+ # Inference: Generation of the output
123
+ output_ids = model.generate(**inputs, max_new_tokens=128)
124
+ generated_ids = [
125
+ output_ids[len(input_ids) :]
126
+ for input_ids, output_ids in zip(inputs.input_ids, output_ids)
127
+ ]
128
+ output_text = processor.batch_decode(
129
+ generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
130
+ )
131
+ print(output_text)
132
+ ```
133
+ </details>
134
+ <details>
135
+ <summary>Multi image inference</summary>
136
+
137
+ ```python
138
+ # Messages containing multiple images and a text query
139
+ messages = [
140
+ {
141
+ "role": "user",
142
+ "content": [
143
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
144
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
145
+ {"type": "text", "text": "Identify the similarities between these images."},
146
+ ],
147
+ }
148
+ ]
149
+ # Preparation for inference
150
+ text = processor.apply_chat_template(
151
+ messages, tokenize=False, add_generation_prompt=True
152
+ )
153
+ image_inputs, video_inputs = process_vision_info(messages)
154
+ inputs = processor(
155
+ text=[text],
156
+ images=image_inputs,
157
+ videos=video_inputs,
158
+ padding=True,
159
+ return_tensors="pt",
160
+ )
161
+ inputs = inputs.to("cuda")
162
+ # Inference
163
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
164
+ generated_ids_trimmed = [
165
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
166
+ ]
167
+ output_text = processor.batch_decode(
168
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
169
+ )
170
+ print(output_text)
171
+ ```
172
+ </details>
173
+
174
+ <details>
175
+ <summary>Video inference</summary>
176
+
177
+ ```python
178
+ # Messages containing a images list as a video and a text query
179
+ messages = [
180
+ {
181
+ "role": "user",
182
+ "content": [
183
+ {
184
+ "type": "video",
185
+ "video": [
186
+ "file:///path/to/frame1.jpg",
187
+ "file:///path/to/frame2.jpg",
188
+ "file:///path/to/frame3.jpg",
189
+ "file:///path/to/frame4.jpg",
190
+ ],
191
+ "fps": 1.0,
192
+ },
193
+ {"type": "text", "text": "Describe this video."},
194
+ ],
195
+ }
196
+ ]
197
+ # Messages containing a video and a text query
198
+ messages = [
199
+ {
200
+ "role": "user",
201
+ "content": [
202
+ {
203
+ "type": "video",
204
+ "video": "file:///path/to/video1.mp4",
205
+ "max_pixels": 360 * 420,
206
+ "fps": 1.0,
207
+ },
208
+ {"type": "text", "text": "Describe this video."},
209
+ ],
210
+ }
211
+ ]
212
+ # Preparation for inference
213
+ text = processor.apply_chat_template(
214
+ messages, tokenize=False, add_generation_prompt=True
215
+ )
216
+ image_inputs, video_inputs = process_vision_info(messages)
217
+ inputs = processor(
218
+ text=[text],
219
+ images=image_inputs,
220
+ videos=video_inputs,
221
+ padding=True,
222
+ return_tensors="pt",
223
+ )
224
+ inputs = inputs.to("cuda")
225
+ # Inference
226
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
227
+ generated_ids_trimmed = [
228
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
229
+ ]
230
+ output_text = processor.batch_decode(
231
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
232
+ )
233
+ print(output_text)
234
+ ```
235
+ </details>
236
+
237
+ <details>
238
+ <summary>Batch inference</summary>
239
+
240
+ ```python
241
+ # Sample messages for batch inference
242
+ messages1 = [
243
+ {
244
+ "role": "user",
245
+ "content": [
246
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
247
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
248
+ {"type": "text", "text": "What are the common elements in these pictures?"},
249
+ ],
250
+ }
251
+ ]
252
+ messages2 = [
253
+ {"role": "system", "content": "You are a helpful assistant."},
254
+ {"role": "user", "content": "Who are you?"},
255
+ ]
256
+ # Combine messages for batch processing
257
+ messages = [messages1, messages1]
258
+ # Preparation for batch inference
259
+ texts = [
260
+ processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
261
+ for msg in messages
262
+ ]
263
+ image_inputs, video_inputs = process_vision_info(messages)
264
+ inputs = processor(
265
+ text=texts,
266
+ images=image_inputs,
267
+ videos=video_inputs,
268
+ padding=True,
269
+ return_tensors="pt",
270
+ )
271
+ inputs = inputs.to("cuda")
272
+ # Batch Inference
273
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
274
+ generated_ids_trimmed = [
275
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
276
+ ]
277
+ output_texts = processor.batch_decode(
278
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
279
+ )
280
+ print(output_texts)
281
+ ```
282
+ </details>
283
+
284
+ ### More Usage Tips
285
+
286
+ For input images, we support local files, base64, and URLs. For videos, we currently only support local files.
287
+
288
+ ```python
289
+ # You can directly insert a local file path, a URL, or a base64-encoded image into the position where you want in the text.
290
+ ## Local file path
291
+ messages = [
292
+ {
293
+ "role": "user",
294
+ "content": [
295
+ {"type": "image", "image": "file:///path/to/your/image.jpg"},
296
+ {"type": "text", "text": "Describe this image."},
297
+ ],
298
+ }
299
+ ]
300
+ ## Image URL
301
+ messages = [
302
+ {
303
+ "role": "user",
304
+ "content": [
305
+ {"type": "image", "image": "http://path/to/your/image.jpg"},
306
+ {"type": "text", "text": "Describe this image."},
307
+ ],
308
+ }
309
+ ]
310
+ ## Base64 encoded image
311
+ messages = [
312
+ {
313
+ "role": "user",
314
+ "content": [
315
+ {"type": "image", "image": "data:image;base64,/9j/..."},
316
+ {"type": "text", "text": "Describe this image."},
317
+ ],
318
+ }
319
+ ]
320
+ ```
321
+ #### Image Resolution for performance boost
322
+
323
+ The model supports a wide range of resolution inputs. By default, it uses the native resolution for input, but higher resolutions can enhance performance at the cost of more computation. Users can set the minimum and maximum number of pixels to achieve an optimal configuration for their needs, such as a token count range of 256-1280, to balance speed and memory usage.
324
+
325
+ ```python
326
+ min_pixels = 256 * 28 * 28
327
+ max_pixels = 1280 * 28 * 28
328
+ processor = AutoProcessor.from_pretrained(
329
+ "Qwen/Qwen2-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels
330
+ )
331
+ ```
332
+
333
+ Besides, We provide two methods for fine-grained control over the image size input to the model:
334
+
335
+ 1. Define min_pixels and max_pixels: Images will be resized to maintain their aspect ratio within the range of min_pixels and max_pixels.
336
+
337
+ 2. Specify exact dimensions: Directly set `resized_height` and `resized_width`. These values will be rounded to the nearest multiple of 28.
338
+
339
+ ```python
340
+ # min_pixels and max_pixels
341
+ messages = [
342
+ {
343
+ "role": "user",
344
+ "content": [
345
+ {
346
+ "type": "image",
347
+ "image": "file:///path/to/your/image.jpg",
348
+ "resized_height": 280,
349
+ "resized_width": 420,
350
+ },
351
+ {"type": "text", "text": "Describe this image."},
352
+ ],
353
+ }
354
+ ]
355
+ # resized_height and resized_width
356
+ messages = [
357
+ {
358
+ "role": "user",
359
+ "content": [
360
+ {
361
+ "type": "image",
362
+ "image": "file:///path/to/your/image.jpg",
363
+ "min_pixels": 50176,
364
+ "max_pixels": 50176,
365
+ },
366
+ {"type": "text", "text": "Describe this image."},
367
+ ],
368
+ }
369
+ ]
370
+ ```
371
+
372
+ ## ✏️ Citation
373
+
374
+ ```bibtex
375
+ @misc{pei2025egothinkerunveilingegocentricreasoning,
376
+ title={EgoThinker: Unveiling Egocentric Reasoning with Spatio-Temporal CoT},
377
+ author={Baoqi Pei and Yifei Huang and Jilan Xu and Yuping He and Guo Chen and Fei Wu and Yu Qiao and Jiangmiao Pang},
378
+ year={2025},
379
+ eprint={2510.23569},
380
+ archivePrefix={arXiv},
381
+ primaryClass={cs.CV},
382
+ url={https://arxiv.org/abs/2510.23569},
383
+ }
384
+ ```