Pedro Henrique Conrado commited on
Commit
62cf07b
·
1 Parent(s): f4c8762
Files changed (2) hide show
  1. app.py +17 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -24,16 +24,29 @@ import yolox
24
  os.system("pip3 install cython_bbox gdown 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'")
25
  os.system("pip3 install -v -e .")
26
  from yolox.tracker.byte_tracker import BYTETracker, STrack
27
-
28
 
29
  MODEL = "./best.pt"
30
 
31
- SOURCE_VIDEO_PATH = "./examples"
32
-
33
  TARGET_VIDEO_PATH = "test.mp4"
34
 
35
  CLASS_ID = [0,1,2,3]
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  model = YOLO(MODEL)
38
  model.fuse()
39
 
@@ -128,5 +141,5 @@ def ObjectDetection(video_path):
128
 
129
  return TARGET_VIDEO_PATH
130
 
131
- demo = gr.Interface(fn=ObjectDetection, inputs=gr.Video(), outputs=gr.Video(), examples=SOURCE_VIDEO_PATH, cache_examples=False)
132
  demo.launch()
 
24
  os.system("pip3 install cython_bbox gdown 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'")
25
  os.system("pip3 install -v -e .")
26
  from yolox.tracker.byte_tracker import BYTETracker, STrack
27
+ import requests
28
 
29
  MODEL = "./best.pt"
30
 
 
 
31
  TARGET_VIDEO_PATH = "test.mp4"
32
 
33
  CLASS_ID = [0,1,2,3]
34
 
35
+ file_urls = [
36
+ 'https://www.dropbox.com/s/qf9le18eoirfkbd/3_2.mp4?dl=0'
37
+ ]
38
+
39
+ def download_file(url, save_name):
40
+ url = url
41
+ if not os.path.exists(save_name):
42
+ file = requests.get(url)
43
+ open(save_name, 'wb').write(file.content)
44
+
45
+ for i, url in enumerate(file_urls):
46
+ download_file(file_urls[i], f"video.mp4")
47
+
48
+ video_path = [['video.mp4']]
49
+
50
  model = YOLO(MODEL)
51
  model.fuse()
52
 
 
141
 
142
  return TARGET_VIDEO_PATH
143
 
144
+ demo = gr.Interface(fn=ObjectDetection, inputs=gr.Video(), outputs=gr.Video(), examples=video_path, cache_examples=False)
145
  demo.launch()
requirements.txt CHANGED
@@ -82,4 +82,5 @@ lap
82
  motmetrics
83
  filterpy
84
  h5py
85
- cython
 
 
82
  motmetrics
83
  filterpy
84
  h5py
85
+ cython
86
+ requests