Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,10 +39,10 @@ def sahi_yolo_inference(
|
|
| 39 |
image,
|
| 40 |
slice_height=512,
|
| 41 |
slice_width=512,
|
| 42 |
-
overlap_height_ratio=0.
|
| 43 |
-
overlap_width_ratio=0.
|
| 44 |
-
postprocess_type="
|
| 45 |
-
postprocess_match_metric="
|
| 46 |
postprocess_match_threshold=0.5,
|
| 47 |
postprocess_class_agnostic=False,
|
| 48 |
):
|
|
@@ -97,19 +97,19 @@ def sahi_yolo_inference(
|
|
| 97 |
|
| 98 |
|
| 99 |
inputs = [
|
| 100 |
-
gr.
|
| 101 |
-
gr.
|
| 102 |
-
gr.
|
| 103 |
-
gr.
|
| 104 |
-
gr.
|
| 105 |
-
gr.
|
| 106 |
["NMS", "GREEDYNMM"],
|
| 107 |
type="value",
|
| 108 |
-
|
| 109 |
label="postprocess_type",
|
| 110 |
),
|
| 111 |
gr.inputs.Dropdown(
|
| 112 |
-
["IOU", "IOS"], type="value", default="
|
| 113 |
),
|
| 114 |
gr.inputs.Number(default=0.5, label="postprocess_match_threshold"),
|
| 115 |
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 |
-
["apple_tree.jpg", 256, 256, 0.
|
| 128 |
-
["highway.jpg", 256, 256, 0.
|
| 129 |
-
["highway2.jpg", 512, 512, 0.
|
| 130 |
-
["highway3.jpg", 512, 512, 0.
|
| 131 |
]
|
| 132 |
|
| 133 |
gr.Interface(
|
|
@@ -139,4 +139,5 @@ gr.Interface(
|
|
| 139 |
article=article,
|
| 140 |
examples=examples,
|
| 141 |
theme="huggingface",
|
|
|
|
| 142 |
).launch(debug=True, enable_queue=True)
|
|
|
|
| 39 |
image,
|
| 40 |
slice_height=512,
|
| 41 |
slice_width=512,
|
| 42 |
+
overlap_height_ratio=0.1,
|
| 43 |
+
overlap_width_ratio=0.1,
|
| 44 |
+
postprocess_type="NMS",
|
| 45 |
+
postprocess_match_metric="IOU",
|
| 46 |
postprocess_match_threshold=0.5,
|
| 47 |
postprocess_class_agnostic=False,
|
| 48 |
):
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
inputs = [
|
| 100 |
+
gr.Image(type="pil", label="Original Image"),
|
| 101 |
+
gr.Number(default=512, label="slice_height"),
|
| 102 |
+
gr.Number(default=512, label="slice_width"),
|
| 103 |
+
gr.Number(default=0.1, label="overlap_height_ratio"),
|
| 104 |
+
gr.Number(default=0.1, label="overlap_width_ratio"),
|
| 105 |
+
gr.Dropdown(
|
| 106 |
["NMS", "GREEDYNMM"],
|
| 107 |
type="value",
|
| 108 |
+
value="NMS",
|
| 109 |
label="postprocess_type",
|
| 110 |
),
|
| 111 |
gr.inputs.Dropdown(
|
| 112 |
+
["IOU", "IOS"], type="value", default="IOU", label="postprocess_type"
|
| 113 |
),
|
| 114 |
gr.inputs.Number(default=0.5, label="postprocess_match_threshold"),
|
| 115 |
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 |
+
["apple_tree.jpg", 256, 256, 0.1, 0.1, "NMS", "IOU", 0.5, True],
|
| 128 |
+
["highway.jpg", 256, 256, 0.1, 0.1, "NMS", "IOU", 0.5, True],
|
| 129 |
+
["highway2.jpg", 512, 512, 0.1, 0.1, "NMS", "IOU", 0.5, True],
|
| 130 |
+
["highway3.jpg", 512, 512, 0.1, 0.1, "NMS", "IOU", 0.5, True],
|
| 131 |
]
|
| 132 |
|
| 133 |
gr.Interface(
|
|
|
|
| 139 |
article=article,
|
| 140 |
examples=examples,
|
| 141 |
theme="huggingface",
|
| 142 |
+
cache_examples=True,
|
| 143 |
).launch(debug=True, enable_queue=True)
|