Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -331,13 +331,18 @@ def process_video(
|
|
| 331 |
|
| 332 |
return annotator_frame
|
| 333 |
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
| 335 |
sv.process_video(
|
| 336 |
source_path=video_path,
|
| 337 |
target_path=output_path,
|
| 338 |
-
callback=callback
|
| 339 |
)
|
| 340 |
-
|
|
|
|
|
|
|
| 341 |
|
| 342 |
|
| 343 |
with gr.Blocks(title="Nhận dạng phương tiện giao thông", theme=gr.themes.Soft(primary_hue="blue", secondary_hue="gray")) as demo:
|
|
@@ -369,6 +374,7 @@ with gr.Blocks(title="Nhận dạng phương tiện giao thông", theme=gr.theme
|
|
| 369 |
)
|
| 370 |
video_output = gr.Video(label="Video đã xử lý")
|
| 371 |
|
|
|
|
| 372 |
with gr.Accordion("⚙️ Tùy chọn nâng cao", open=False):
|
| 373 |
with gr.Row():
|
| 374 |
use_resize = gr.Checkbox(
|
|
|
|
| 331 |
|
| 332 |
return annotator_frame
|
| 333 |
|
| 334 |
+
# Tạo file tạm để lưu video output (đảm bảo file không bị khóa trên Windows)
|
| 335 |
+
fd, output_path = tempfile.mkstemp(suffix=".mp4")
|
| 336 |
+
os.close(fd)
|
| 337 |
+
|
| 338 |
sv.process_video(
|
| 339 |
source_path=video_path,
|
| 340 |
target_path=output_path,
|
| 341 |
+
callback=callback,
|
| 342 |
)
|
| 343 |
+
|
| 344 |
+
# Chuẩn hóa path về dạng forward slash cho Gradio/Trình duyệt
|
| 345 |
+
return output_path.replace("\\", "/")
|
| 346 |
|
| 347 |
|
| 348 |
with gr.Blocks(title="Nhận dạng phương tiện giao thông", theme=gr.themes.Soft(primary_hue="blue", secondary_hue="gray")) as demo:
|
|
|
|
| 374 |
)
|
| 375 |
video_output = gr.Video(label="Video đã xử lý")
|
| 376 |
|
| 377 |
+
# Tùy chọn cấu hình
|
| 378 |
with gr.Accordion("⚙️ Tùy chọn nâng cao", open=False):
|
| 379 |
with gr.Row():
|
| 380 |
use_resize = gr.Checkbox(
|