Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import requests
|
4 |
+
import os
|
5 |
+
|
6 |
+
from ultralytics import YOLO
|
7 |
+
|
8 |
+
file_urls = [
|
9 |
+
'https://www.dropbox.com/s/b5g97xo901zb3ds/pothole_example.jpg?dl=1',
|
10 |
+
'https://www.dropbox.com/s/86uxlxxlm1iaexa/pothole_screenshot.png?dl=1',
|
11 |
+
'https://www.dropbox.com/s/7sjfwncffg8xej2/video_7.mp4?dl=1'
|
12 |
+
]
|
13 |
+
|
14 |
+
def download_file(url, save_name):
|
15 |
+
url = url
|
16 |
+
if not os.path.exists(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 |
+
if 'mp4' in file_urls[i]:
|
22 |
+
download_file(
|
23 |
+
file_urls[i],
|
24 |
+
f"video.mp4"
|
25 |
+
)
|
26 |
+
else:
|
27 |
+
download_file(
|
28 |
+
file_urls[i],
|
29 |
+
f"image_{i}.jpg"
|
30 |
+
)
|