Spaces:
Sleeping
Sleeping
Commit
·
6b2a8f7
1
Parent(s):
4ac195c
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,20 @@
|
|
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 |
-
'
|
10 |
-
'
|
11 |
-
'https://www.dropbox.com/scl/fi/y7z20q3ye7xcxak3r2byp/ct.mp4?rlkey=0phq1um1jnl3oy1j6jjyuppsd&dl=0'
|
12 |
]
|
13 |
|
14 |
-
|
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 |
-
)
|
31 |
|
32 |
model = YOLO('best.pt')
|
33 |
-
path
|
34 |
-
|
35 |
|
36 |
def show_preds_image(image_path):
|
37 |
image = cv2.imread(image_path)
|
@@ -58,11 +41,11 @@ interface_image = gr.Interface(
|
|
58 |
fn=show_preds_image,
|
59 |
inputs=inputs_image,
|
60 |
outputs=outputs_image,
|
61 |
-
title="
|
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()):
|
@@ -81,24 +64,9 @@ def show_preds_video(video_path):
|
|
81 |
lineType=cv2.LINE_AA
|
82 |
)
|
83 |
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
84 |
-
|
85 |
-
inputs_video = [
|
86 |
-
gr.components.Video(type="filepath", label="Input Video"),
|
87 |
-
|
88 |
-
]
|
89 |
-
outputs_video = [
|
90 |
-
gr.components.Image(type="numpy", label="Output Image"),
|
91 |
-
]
|
92 |
-
interface_video = gr.Interface(
|
93 |
-
fn=show_preds_video,
|
94 |
-
inputs=inputs_video,
|
95 |
-
outputs=outputs_video,
|
96 |
-
title="Pothole detector",
|
97 |
-
examples=video_path,
|
98 |
-
cache_examples=False,
|
99 |
-
)
|
100 |
|
101 |
gr.TabbedInterface(
|
102 |
-
[interface_image
|
103 |
-
tab_names=['
|
104 |
-
).
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
|
|
3 |
import os
|
4 |
|
5 |
from ultralytics import YOLO
|
6 |
|
7 |
+
# Remove the URLs containing 'mp4'
|
8 |
file_urls = [
|
9 |
+
'Cyst.jpg',
|
10 |
+
'Stone.jpg'
|
|
|
11 |
]
|
12 |
|
13 |
+
# Do not download files from URLs, use local files directly
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
model = YOLO('best.pt')
|
16 |
+
path = [['Cyst.jpg'], ['Stone.jpg']]
|
17 |
+
|
18 |
|
19 |
def show_preds_image(image_path):
|
20 |
image = cv2.imread(image_path)
|
|
|
41 |
fn=show_preds_image,
|
42 |
inputs=inputs_image,
|
43 |
outputs=outputs_image,
|
44 |
+
title="Kidney Stone and Cyst detection",
|
45 |
examples=path,
|
46 |
cache_examples=False,
|
47 |
)
|
48 |
+
'''
|
49 |
def show_preds_video(video_path):
|
50 |
cap = cv2.VideoCapture(video_path)
|
51 |
while(cap.isOpened()):
|
|
|
64 |
lineType=cv2.LINE_AA
|
65 |
)
|
66 |
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
67 |
+
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
gr.TabbedInterface(
|
70 |
+
[interface_image],
|
71 |
+
tab_names=['Shamim MD Jony']
|
72 |
+
).launch()
|