Spaces:
Runtime error
Runtime error
Diego Fernandez
commited on
Commit
·
547bded
1
Parent(s):
b17ce0d
feat: add cache results
Browse files- app.py +3 -2
- demo_utils/files.py +8 -0
- inference.py +11 -1
- outputs/soccer_YOLOv7_out.mp4 +3 -0
app.py
CHANGED
@@ -7,9 +7,9 @@ from inference import inference
|
|
7 |
|
8 |
input_video = gr.Video(mirror_webcam=False)
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
|
14 |
features = gr.CheckboxGroup(
|
15 |
choices=["Track camera movement", "Draw objects paths"],
|
@@ -28,6 +28,7 @@ slide_threshold = gr.Slider(minimum=0, maximum=1, value=0.25, label="Model confi
|
|
28 |
|
29 |
intput_components = [
|
30 |
input_video,
|
|
|
31 |
dd_model,
|
32 |
features,
|
33 |
dd_track_points,
|
|
|
7 |
|
8 |
input_video = gr.Video(mirror_webcam=False)
|
9 |
|
10 |
+
cb_cache_output = gr.Checkbox(value=True, label="Use chache example result")
|
11 |
|
12 |
+
dd_model = gr.Dropdown(choices=["YOLOv7", "YOLOv7 Tiny"], value="YOLOv7", label="Model")
|
13 |
|
14 |
features = gr.CheckboxGroup(
|
15 |
choices=["Track camera movement", "Draw objects paths"],
|
|
|
28 |
|
29 |
intput_components = [
|
30 |
input_video,
|
31 |
+
cb_cache_output,
|
32 |
dd_model,
|
33 |
features,
|
34 |
dd_track_points,
|
demo_utils/files.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import List
|
3 |
+
|
4 |
+
|
5 |
+
def get_files(folder: str) -> List:
|
6 |
+
files_list = [file.split(".")[0] for file in os.listdir(folder)]
|
7 |
+
|
8 |
+
return files_list
|
inference.py
CHANGED
@@ -14,10 +14,12 @@ from demo_utils.configuration import (
|
|
14 |
)
|
15 |
from demo_utils.distance_function import euclidean_distance, iou
|
16 |
from demo_utils.draw import center, draw
|
|
|
17 |
|
18 |
|
19 |
def inference(
|
20 |
input_video: str,
|
|
|
21 |
model: str,
|
22 |
features: str,
|
23 |
track_points: str,
|
@@ -26,6 +28,14 @@ def inference(
|
|
26 |
# temp_dir = tempfile.TemporaryDirectory()
|
27 |
# output_path = temp_dir.name
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
coord_transformations = None
|
30 |
paths_drawer = None
|
31 |
fix_paths = False
|
@@ -65,7 +75,7 @@ def inference(
|
|
65 |
paths_drawer = Paths(center, attenuation=0.01)
|
66 |
|
67 |
if fix_paths:
|
68 |
-
paths_drawer = AbsolutePaths(max_history=
|
69 |
|
70 |
for frame in video:
|
71 |
yolo_detections = model(
|
|
|
14 |
)
|
15 |
from demo_utils.distance_function import euclidean_distance, iou
|
16 |
from demo_utils.draw import center, draw
|
17 |
+
from demo_utils.files import get_files
|
18 |
|
19 |
|
20 |
def inference(
|
21 |
input_video: str,
|
22 |
+
cb_cache_output: bool,
|
23 |
model: str,
|
24 |
features: str,
|
25 |
track_points: str,
|
|
|
28 |
# temp_dir = tempfile.TemporaryDirectory()
|
29 |
# output_path = temp_dir.name
|
30 |
|
31 |
+
if cb_cache_output:
|
32 |
+
for cache_video in get_files("examples"):
|
33 |
+
if input_video.find(cache_video) == -1:
|
34 |
+
continue
|
35 |
+
|
36 |
+
cache_video_name = f"outputs/{cache_video}_{model}_out.mp4"
|
37 |
+
return cache_video_name
|
38 |
+
|
39 |
coord_transformations = None
|
40 |
paths_drawer = None
|
41 |
fix_paths = False
|
|
|
75 |
paths_drawer = Paths(center, attenuation=0.01)
|
76 |
|
77 |
if fix_paths:
|
78 |
+
paths_drawer = AbsolutePaths(max_history=15, thickness=2)
|
79 |
|
80 |
for frame in video:
|
81 |
yolo_detections = model(
|
outputs/soccer_YOLOv7_out.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f913effd319ea0108016bab55dc4acf4275aafc5bd48b657a99948ba023f38fe
|
3 |
+
size 7186625
|