ZZQ987 commited on
Commit
2dd3c75
·
verified ·
1 Parent(s): 52d8389

Update demo_vc3_proactive.py

Browse files
Files changed (1) hide show
  1. 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 = 4.0
42
  MAX_PIXELS = 224*224 # pixel budget for normal frames
43
- MAX_ROUNDS = 32
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=True, temperature=0.7
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
- frames_per_round = max(1, round(TARGET_FPS))
 
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 / TARGET_FPS
154
- time_end = (frame_start + len(frames)) / TARGET_FPS
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,