Add library_name and usage example
Browse filesThis PR improves the model card by:
- Adding `library_name: transformers` to ensure the "how to use" widget appears with an automated code snippet.
- Including a "Quick Inference Code" section from the GitHub README as a "Usage" section in the model card, making it easier for users to get started with the model.
README.md
CHANGED
|
@@ -1,18 +1,84 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
base_model:
|
| 6 |
- Qwen/Qwen2.5-VL-7B-Instruct
|
|
|
|
|
|
|
|
|
|
| 7 |
pipeline_tag: video-text-to-text
|
| 8 |
tags:
|
| 9 |
- multimodal
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
# TimeSearch-R-7B
|
| 13 |
- **Code:** https://github.com/Time-Search/TimeSearch-R
|
| 14 |
- **Paper:** [TimeSearch-R: Adaptive Temporal Search for Long-Form Video Understanding via Self-Verification Reinforcement Learning](https://arxiv.org/abs/2511.05489)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
## Citation
|
| 17 |
|
| 18 |
If you find our work helpful, feel free to give us a cite.
|
|
@@ -24,4 +90,4 @@ If you find our work helpful, feel free to give us a cite.
|
|
| 24 |
journal={arXiv preprint arXiv:2511.05489},
|
| 25 |
year={2025}
|
| 26 |
}
|
| 27 |
-
```
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model:
|
| 3 |
- Qwen/Qwen2.5-VL-7B-Instruct
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
license: apache-2.0
|
| 7 |
pipeline_tag: video-text-to-text
|
| 8 |
tags:
|
| 9 |
- multimodal
|
| 10 |
+
library_name: transformers
|
| 11 |
---
|
| 12 |
|
| 13 |
# TimeSearch-R-7B
|
| 14 |
- **Code:** https://github.com/Time-Search/TimeSearch-R
|
| 15 |
- **Paper:** [TimeSearch-R: Adaptive Temporal Search for Long-Form Video Understanding via Self-Verification Reinforcement Learning](https://arxiv.org/abs/2511.05489)
|
| 16 |
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
We provide the simple generation process for using our model. For more details, you could refer to [Github](https://github.com/Time-Search/TimeSearch-R).
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import numpy as np
|
| 23 |
+
import torch
|
| 24 |
+
from longvu.builder import load_pretrained_model
|
| 25 |
+
from longvu.constants import (
|
| 26 |
+
DEFAULT_IMAGE_TOKEN,
|
| 27 |
+
IMAGE_TOKEN_INDEX,
|
| 28 |
+
)
|
| 29 |
+
from longvu.conversation import conv_templates, SeparatorStyle
|
| 30 |
+
from longvu.mm_datautils import (
|
| 31 |
+
KeywordsStoppingCriteria,
|
| 32 |
+
process_images,
|
| 33 |
+
tokenizer_image_token,
|
| 34 |
+
)
|
| 35 |
+
from decord import cpu, VideoReader
|
| 36 |
+
|
| 37 |
+
tokenizer, model, image_processor, context_len = load_pretrained_model(
|
| 38 |
+
"./checkpoints/longvu_qwen", None, "cambrian_qwen",
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
model.eval()
|
| 42 |
+
video_path = "./examples/video1.mp4"
|
| 43 |
+
qs = "Describe this video in detail"
|
| 44 |
+
|
| 45 |
+
vr = VideoReader(video_path, ctx=cpu(0), num_threads=1)
|
| 46 |
+
fps = float(vr.get_avg_fps())
|
| 47 |
+
frame_indices = np.array([i for i in range(0, len(vr), round(fps),)])
|
| 48 |
+
video = []
|
| 49 |
+
for frame_index in frame_indices:
|
| 50 |
+
img = vr[frame_index].asnumpy()
|
| 51 |
+
video.append(img)
|
| 52 |
+
video = np.stack(video)
|
| 53 |
+
image_sizes = [video[0].shape[:2]]
|
| 54 |
+
video = process_images(video, image_processor, model.config)
|
| 55 |
+
video = [item.unsqueeze(0) for item in video]
|
| 56 |
+
|
| 57 |
+
qs = DEFAULT_IMAGE_TOKEN + "
|
| 58 |
+
" + qs
|
| 59 |
+
conv = conv_templates["qwen"].copy()
|
| 60 |
+
conv.append_message(conv.roles[0], qs)
|
| 61 |
+
conv.append_message(conv.roles[1], None)
|
| 62 |
+
prompt = conv.get_prompt()
|
| 63 |
+
|
| 64 |
+
input_ids = tokenizer_image_token(prompt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(model.device)
|
| 65 |
+
stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
|
| 66 |
+
keywords = [stop_str]
|
| 67 |
+
stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
|
| 68 |
+
with torch.inference_mode():
|
| 69 |
+
output_ids = model.generate(
|
| 70 |
+
input_ids,
|
| 71 |
+
images=video,
|
| 72 |
+
image_sizes=image_sizes,
|
| 73 |
+
do_sample=False,
|
| 74 |
+
temperature=0.2,
|
| 75 |
+
max_new_tokens=128,
|
| 76 |
+
use_cache=True,
|
| 77 |
+
stopping_criteria=[stopping_criteria],
|
| 78 |
+
)
|
| 79 |
+
pred = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip()
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
## Citation
|
| 83 |
|
| 84 |
If you find our work helpful, feel free to give us a cite.
|
|
|
|
| 90 |
journal={arXiv preprint arXiv:2511.05489},
|
| 91 |
year={2025}
|
| 92 |
}
|
| 93 |
+
```
|