Spaces:
Running
Running
update yo yolo11
#4
by
fcakyon
- opened
- README.md +1 -1
- app.py +23 -14
- packages.txt +1 -1
- requirements.txt +8 -5
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Small Object Detection with
|
3 |
emoji: 🔭
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
|
|
1 |
---
|
2 |
+
title: Small Object Detection with YOLO11
|
3 |
emoji: 🔭
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
app.py
CHANGED
@@ -5,6 +5,15 @@ import sahi.predict
|
|
5 |
import sahi.slicing
|
6 |
from PIL import Image
|
7 |
import numpy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
IMAGE_SIZE = 640
|
10 |
|
@@ -31,7 +40,7 @@ sahi.utils.file.download_from_url(
|
|
31 |
|
32 |
# Model
|
33 |
model = AutoDetectionModel.from_pretrained(
|
34 |
-
model_type="
|
35 |
)
|
36 |
|
37 |
|
@@ -98,10 +107,10 @@ def sahi_yolo_inference(
|
|
98 |
|
99 |
inputs = [
|
100 |
gr.Image(type="pil", label="Original Image"),
|
101 |
-
gr.Number(
|
102 |
-
gr.Number(
|
103 |
-
gr.Number(
|
104 |
-
gr.Number(
|
105 |
gr.Dropdown(
|
106 |
["NMS", "GREEDYNMM"],
|
107 |
type="value",
|
@@ -109,20 +118,20 @@ inputs = [
|
|
109 |
label="postprocess_type",
|
110 |
),
|
111 |
gr.Dropdown(
|
112 |
-
["IOU", "IOS"], type="value",
|
113 |
),
|
114 |
-
gr.Number(
|
115 |
-
gr.Checkbox(
|
116 |
]
|
117 |
|
118 |
outputs = [
|
119 |
-
gr.Image(type="pil", label="
|
120 |
-
gr.Image(type="pil", label="
|
121 |
]
|
122 |
|
123 |
-
title = "Small Object Detection with SAHI +
|
124 |
-
description = "SAHI +
|
125 |
-
article = "<p style='text-align: center'>SAHI is a lightweight vision library for performing large scale object detection/ instance segmentation.. <a href='https://github.com/obss/sahi'>SAHI Github</a> | <a href='https://medium.com/codable/sahi-a-vision-library-for-performing-sliced-inference-on-large-images-small-objects-c8b086af3b80'>SAHI Blog</a>
|
126 |
examples = [
|
127 |
["apple_tree.jpg", 256, 256, 0.2, 0.2, "NMS", "IOU", 0.4, True],
|
128 |
["highway.jpg", 256, 256, 0.2, 0.2, "NMS", "IOU", 0.4, True],
|
@@ -140,4 +149,4 @@ gr.Interface(
|
|
140 |
examples=examples,
|
141 |
theme="huggingface",
|
142 |
cache_examples=True,
|
143 |
-
).launch(debug=True
|
|
|
5 |
import sahi.slicing
|
6 |
from PIL import Image
|
7 |
import numpy
|
8 |
+
from ultralytics import YOLO
|
9 |
+
|
10 |
+
|
11 |
+
import sys
|
12 |
+
import types
|
13 |
+
if 'huggingface_hub.utils._errors' not in sys.modules:
|
14 |
+
mock_errors = types.ModuleType('_errors')
|
15 |
+
mock_errors.RepositoryNotFoundError = Exception
|
16 |
+
sys.modules['huggingface_hub.utils._errors'] = mock_errors
|
17 |
|
18 |
IMAGE_SIZE = 640
|
19 |
|
|
|
40 |
|
41 |
# Model
|
42 |
model = AutoDetectionModel.from_pretrained(
|
43 |
+
model_type="ultralytics", model_path="yolo11s.pt", device="cpu", confidence_threshold=0.5, image_size=IMAGE_SIZE
|
44 |
)
|
45 |
|
46 |
|
|
|
107 |
|
108 |
inputs = [
|
109 |
gr.Image(type="pil", label="Original Image"),
|
110 |
+
gr.Number(value=512, label="slice_height"),
|
111 |
+
gr.Number(value=512, label="slice_width"),
|
112 |
+
gr.Number(value=0.2, label="overlap_height_ratio"),
|
113 |
+
gr.Number(value=0.2, label="overlap_width_ratio"),
|
114 |
gr.Dropdown(
|
115 |
["NMS", "GREEDYNMM"],
|
116 |
type="value",
|
|
|
118 |
label="postprocess_type",
|
119 |
),
|
120 |
gr.Dropdown(
|
121 |
+
["IOU", "IOS"], type="value", value="IOU", label="postprocess_type"
|
122 |
),
|
123 |
+
gr.Number(value=0.5, label="postprocess_match_threshold"),
|
124 |
+
gr.Checkbox(value=True, label="postprocess_class_agnostic"),
|
125 |
]
|
126 |
|
127 |
outputs = [
|
128 |
+
gr.Image(type="pil", label="YOLO11s Standard"),
|
129 |
+
gr.Image(type="pil", label="YOLO11s + SAHI Sliced"),
|
130 |
]
|
131 |
|
132 |
+
title = "Small Object Detection with SAHI + YOLO11"
|
133 |
+
description = "SAHI + YOLO11 demo for small object detection. Upload your own image or click an example image to use."
|
134 |
+
article = "<p style='text-align: center'>SAHI is a lightweight vision library for performing large scale object detection/ instance segmentation.. <a href='https://github.com/obss/sahi'>SAHI Github</a> | <a href='https://medium.com/codable/sahi-a-vision-library-for-performing-sliced-inference-on-large-images-small-objects-c8b086af3b80'>SAHI Blog</a> </p>"
|
135 |
examples = [
|
136 |
["apple_tree.jpg", 256, 256, 0.2, 0.2, "NMS", "IOU", 0.4, True],
|
137 |
["highway.jpg", 256, 256, 0.2, 0.2, "NMS", "IOU", 0.4, True],
|
|
|
149 |
examples=examples,
|
150 |
theme="huggingface",
|
151 |
cache_examples=True,
|
152 |
+
).launch(debug=True)
|
packages.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
ffmpeg
|
2 |
libsm6
|
3 |
-
libxext6
|
|
|
1 |
ffmpeg
|
2 |
libsm6
|
3 |
+
libxext6
|
requirements.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
-
torch
|
2 |
-
torchvision
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
1 |
+
torch>=1.11.0
|
2 |
+
torchvision>=0.12.0
|
3 |
+
sahi>=0.11.0
|
4 |
+
numpy<2.0.0
|
5 |
+
gradio>=3.0.0
|
6 |
+
Pillow>=8.0.0
|
7 |
+
opencv-python>=4.5.0
|
8 |
+
ultralytics
|