| Model | Charades-TimeLens | ActivityNet-TimeLens | QVHighlights-TimeLens | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R1 @0.3 | R1 @0.5 | R1 @0.7 | mIoU | R1 @0.3 | R1 @0.5 | R1 @0.7 | mIoU | R1 @0.3 | R1 @0.5 | R1 @0.7 | mIoU | |
| Qwen2.5-VL-7B-Instruct | 59.7 | 37.8 | 16.6 | 39.3 | 44.1 | 31.0 | 16.1 | 31.4 | 41.5 | 27.8 | 15.2 | 31.6 |
| TimeLens-7B🚀 | 70.5 | 55.6 | 28.4 | 48.8 | 62.8 | 51.0 | 32.6 | 46.2 | 74.1 | 62.7 | 43.1 | 56.0 |
| Qwen3-VL-8B-Instruct | 69.2 | 53.4 | 27.5 | 48.3 | 62.1 | 51.2 | 34.4 | 46.8 | 74.2 | 64.6 | 49.3 | 59.4 |
| TimeLens-8B🚀 | 76.6 | 63.0 | 35.2 | 55.2 | 68.9 | 58.4 | 40.6 | 53.2 | 80.2 | 71.6 | 55.5 | 65.5 |
For detailed comparison with other models, please refer to the 🏆 Leaderboard.
1pip install transformers==4.57.1 accelerate==1.6.0 torch==2.6.0 torchvision==0.21.0
2pip install qwen-vl-utils[decord]==0.0.14
3# use Flash-Attention 2 to speed up generation
4pip install flash-attn==2.7.4.post1 --no-build-isolation --no-cache-dir1import requests
2import os
3import torch
4from transformers import AutoModelForImageTextToText, AutoProcessor
5from qwen_vl_utils import process_vision_info
6
7
8def download_video(url):
9 save_path = os.path.basename(url)
10 if not os.path.exists(save_path):
11 print(f"Downloading video from {url}...")
12 response = requests.get(url, stream=True)
13 response.raise_for_status()
14 with open(save_path, 'wb') as f:
15 for chunk in response.iter_content(chunk_size=8192):
16 f.write(chunk)
17 return save_path
18
19# Load model and processor
20model = AutoModelForImageTextToText.from_pretrained(
21 "TencentARC/TimeLens-8B",
22 dtype=torch.bfloat16,
23 attn_implementation="flash_attention_2",
24 device_map="auto",
25)
26
27processor = AutoProcessor.from_pretrained(
28 "TencentARC/TimeLens-8B",
29 padding_side="left",
30 do_resize=False,
31)
32
33# Prepare input
34query = "A man drinks water with a glass"
35video_path = download_video("https://huggingface.co/datasets/JungleGym/TimeLens-Assets/resolve/main/2Y8XQ.mp4")
36
37GROUNDER_PROMPT = "Please find the visual event described by the sentence '{}', determining its starting and ending times. The format should be: 'The event happens in <start time> - <end time> seconds'."
38
39messages = [{
40 'role': 'user',
41 'content': [
42 {
43 'type': 'video',
44 'video': video_path,
45 'min_pixels': 64 * 32 * 32,
46 'total_pixels': 14336 * 32 * 32,
47 'fps': 2,
48 },
49 {
50 'type': 'text',
51 'text': GROUNDER_PROMPT.format(query)
52 }
53 ]
54}]
55
56text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
57images, videos, video_kwargs = process_vision_info(
58 messages,
59 image_patch_size=16,
60 return_video_kwargs=True,
61 return_video_metadata=True,
62)
63
64videos, video_metadatas = zip(*videos)
65videos, video_metadatas = list(videos), list(video_metadatas)
66
67inputs = processor(
68 text=[text],
69 images=images,
70 videos=videos,
71 video_metadata=video_metadatas,
72 padding=True,
73 return_tensors='pt',
74 **video_kwargs,
75).to("cuda")
76
77output_ids = model.generate(
78 **inputs,
79 do_sample=False,
80 max_new_tokens=512,
81)
82
83generated_ids_trimmed = [
84 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, output_ids)
85]
86answer = processor.batch_decode(
87 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
88)[0]
89print(f"Answer: {answer}")1@article{zhang2025timelens,
2 title={TimeLens: Rethinking Video Temporal Grounding with Multimodal LLMs},
3 author={Zhang, Jun and Wang, Teng and Ge, Yuying and Ge, Yixiao and Li, Xinhao and Shan, Ying and Wang, Limin},
4 journal={arXiv preprint arXiv:2512.14698},
5 year={2025}
6}