Spaces:
Running
Running
Cleaning up App.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
from gradio.outputs import Label
|
3 |
import cv2
|
4 |
import requests
|
5 |
import os
|
@@ -39,7 +38,6 @@ def show_preds_image(image_path):
|
|
39 |
outputs = model.predict(source=image_path)
|
40 |
results = outputs[0].cpu().numpy()
|
41 |
for i, det in enumerate(results.boxes.xyxy):
|
42 |
-
# print(det.xyxy)
|
43 |
cv2.rectangle(
|
44 |
image,
|
45 |
(int(det[0]), int(det[1])),
|
@@ -52,8 +50,6 @@ def show_preds_image(image_path):
|
|
52 |
|
53 |
inputs_image = [
|
54 |
gr.components.Image(type="filepath", label="Input Image"),
|
55 |
-
# gr.components.Video(type="filepath", label="Input Video", optional=True),
|
56 |
-
|
57 |
]
|
58 |
outputs_image = [
|
59 |
gr.components.Image(type="numpy", label="Output Image"),
|
@@ -65,10 +61,8 @@ interface_image = gr.Interface(
|
|
65 |
title="Pothole detector",
|
66 |
examples=path,
|
67 |
cache_examples=False,
|
68 |
-
# live=True,
|
69 |
)
|
70 |
|
71 |
-
|
72 |
def show_preds_video(video_path):
|
73 |
cap = cv2.VideoCapture(video_path)
|
74 |
while(cap.isOpened()):
|
@@ -78,7 +72,6 @@ def show_preds_video(video_path):
|
|
78 |
outputs = model.predict(source=frame)
|
79 |
results = outputs[0].cpu().numpy()
|
80 |
for i, det in enumerate(results.boxes.xyxy):
|
81 |
-
# print(det.xyxy)
|
82 |
cv2.rectangle(
|
83 |
frame_copy,
|
84 |
(int(det[0]), int(det[1])),
|
@@ -103,9 +96,8 @@ interface_video = gr.Interface(
|
|
103 |
title="Pothole detector",
|
104 |
examples=video_path,
|
105 |
cache_examples=False,
|
106 |
-
# live=True,
|
107 |
)
|
108 |
-
|
109 |
gr.TabbedInterface(
|
110 |
[interface_image, interface_video],
|
111 |
tab_names=['Image inference', 'Video inference']
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import cv2
|
3 |
import requests
|
4 |
import os
|
|
|
38 |
outputs = model.predict(source=image_path)
|
39 |
results = outputs[0].cpu().numpy()
|
40 |
for i, det in enumerate(results.boxes.xyxy):
|
|
|
41 |
cv2.rectangle(
|
42 |
image,
|
43 |
(int(det[0]), int(det[1])),
|
|
|
50 |
|
51 |
inputs_image = [
|
52 |
gr.components.Image(type="filepath", label="Input Image"),
|
|
|
|
|
53 |
]
|
54 |
outputs_image = [
|
55 |
gr.components.Image(type="numpy", label="Output Image"),
|
|
|
61 |
title="Pothole detector",
|
62 |
examples=path,
|
63 |
cache_examples=False,
|
|
|
64 |
)
|
65 |
|
|
|
66 |
def show_preds_video(video_path):
|
67 |
cap = cv2.VideoCapture(video_path)
|
68 |
while(cap.isOpened()):
|
|
|
72 |
outputs = model.predict(source=frame)
|
73 |
results = outputs[0].cpu().numpy()
|
74 |
for i, det in enumerate(results.boxes.xyxy):
|
|
|
75 |
cv2.rectangle(
|
76 |
frame_copy,
|
77 |
(int(det[0]), int(det[1])),
|
|
|
96 |
title="Pothole detector",
|
97 |
examples=video_path,
|
98 |
cache_examples=False,
|
|
|
99 |
)
|
100 |
+
|
101 |
gr.TabbedInterface(
|
102 |
[interface_image, interface_video],
|
103 |
tab_names=['Image inference', 'Video inference']
|