sovitrath commited on
Commit
d9e18fa
1 Parent(s): 6568a70

Sample video path added

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -8,7 +8,8 @@ from ultralytics import YOLO
8
 
9
  file_urls = [
10
  'https://www.dropbox.com/s/b5g97xo901zb3ds/pothole_example.jpg?dl=1',
11
- 'https://www.dropbox.com/s/86uxlxxlm1iaexa/pothole_screenshot.png?dl=1'
 
12
  ]
13
 
14
  def download_file(url, save_name):
@@ -17,14 +18,21 @@ def download_file(url, save_name):
17
  file = requests.get(url)
18
  open(save_name, 'wb').write(file.content)
19
 
20
- for i, url in enumerate(file_urls):
21
- download_file(
22
- file_urls[i],
23
- f"image_{i}.jpg"
24
- )
 
 
 
 
 
 
25
 
26
  model = YOLO('best.pt')
27
  path = [['image_0.jpg'], ['image_1.jpg']]
 
28
 
29
  def show_preds_image(image_path):
30
  image = cv2.imread(image_path)
@@ -93,7 +101,7 @@ interface_video = gr.Interface(
93
  inputs=inputs_video,
94
  outputs=outputs_video,
95
  title="Pothole detector",
96
- # examples=path,
97
  cache_examples=False,
98
  # live=True,
99
  )
 
8
 
9
  file_urls = [
10
  'https://www.dropbox.com/s/b5g97xo901zb3ds/pothole_example.jpg?dl=1',
11
+ 'https://www.dropbox.com/s/86uxlxxlm1iaexa/pothole_screenshot.png?dl=1',
12
+ 'https://www.dropbox.com/s/7sjfwncffg8xej2/video_7.mp4?dl=1'
13
  ]
14
 
15
  def download_file(url, save_name):
 
18
  file = requests.get(url)
19
  open(save_name, 'wb').write(file.content)
20
 
21
+ for i, url in enumerate(file_urls):
22
+ if 'mp4' in file_urls[i]:
23
+ download_file(
24
+ file_urls[i],
25
+ f"video.mp4"
26
+ )
27
+ else:
28
+ download_file(
29
+ file_urls[i],
30
+ f"image_{i}.jpg"
31
+ )
32
 
33
  model = YOLO('best.pt')
34
  path = [['image_0.jpg'], ['image_1.jpg']]
35
+ video_path = [['video.mp4']]
36
 
37
  def show_preds_image(image_path):
38
  image = cv2.imread(image_path)
 
101
  inputs=inputs_video,
102
  outputs=outputs_video,
103
  title="Pothole detector",
104
+ examples=video_path,
105
  cache_examples=False,
106
  # live=True,
107
  )