Upload model
Browse files
app.py
CHANGED
@@ -1,67 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
import cv2
|
3 |
import requests
|
4 |
-
import os
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
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 |
-
|
15 |
-
def download_file(url, save_name):
|
16 |
-
url = url
|
17 |
-
if not os.path.exists(save_name):
|
18 |
-
file = requests.get(url)
|
19 |
-
open(save_name, 'wb').write(file.content)
|
20 |
-
|
21 |
-
|
22 |
-
for i, url in enumerate(file_urls):
|
23 |
-
if 'mp4' in file_urls[i]:
|
24 |
-
download_file(
|
25 |
-
file_urls[i],
|
26 |
-
f"video.mp4"
|
27 |
-
)
|
28 |
-
else:
|
29 |
-
download_file(
|
30 |
-
file_urls[i],
|
31 |
-
f"image_{i}.jpg"
|
32 |
-
)
|
33 |
-
model = YOLO('best.pt')
|
34 |
-
path = [['image_0.jpg'], ['image_1.jpg']]
|
35 |
-
video_path = [['video.mp4']]
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
52 |
-
|
53 |
-
|
54 |
-
inputs_image = [
|
55 |
-
gr.components.Image(type="filepath", label="Input Image"),
|
56 |
-
]
|
57 |
-
outputs_image = [
|
58 |
-
gr.components.Image(type="numpy", label="Output Image"),
|
59 |
-
]
|
60 |
-
interface_image = gr.Interface(
|
61 |
-
fn=show_preds_image,
|
62 |
-
inputs=inputs_image,
|
63 |
-
outputs=outputs_image,
|
64 |
-
title="Pothole detector",
|
65 |
-
examples=path,
|
66 |
-
cache_examples=False,
|
67 |
-
)
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
|
|
3 |
|
4 |
+
def predict_label(img_path ):
|
5 |
|
6 |
+
results = model(img_path)
|
7 |
+
return map[results[0].probs.data.argmax().item()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
inputs_image = [
|
10 |
+
gr.components.Image(type="filepath", label="Input Image"),
|
11 |
+
]
|
12 |
+
outputs_image = [
|
13 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
14 |
+
]
|
15 |
+
interface_image = gr.Interface(
|
16 |
+
fn=show_preds_image,
|
17 |
+
inputs=inputs_image,
|
18 |
+
outputs=outputs_image,
|
19 |
+
title="Pothole detector",
|
20 |
+
examples=path,
|
21 |
+
cache_examples=False,
|
22 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|