yonigozlan HF Staff commited on
Commit
82b4cf3
·
1 Parent(s): 2929986

change output file name

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
- import os
2
  import time
 
3
 
4
  import cv2
5
  import gradio as gr
@@ -61,9 +61,7 @@ def process_video(
61
  global threshold
62
  classes = classes_new
63
  threshold = confidence_threshold
64
- result_file_name = "output.mp4"
65
- result_file_path = os.path.join(os.getcwd(), result_file_name)
66
- batch_fps = []
67
 
68
  cap = cv2.VideoCapture(input_video)
69
 
@@ -74,7 +72,7 @@ def process_video(
74
  desired_fps = fps // SUBSAMPLE
75
  iterating, frame = cap.read()
76
  segment_file = cv2.VideoWriter(
77
- result_file_path, video_codec, desired_fps, (width, height)
78
  ) # type: ignore
79
  batch = []
80
  frames = []
@@ -115,14 +113,14 @@ def process_video(
115
  segment_file.write(frame)
116
  segment_file.release()
117
  yield (
118
- result_file_path,
119
  gr.Markdown(
120
  f'<h3 style="text-align: center;">Model inference FPS (batched): {fps*len(batch):.2f}</h3>',
121
  visible=True,
122
  ),
123
  )
124
  segment_file = cv2.VideoWriter(
125
- result_file_path, video_codec, desired_fps, (width, height)
126
  ) # type: ignore
127
  batch = []
128
  frames = []
 
 
1
  import time
2
+ import uuid
3
 
4
  import cv2
5
  import gradio as gr
 
61
  global threshold
62
  classes = classes_new
63
  threshold = confidence_threshold
64
+ result_file_name = f"output_{uuid.uuid4()}.mp4"
 
 
65
 
66
  cap = cv2.VideoCapture(input_video)
67
 
 
72
  desired_fps = fps // SUBSAMPLE
73
  iterating, frame = cap.read()
74
  segment_file = cv2.VideoWriter(
75
+ result_file_name, video_codec, desired_fps, (width, height)
76
  ) # type: ignore
77
  batch = []
78
  frames = []
 
113
  segment_file.write(frame)
114
  segment_file.release()
115
  yield (
116
+ result_file_name,
117
  gr.Markdown(
118
  f'<h3 style="text-align: center;">Model inference FPS (batched): {fps*len(batch):.2f}</h3>',
119
  visible=True,
120
  ),
121
  )
122
  segment_file = cv2.VideoWriter(
123
+ result_file_name, video_codec, desired_fps, (width, height)
124
  ) # type: ignore
125
  batch = []
126
  frames = []