Views
No views yet
[!Important] This is a Real-Time SFT checkpoint. It is optimized for low-latency, high-frequency real-time video understanding.


MllamaVideoModel, it performs autoregressive generation alongside the visual stream, achieving ultra-low Time to First Token (TTFT).real_time_generate() API for low-latency streaming.1import os, queue, threading, time, cv2
2from PIL import Image
3from transformers import AutoProcessor, AutoModelForCausalLM
4
5def feed(video, q, fps=1.0):
6 cap=cv2.VideoCapture(video); step=max(1, round((cap.get(cv2.CAP_PROP_FPS) or 25)/fps)); i=0
7 while cap.isOpened():
8 ok, f = cap.read()
9 if not ok: break
10 if i % step == 0: q.put(Image.fromarray(cv2.cvtColor(f, cv2.COLOR_BGR2RGB))); time.sleep(1/fps)
11 i += 1
12 cap.release()
13
14checkpoint = "OpenMOSS-Team/moss-video-preview-realtime-sft"
15video_path = "data/example_video.mp4"
16prompt = "Describe the video."
17
18processor=AutoProcessor.from_pretrained(checkpoint, trust_remote_code=True)
19model=AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True, device_map="auto")
20
21image_queue, prompt_queue, token_queue = queue.Queue(), queue.Queue(), queue.Queue()
22threading.Thread(target=feed, args=(video_path, image_queue), daemon=True).start()
23time.sleep(1)
24prompt_queue.put(prompt)
25threading.Thread(
26 target=lambda: model.real_time_generate(image_queue, prompt_queue, token_queue, processor),
27 daemon=True,
28).start()
29
30END={"[DONE]","[ERROR]","<|round_end|>"}; BANNER="\n"+"-"*30+" [Silence / Observing] "+"-"*30
31pending=None; silent=False; last=time.time(); got=False
32while True:
33 try: tok = token_queue.get(timeout=0.1)
34 except queue.Empty:
35 if pending: print(pending, end="", flush=True); pending=None
36 if got and time.time()-last>5: break
37 continue
38 got,last=True,time.time()
39 if tok=="<|round_start|>": pending=None; continue
40 if tok in END:
41 if pending: print(pending, end="", flush=True)
42 break
43 if tok=="<|silence|>":
44 if not silent:
45 if pending: print(pending, end="", flush=True); pending=None
46 print(BANNER, flush=True); silent=True
47 continue
48 silent=False
49 if pending: print(pending, end="", flush=True)
50 pending=tok
51
52if hasattr(model,"stop_real_time_generate"): model.stop_real_time_generate()
531import os
2import queue
3import threading
4
5import torch
6from transformers import AutoModelForCausalLM, AutoProcessor
7
8checkpoint = "OpenMOSS-Team/moss-video-preview-realtime-sft"
9video_path = "data/example_video.mp4"
10prompt = "Describe the video."
11
12max_new_tokens = 1024
13temperature = 1.0
14top_k = 50
15top_p = 1.0
16repetition_penalty = 1.0
17
18video_fps = 1.0
19video_minlen = 8
20video_maxlen = 256
21
22
23def load_model(checkpoint: str):
24 processor = AutoProcessor.from_pretrained(
25 checkpoint, trust_remote_code=True, frame_extract_num_threads=1
26 )
27 model = AutoModelForCausalLM.from_pretrained(
28 checkpoint,
29 trust_remote_code=True,
30 device_map="auto",
31 torch_dtype=torch.bfloat16,
32 attn_implementation="flash_attention_2",
33 )
34 return model, processor
35
36
37if not checkpoint:
38 raise ValueError("Missing `checkpoint`.")
39if not video_path:
40 raise ValueError("Missing `video_path`.")
41if not os.path.isfile(video_path):
42 raise FileNotFoundError(f"Video not found: {video_path}")
43
44model, processor = load_model(checkpoint)
45new_queries: "queue.Queue[dict]" = queue.Queue()
46output_text_queue: "queue.Queue[str]" = queue.Queue()
47
48new_queries.put(
49 {
50 "prompt": f"\n{prompt}",
51 "images": [],
52 "videos": [video_path],
53 "media_kwargs": {
54 "video_fps": video_fps,
55 "video_minlen": video_minlen,
56 "video_maxlen": video_maxlen,
57 },
58 "thinking_mode": "no_thinking",
59 "system_prompt_type": "video",
60 "generate_kwargs": {
61 "temperature": temperature,
62 "top_k": top_k,
63 "top_p": top_p,
64 "max_new_tokens": max_new_tokens,
65 "repetition_penalty": repetition_penalty,
66 },
67 "stop_offline_generate": False,
68 }
69)
70new_queries.put({"stop_offline_generate": True})
71
72
73def drain_output():
74 while True:
75 tok = output_text_queue.get()
76 if tok == "<|round_end|>":
77 break
78 print(tok, end="", flush=True)
79
80
81t = threading.Thread(target=drain_output, daemon=True)
82t.start()
83with torch.no_grad():
84 model.offline_generate(processor, new_queries, output_text_queue, vision_chunked_length=64)
85t.join(timeout=5.0)1
2
3import os, queue, threading, torch
4from PIL import Image
5from transformers import AutoModelForCausalLM, AutoProcessor
6checkpoint = "OpenMOSS-Team/moss-video-preview-realtime-sft"
7image_path = "data/example_image.jpg"
8prompt = "Describe this image."
9if not os.path.isfile(image_path):
10 raise FileNotFoundError(image_path)
11
12processor = AutoProcessor.from_pretrained(
13 checkpoint, trust_remote_code=True, frame_extract_num_threads=1
14)
15model = AutoModelForCausalLM.from_pretrained(
16 checkpoint, trust_remote_code=True, device_map="auto", torch_dtype=torch.bfloat16, attn_implementation="flash_attention_2"
17)
18
19new_q, out_q = queue.Queue(), queue.Queue()
20new_q.put(
21 {
22 "prompt": f"\n{prompt}",
23 "images": [Image.open(image_path).convert("RGB")],
24 "videos": [],
25 "system_prompt_type": "text_image",
26 "thinking_mode": "no_thinking",
27 "generate_kwargs": {"temperature": 1.0, "top_k": 50, "top_p": 1.0, "max_new_tokens": 256, "repetition_penalty": 1.0},
28 "stop_offline_generate": False,
29 }
30)
31new_q.put({"stop_offline_generate": True})
32
33threading.Thread(
34 target=lambda: (lambda: [print(t, end="", flush=True) for t in iter(out_q.get, "<|round_end|>")])(),
35 daemon=True,
36).start()
37
38with torch.no_grad():
39 model.offline_generate(processor, new_q, out_q, vision_chunked_length=64)trust_remote_code=True[!IMPORTANT]🌟 Our Mission & Community Invitation
We have filled the gap in cross-attention-based foundation models for video understanding.We warmly welcome experts in Representation Learning and Model Efficiency to explore, experiment, and innovate on top of our architecture. Let's push the boundaries of video intelligence and advance the open-source community together!
1@article{wang2026mossvideo,
2 title = {{MOSS-Video-Preview: Toward Real-Time Video Understanding via Cross-Attention}},
3 author = {Pengyu Wang, Chenkun Tan, Shaojun Zhou, Wei Huang, Qirui Zhou, Zhan Huang, Zhen Ye, Jijun Cheng, Xiaomeng Qian, Yanxin Chen, Xingyang He, Huazheng Zeng, Chenghao Wang, Pengfei Wang, Hongkai Wang, Shanqing Gao, Yixian Tian, Chenghao Liu, Xinghao Wang, Botian Jiang, Xipeng Qiu},
4 year = {2026},
5 journal = {arXiv preprint arXiv:2606.07639},
6 eprint = {2606.07639},
7 archivePrefix = {arXiv},
8 primaryClass = {cs.CV},
9 url = {https://arxiv.org/abs/2606.07639}
10}