aiqcamp commited on
Commit
6feb9f3
Β·
verified Β·
1 Parent(s): 4f01584

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -161,11 +161,33 @@ def video_vision(video_input_path, prompt, video_interval):
161
  prediction = translate_to_korean(prediction)
162
 
163
  if '[SEG]' in prediction and Visualizer is not None:
164
- # λ‚˜λ¨Έμ§€ μ½”λ“œλŠ” 동일...
165
-
166
- return prediction, output_video if '[SEG]' in prediction else (prediction, None)
167
-
168
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  # Gradio UI
171
 
 
161
  prediction = translate_to_korean(prediction)
162
 
163
  if '[SEG]' in prediction and Visualizer is not None:
164
+ _seg_idx = 0
165
+ pred_masks = result['prediction_masks'][_seg_idx]
166
+ seg_frames = []
167
+ for frame_idx in range(len(vid_frames)):
168
+ pred_mask = pred_masks[frame_idx]
169
+ temp_dir = tempfile.mkdtemp()
170
+ os.makedirs(temp_dir, exist_ok=True)
171
+ seg_frame = visualize(pred_mask, image_paths[frame_idx], temp_dir)
172
+ seg_frames.append(seg_frame)
173
+
174
+ output_video = "output_video.mp4"
175
+ frame = cv2.imread(seg_frames[0])
176
+ height, width, layers = frame.shape
177
+ fourcc = cv2.VideoWriter_fourcc(*'mp4v')
178
+ video = cv2.VideoWriter(output_video, fourcc, new_fps, (width, height))
179
+
180
+ for img_path in seg_frames:
181
+ frame = cv2.imread(img_path)
182
+ video.write(frame)
183
+
184
+ video.release()
185
+ print(f"Video created successfully at {output_video}")
186
+
187
+ return prediction, output_video
188
+
189
+ else:
190
+ return prediction, None
191
 
192
  # Gradio UI
193