Spaces:
Running
on
Zero
Running
on
Zero
generate caption only once
Browse files
app.py
CHANGED
|
@@ -89,16 +89,20 @@ def process_video(
|
|
| 89 |
)
|
| 90 |
result_file_name = generate_file_name(extension="mp4")
|
| 91 |
result_file_path = os.path.join(RESULTS, result_file_name)
|
|
|
|
| 92 |
TRACKER.reset()
|
|
|
|
|
|
|
| 93 |
with sv.VideoSink(result_file_path, video_info=video_info) as sink:
|
| 94 |
for _ in tqdm(range(total // OUTPUT_LENGTH), desc="Processing video..."):
|
| 95 |
frame = next(frame_generator)
|
| 96 |
-
caption
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
| 102 |
detections = run_caption_to_phrase_grounding(
|
| 103 |
model=MODEL,
|
| 104 |
processor=PROCESSOR,
|
|
|
|
| 89 |
)
|
| 90 |
result_file_name = generate_file_name(extension="mp4")
|
| 91 |
result_file_path = os.path.join(RESULTS, result_file_name)
|
| 92 |
+
|
| 93 |
TRACKER.reset()
|
| 94 |
+
caption = None
|
| 95 |
+
|
| 96 |
with sv.VideoSink(result_file_path, video_info=video_info) as sink:
|
| 97 |
for _ in tqdm(range(total // OUTPUT_LENGTH), desc="Processing video..."):
|
| 98 |
frame = next(frame_generator)
|
| 99 |
+
if caption is None:
|
| 100 |
+
caption = run_captioning(
|
| 101 |
+
model=MODEL,
|
| 102 |
+
processor=PROCESSOR,
|
| 103 |
+
image=frame,
|
| 104 |
+
device=DEVICE
|
| 105 |
+
)[CAPTIONING_TASK]
|
| 106 |
detections = run_caption_to_phrase_grounding(
|
| 107 |
model=MODEL,
|
| 108 |
processor=PROCESSOR,
|