Spaces:
Runtime error
Runtime error
Upload 10 files
Browse files- .gitattributes +1 -0
- README.md +5 -5
- app.py +83 -0
- best.pt +3 -0
- examples/.DS_Store +0 -0
- examples/images/0000000001.jpg +0 -0
- examples/images/0000000650.jpg +0 -0
- examples/images/0000000654.jpg +0 -0
- examples/images/0000000655.jpg +0 -0
- examples/videos/example_video.mp4 +3 -0
- requirements.txt +47 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
examples/videos/example_video.mp4 filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title: RSUD20K
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: RSUD20K
|
3 |
+
emoji: 🐢
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.18.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import requests
|
4 |
+
import os
|
5 |
+
from PIL import Image
|
6 |
+
from ultralytics import YOLO
|
7 |
+
|
8 |
+
|
9 |
+
################## MODEL ##################
|
10 |
+
model = YOLO('best.pt')
|
11 |
+
title = "RSUD20K"
|
12 |
+
|
13 |
+
################## IMAGE ##################
|
14 |
+
|
15 |
+
Image_directory = "examples/images"
|
16 |
+
|
17 |
+
inputs_image = [
|
18 |
+
gr.components.Image(type="filepath", label="Input Image"),
|
19 |
+
]
|
20 |
+
outputs_image = [
|
21 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
22 |
+
]
|
23 |
+
|
24 |
+
def show_preds_image(image_path):
|
25 |
+
image = cv2.imread(image_path)
|
26 |
+
outputs = model.predict(source=image_path)
|
27 |
+
results = Image.fromarray(outputs[0].plot()[:, :, ::-1])
|
28 |
+
return results
|
29 |
+
|
30 |
+
|
31 |
+
demo_image = gr.Interface(
|
32 |
+
fn=show_preds_image,
|
33 |
+
title=title,
|
34 |
+
inputs= inputs_image,
|
35 |
+
outputs= outputs_image,
|
36 |
+
examples= [os.path.join(Image_directory, fname) for fname in os.listdir(Image_directory) if fname.endswith(".jpg")],
|
37 |
+
allow_flagging="never",
|
38 |
+
analytics_enabled=False,
|
39 |
+
)
|
40 |
+
|
41 |
+
################## VIDEO ##################
|
42 |
+
|
43 |
+
Video_directory = "examples/videos"
|
44 |
+
|
45 |
+
inputs_video = [
|
46 |
+
gr.components.Video(label="Input Video"),
|
47 |
+
]
|
48 |
+
|
49 |
+
outputs_video = [
|
50 |
+
gr.components.Image(type = "numpy", label="Output Video"),
|
51 |
+
]
|
52 |
+
|
53 |
+
|
54 |
+
def show_preds_video(video_path):
|
55 |
+
cap = cv2.VideoCapture(video_path)
|
56 |
+
predicted_frames = []
|
57 |
+
while(cap.isOpened()):
|
58 |
+
ret, frame = cap.read()
|
59 |
+
if ret:
|
60 |
+
frame_copy = frame.copy()
|
61 |
+
outputs = model.predict(source=frame)
|
62 |
+
results = Image.fromarray(outputs[0].plot()[:, :, ::-1])
|
63 |
+
yield results
|
64 |
+
else:
|
65 |
+
break
|
66 |
+
cap.release()
|
67 |
+
cv2.destroyAllWindows()
|
68 |
+
|
69 |
+
demo_video = gr.Interface(
|
70 |
+
fn=show_preds_video,
|
71 |
+
title=title,
|
72 |
+
inputs= inputs_video,
|
73 |
+
outputs= outputs_video,
|
74 |
+
examples= [os.path.join(Video_directory, fname) for fname in os.listdir(Video_directory) if fname.endswith(".mp4")],
|
75 |
+
allow_flagging="never",
|
76 |
+
analytics_enabled=False,
|
77 |
+
)
|
78 |
+
|
79 |
+
################## LAUNCH ##################
|
80 |
+
gr.TabbedInterface(
|
81 |
+
[demo_image, demo_video],
|
82 |
+
tab_names=['Image inference', 'Video inference']
|
83 |
+
).queue().launch()
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ffe04bee563f192b59c1e2967357d7467a2396d63c8caacd80cc131677fe747c
|
3 |
+
size 22504110
|
examples/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
examples/images/0000000001.jpg
ADDED
![]() |
examples/images/0000000650.jpg
ADDED
![]() |
examples/images/0000000654.jpg
ADDED
![]() |
examples/images/0000000655.jpg
ADDED
![]() |
examples/videos/example_video.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96ed84811e291de404333d4f1e6f9349c3836c0f5a3c134c366431340875d617
|
3 |
+
size 4492700
|
requirements.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Ultralytics requirements
|
2 |
+
# Usage: pip install -r requirements.txt
|
3 |
+
|
4 |
+
# Base ----------------------------------------
|
5 |
+
hydra-core>=1.2.0
|
6 |
+
matplotlib>=3.2.2
|
7 |
+
numpy>=1.18.5
|
8 |
+
opencv-python>=4.1.1
|
9 |
+
Pillow>=7.1.2
|
10 |
+
PyYAML>=5.3.1
|
11 |
+
requests>=2.23.0
|
12 |
+
scipy>=1.4.1
|
13 |
+
torch>=1.7.0
|
14 |
+
torchvision>=0.8.1
|
15 |
+
tqdm>=4.64.0
|
16 |
+
ultralytics
|
17 |
+
|
18 |
+
# Logging -------------------------------------
|
19 |
+
tensorboard>=2.4.1
|
20 |
+
# clearml
|
21 |
+
# comet
|
22 |
+
|
23 |
+
# Plotting ------------------------------------
|
24 |
+
pandas>=1.1.4
|
25 |
+
seaborn>=0.11.0
|
26 |
+
|
27 |
+
# Export --------------------------------------
|
28 |
+
# coremltools>=6.0 # CoreML export
|
29 |
+
# onnx>=1.12.0 # ONNX export
|
30 |
+
# onnx-simplifier>=0.4.1 # ONNX simplifier
|
31 |
+
# nvidia-pyindex # TensorRT export
|
32 |
+
# nvidia-tensorrt # TensorRT export
|
33 |
+
# scikit-learn==0.19.2 # CoreML quantization
|
34 |
+
# tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos)
|
35 |
+
# tensorflowjs>=3.9.0 # TF.js export
|
36 |
+
# openvino-dev # OpenVINO export
|
37 |
+
|
38 |
+
# Extras --------------------------------------
|
39 |
+
ipython # interactive notebook
|
40 |
+
psutil # system utilization
|
41 |
+
thop>=0.1.1 # FLOPs computation
|
42 |
+
# albumentations>=1.0.3
|
43 |
+
# pycocotools>=2.0.6 # COCO mAP
|
44 |
+
# roboflow
|
45 |
+
|
46 |
+
# HUB -----------------------------------------
|
47 |
+
GitPython>=3.1.24
|