Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,12 +25,12 @@ model = AutoDetectionModel.from_pretrained(
|
|
25 |
def sahi_yolo_inference(
|
26 |
model_type,
|
27 |
image,
|
28 |
-
slice_height=
|
29 |
-
slice_width=
|
30 |
-
overlap_height_ratio=0.
|
31 |
-
overlap_width_ratio=0.
|
32 |
-
postprocess_type="
|
33 |
-
postprocess_match_metric="
|
34 |
postprocess_match_threshold=0.5,
|
35 |
postprocess_class_agnostic=False,
|
36 |
):
|
@@ -99,18 +99,18 @@ def sahi_yolo_inference(
|
|
99 |
inputs = [
|
100 |
gr.inputs.Dropdown(choices=model_types,label="Choose Model Type",type="value",),
|
101 |
gr.inputs.Image(type="pil", label="Original Image"),
|
102 |
-
gr.inputs.Number(default=
|
103 |
-
gr.inputs.Number(default=
|
104 |
-
gr.inputs.Number(default=0.
|
105 |
-
gr.inputs.Number(default=0.
|
106 |
gr.inputs.Dropdown(
|
107 |
["NMS", "GREEDYNMM"],
|
108 |
type="value",
|
109 |
-
default="
|
110 |
label="postprocess_type",
|
111 |
),
|
112 |
gr.inputs.Dropdown(
|
113 |
-
["IOU", "IOS"], type="value", default="
|
114 |
),
|
115 |
gr.inputs.Number(default=0.5, label="postprocess_match_threshold"),
|
116 |
gr.inputs.Checkbox(default=True, label="postprocess_class_agnostic"),
|
@@ -124,10 +124,10 @@ title = "Small Object Detection with SAHI + YOLOv5"
|
|
124 |
description = "SAHI + YOLOv5 demo for small object detection. Upload an image or click an example image to use."
|
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> | <a href='https://github.com/fcakyon/yolov5-pip'>YOLOv5 Github</a> </p>"
|
126 |
examples = [
|
127 |
-
[model_types[0],"26.jpg", 256, 256, 0.2, 0.2, "
|
128 |
-
[model_types[0],"27.jpg", 512, 512, 0.2, 0.2, "
|
129 |
-
[model_types[0],"28.jpg", 512, 512, 0.2, 0.2, "
|
130 |
-
[model_types[0],"31.jpg", 512, 512, 0.2, 0.2, "
|
131 |
|
132 |
]
|
133 |
gr.Interface(
|
|
|
25 |
def sahi_yolo_inference(
|
26 |
model_type,
|
27 |
image,
|
28 |
+
slice_height=1280,
|
29 |
+
slice_width=1280,
|
30 |
+
overlap_height_ratio=0.1,
|
31 |
+
overlap_width_ratio=0.1,
|
32 |
+
postprocess_type="NMS",
|
33 |
+
postprocess_match_metric="IOU",
|
34 |
postprocess_match_threshold=0.5,
|
35 |
postprocess_class_agnostic=False,
|
36 |
):
|
|
|
99 |
inputs = [
|
100 |
gr.inputs.Dropdown(choices=model_types,label="Choose Model Type",type="value",),
|
101 |
gr.inputs.Image(type="pil", label="Original Image"),
|
102 |
+
gr.inputs.Number(default=1920 label="slice_height"),
|
103 |
+
gr.inputs.Number(default=1920, label="slice_width"),
|
104 |
+
gr.inputs.Number(default=0.1, label="overlap_height_ratio"),
|
105 |
+
gr.inputs.Number(default=0.1, label="overlap_width_ratio"),
|
106 |
gr.inputs.Dropdown(
|
107 |
["NMS", "GREEDYNMM"],
|
108 |
type="value",
|
109 |
+
default="NMS",
|
110 |
label="postprocess_type",
|
111 |
),
|
112 |
gr.inputs.Dropdown(
|
113 |
+
["IOU", "IOS"], type="value", default="IOU", label="postprocess_type"
|
114 |
),
|
115 |
gr.inputs.Number(default=0.5, label="postprocess_match_threshold"),
|
116 |
gr.inputs.Checkbox(default=True, label="postprocess_class_agnostic"),
|
|
|
124 |
description = "SAHI + YOLOv5 demo for small object detection. Upload an image or click an example image to use."
|
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> | <a href='https://github.com/fcakyon/yolov5-pip'>YOLOv5 Github</a> </p>"
|
126 |
examples = [
|
127 |
+
[model_types[0],"26.jpg", 256, 256, 0.2, 0.2, "NMS", "IOU", 0.5, True],
|
128 |
+
[model_types[0],"27.jpg", 512, 512, 0.2, 0.2, "NMS", "IOU", 0.5, True],
|
129 |
+
[model_types[0],"28.jpg", 512, 512, 0.2, 0.2, "NMS", "IOU", 0.5, True],
|
130 |
+
[model_types[0],"31.jpg", 512, 512, 0.2, 0.2, "NMS", "IOU", 0.5, True],
|
131 |
|
132 |
]
|
133 |
gr.Interface(
|