Spaces:
Paused
Paused
luminoussg
commited on
Commit
•
1a72c00
1
Parent(s):
e3f3c50
Update app.py
Browse files
app.py
CHANGED
@@ -153,9 +153,14 @@ def preview_line(video_file, scale_percent, line_start_x, line_start_y, line_end
|
|
153 |
return preview_path
|
154 |
|
155 |
def gradio_app(video, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness, draw_tracks, view_img, view_in_counts, view_out_counts, track_thickness, region_thickness, line_dist_thresh, persist, conf, iou, classes_to_track, verbose):
|
|
|
|
|
|
|
|
|
|
|
156 |
progress = gr.Progress()
|
157 |
-
total_frames = count_frames(
|
158 |
-
output_path = process_video(
|
159 |
return output_path, output_path
|
160 |
|
161 |
def update_preview(video, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness):
|
@@ -167,10 +172,15 @@ def set_4k_coordinates():
|
|
167 |
def set_1080p_coordinates():
|
168 |
return 0, 700, 1920, 700
|
169 |
|
|
|
|
|
|
|
|
|
170 |
with gr.Blocks() as demo:
|
171 |
with gr.Row():
|
172 |
with gr.Column(scale=1):
|
173 |
video_input = gr.File(label="Upload your video") # Removed max_size parameter
|
|
|
174 |
with gr.Row():
|
175 |
set_4k_button = gr.Button("4K")
|
176 |
set_1080p_button = gr.Button("1080p")
|
@@ -214,5 +224,8 @@ with gr.Blocks() as demo:
|
|
214 |
|
215 |
process_button.click(clear_previous_video, outputs=[video_output, download_button], queue=False)
|
216 |
process_button.click(gradio_app, inputs=[video_input, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness, draw_tracks, view_img, view_in_counts, view_out_counts, track_thickness, region_thickness, line_dist_thresh, persist, conf, iou, classes_to_track, verbose], outputs=[video_output, download_button])
|
|
|
|
|
|
|
217 |
|
218 |
-
demo.launch()
|
|
|
153 |
return preview_path
|
154 |
|
155 |
def gradio_app(video, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness, draw_tracks, view_img, view_in_counts, view_out_counts, track_thickness, region_thickness, line_dist_thresh, persist, conf, iou, classes_to_track, verbose):
|
156 |
+
# Save the uploaded video to the main folder
|
157 |
+
main_folder_video_path = "vehicle-counting.mp4"
|
158 |
+
with open(main_folder_video_path, "wb") as f:
|
159 |
+
f.write(open(video.name, "rb").read())
|
160 |
+
|
161 |
progress = gr.Progress()
|
162 |
+
total_frames = count_frames(main_folder_video_path)
|
163 |
+
output_path = process_video(main_folder_video_path, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, int(line_thickness), draw_tracks, view_img, view_in_counts, view_out_counts, int(track_thickness), int(region_thickness), line_dist_thresh, persist, conf, iou, classes_to_track, verbose, progress)
|
164 |
return output_path, output_path
|
165 |
|
166 |
def update_preview(video, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness):
|
|
|
172 |
def set_1080p_coordinates():
|
173 |
return 0, 700, 1920, 700
|
174 |
|
175 |
+
def use_example_video():
|
176 |
+
example_video_path = "vehicle-counting.mp4"
|
177 |
+
return example_video_path
|
178 |
+
|
179 |
with gr.Blocks() as demo:
|
180 |
with gr.Row():
|
181 |
with gr.Column(scale=1):
|
182 |
video_input = gr.File(label="Upload your video") # Removed max_size parameter
|
183 |
+
example_button = gr.Button("Use Example Video")
|
184 |
with gr.Row():
|
185 |
set_4k_button = gr.Button("4K")
|
186 |
set_1080p_button = gr.Button("1080p")
|
|
|
224 |
|
225 |
process_button.click(clear_previous_video, outputs=[video_output, download_button], queue=False)
|
226 |
process_button.click(gradio_app, inputs=[video_input, scale_percent, line_start_x, line_start_y, line_end_x, line_end_y, line_thickness, draw_tracks, view_img, view_in_counts, view_out_counts, track_thickness, region_thickness, line_dist_thresh, persist, conf, iou, classes_to_track, verbose], outputs=[video_output, download_button])
|
227 |
+
|
228 |
+
# Add the example button right below the video input
|
229 |
+
example_button.click(use_example_video, outputs=[video_input])
|
230 |
|
231 |
+
demo.launch()
|