Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ def count_people_in_video(video_path):
|
|
| 18 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
| 19 |
|
| 20 |
# Buat VideoWriter untuk menyimpan video output
|
| 21 |
-
output_dir = "
|
| 22 |
os.makedirs(output_dir, exist_ok=True)
|
| 23 |
output_path = os.path.join(output_dir, "person_counter_output.mp4")
|
| 24 |
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
|
|
@@ -57,16 +57,15 @@ def count_people_in_video(video_path):
|
|
| 57 |
return output_path, person_count_total
|
| 58 |
|
| 59 |
# Membuat antarmuka Gradio
|
| 60 |
-
def gradio_interface(
|
| 61 |
-
output_path, person_count = count_people_in_video(
|
| 62 |
return output_path, f"Total people detected: {person_count}"
|
| 63 |
|
| 64 |
# Antarmuka Gradio
|
| 65 |
iface = gr.Interface(
|
| 66 |
fn=gradio_interface,
|
| 67 |
-
inputs=gr.
|
| 68 |
outputs=[gr.File(), gr.Text()],
|
| 69 |
-
live=True
|
| 70 |
)
|
| 71 |
|
| 72 |
# Menjalankan aplikasi
|
|
|
|
| 18 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
| 19 |
|
| 20 |
# Buat VideoWriter untuk menyimpan video output
|
| 21 |
+
output_dir = "output_videos"
|
| 22 |
os.makedirs(output_dir, exist_ok=True)
|
| 23 |
output_path = os.path.join(output_dir, "person_counter_output.mp4")
|
| 24 |
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
|
|
|
|
| 57 |
return output_path, person_count_total
|
| 58 |
|
| 59 |
# Membuat antarmuka Gradio
|
| 60 |
+
def gradio_interface(video_file):
|
| 61 |
+
output_path, person_count = count_people_in_video(video_file)
|
| 62 |
return output_path, f"Total people detected: {person_count}"
|
| 63 |
|
| 64 |
# Antarmuka Gradio
|
| 65 |
iface = gr.Interface(
|
| 66 |
fn=gradio_interface,
|
| 67 |
+
inputs=gr.File(type="file"),
|
| 68 |
outputs=[gr.File(), gr.Text()],
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
# Menjalankan aplikasi
|