Video-Text-to-Text
Transformers
Safetensors
English
Chinese
videochat3
feature-extraction
video-language-model
vision-language-model
multimodal
video-understanding
image-understanding
streaming-video
custom_code
Instructions to use MCG-NJU/VideoChat3-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MCG-NJU/VideoChat3-4B with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MCG-NJU/VideoChat3-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update demo_vc3_proactive.py
Browse files- demo_vc3_proactive.py +7 -6
demo_vc3_proactive.py
CHANGED
|
@@ -38,9 +38,9 @@ MODEL_PATH = "MCG-NJU/VideoChat3-4B"
|
|
| 38 |
VIDEO_PATH = "example.mp4"
|
| 39 |
QUESTION = "Your question"
|
| 40 |
# ----------------------------------------------------------
|
| 41 |
-
TARGET_FPS =
|
| 42 |
MAX_PIXELS = 224*224 # pixel budget for normal frames
|
| 43 |
-
MAX_ROUNDS =
|
| 44 |
MAX_NEW_TOKENS = 128
|
| 45 |
# ----------------------------------------------------------
|
| 46 |
|
|
@@ -114,7 +114,7 @@ def main():
|
|
| 114 |
with torch.inference_mode():
|
| 115 |
out = model.generate(
|
| 116 |
**inputs, max_new_tokens=max_tokens,
|
| 117 |
-
do_sample=
|
| 118 |
)
|
| 119 |
trimmed = [o[len(i):] for i, o in zip(inputs.input_ids, out)]
|
| 120 |
text = processor.batch_decode(
|
|
@@ -129,7 +129,8 @@ def main():
|
|
| 129 |
)
|
| 130 |
|
| 131 |
extractor = VideoFrameExtractor(args.video, target_fps=TARGET_FPS)
|
| 132 |
-
|
|
|
|
| 133 |
standby_remaining = 0
|
| 134 |
|
| 135 |
try:
|
|
@@ -150,8 +151,8 @@ def main():
|
|
| 150 |
frames = [_resize_frame(frame, max_px) for frame in raw_frames]
|
| 151 |
|
| 152 |
round_idx = frame_start // frames_per_round
|
| 153 |
-
time_start = frame_start /
|
| 154 |
-
time_end = (frame_start + len(frames)) /
|
| 155 |
answer = session.step(
|
| 156 |
frames,
|
| 157 |
round_idx=round_idx,
|
|
|
|
| 38 |
VIDEO_PATH = "example.mp4"
|
| 39 |
QUESTION = "Your question"
|
| 40 |
# ----------------------------------------------------------
|
| 41 |
+
TARGET_FPS = 2.0
|
| 42 |
MAX_PIXELS = 224*224 # pixel budget for normal frames
|
| 43 |
+
MAX_ROUNDS = 16
|
| 44 |
MAX_NEW_TOKENS = 128
|
| 45 |
# ----------------------------------------------------------
|
| 46 |
|
|
|
|
| 114 |
with torch.inference_mode():
|
| 115 |
out = model.generate(
|
| 116 |
**inputs, max_new_tokens=max_tokens,
|
| 117 |
+
do_sample=False, temperature=1.0, top_p=1.0, top_k=0,
|
| 118 |
)
|
| 119 |
trimmed = [o[len(i):] for i, o in zip(inputs.input_ids, out)]
|
| 120 |
text = processor.batch_decode(
|
|
|
|
| 129 |
)
|
| 130 |
|
| 131 |
extractor = VideoFrameExtractor(args.video, target_fps=TARGET_FPS)
|
| 132 |
+
actual_fps = extractor.actual_fps if extractor.actual_fps > 0 else TARGET_FPS
|
| 133 |
+
frames_per_round = max(1, round(actual_fps))
|
| 134 |
standby_remaining = 0
|
| 135 |
|
| 136 |
try:
|
|
|
|
| 151 |
frames = [_resize_frame(frame, max_px) for frame in raw_frames]
|
| 152 |
|
| 153 |
round_idx = frame_start // frames_per_round
|
| 154 |
+
time_start = frame_start / actual_fps
|
| 155 |
+
time_end = (frame_start + len(frames)) / actual_fps
|
| 156 |
answer = session.step(
|
| 157 |
frames,
|
| 158 |
round_idx=round_idx,
|