Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- .gitattributes +2 -0
- app.py +38 -0
- image1.jpg +3 -0
- image2.jpg +3 -0
- my_model.pt +3 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ 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 |
+
image1.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
image2.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ultralytics import YOLO
|
2 |
+
import cv2
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
file = "my_model.pt"
|
6 |
+
images = [["image1.jpg"],["image2.jpg"]]
|
7 |
+
model = YOLO(file)
|
8 |
+
|
9 |
+
def show_preds_image(image_path):
|
10 |
+
image = cv2. imread(image_path)
|
11 |
+
outputs = model.predict(source=image_path)
|
12 |
+
results = outputs[0]. cpu().numpy()
|
13 |
+
for i, det in enumerate(results.boxes.xyxy):
|
14 |
+
cv2. rectangle(image,(int(det[0]), int(det[1])), (int(det[2]), int(det[3])),
|
15 |
+
thickness=2 , color=[0,255,0]
|
16 |
+
)
|
17 |
+
return cv2. cvtColor (image, cv2.COLOR_BGR2RGB)
|
18 |
+
|
19 |
+
|
20 |
+
inputs_image = [
|
21 |
+
gr.components.Image(type="filepath", label="Input Image"),
|
22 |
+
]
|
23 |
+
outputs_image = [
|
24 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
25 |
+
]
|
26 |
+
|
27 |
+
interface_image = gr.Interface(
|
28 |
+
fn=show_preds_image,
|
29 |
+
inputs=inputs_image,
|
30 |
+
outputs=outputs_image,
|
31 |
+
title="Plastic Detector",
|
32 |
+
examples=images,
|
33 |
+
cache_examples=False,
|
34 |
+
)
|
35 |
+
|
36 |
+
interface_image.launch()
|
37 |
+
|
38 |
+
|
image1.jpg
ADDED
![]() |
Git LFS Details
|
image2.jpg
ADDED
![]() |
Git LFS Details
|
my_model.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4305da01e86751f7c094615f04997e62d145a85ec16efe247f2ad4b89f25de1f
|
3 |
+
size 19182419
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ultralytics==8.3.80
|
2 |
+
Pillow==9.4.0
|
3 |
+
httpx==0.24.1
|
4 |
+
gradio==3.35.2
|
5 |
+
gradio_client==0.2.7
|