Spaces:
Runtime error
Runtime error
fix: π show files when image saved
Browse filesSigned-off-by: Onuralp SEZER <[email protected]>
.DS_Store
ADDED
Binary file (8.2 kB). View file
|
|
app.py
CHANGED
@@ -14,7 +14,7 @@ from mmengine.runner.amp import autocast
|
|
14 |
from mmyolo.registry import RUNNERS
|
15 |
from torchvision.ops import nms
|
16 |
import supervision as sv
|
17 |
-
import
|
18 |
import cv2
|
19 |
|
20 |
import gradio as gr
|
@@ -23,10 +23,10 @@ import gradio as gr
|
|
23 |
TITLE = """
|
24 |
# YOLO-World-Seg
|
25 |
|
26 |
-
This is a demo of zero-shot object detection and instance segmentation using
|
27 |
-
[YOLO-World](https://github.com/AILab-CVC/YOLO-World)
|
28 |
|
29 |
-
Powered by [Supervision](https://github.com/roboflow/supervision).
|
30 |
"""
|
31 |
|
32 |
EXAMPLES = [
|
@@ -62,11 +62,13 @@ def run_image(
|
|
62 |
max_num_boxes=100,
|
63 |
):
|
64 |
runner = load_runner()
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
texts = [[t.strip()] for t in class_names.split(",")] + [[" "]]
|
69 |
-
data_info = runner.pipeline(dict(img_id=0, img_path=
|
70 |
texts=texts))
|
71 |
|
72 |
data_batch = dict(
|
@@ -102,7 +104,8 @@ def run_image(
|
|
102 |
in zip(detections.class_id, detections.confidence)
|
103 |
]
|
104 |
|
105 |
-
svimage =
|
|
|
106 |
svimage = label_annotator.annotate(svimage, detections, labels)
|
107 |
svimage = mask_annotator.annotate(svimage,detections)
|
108 |
return svimage
|
@@ -142,7 +145,7 @@ with gr.Blocks() as demo:
|
|
142 |
with gr.Tab(label="Image"):
|
143 |
with gr.Row():
|
144 |
input_image_component = gr.Image(
|
145 |
-
type='
|
146 |
label='Input Image'
|
147 |
)
|
148 |
output_image_component = gr.Image(
|
|
|
14 |
from mmyolo.registry import RUNNERS
|
15 |
from torchvision.ops import nms
|
16 |
import supervision as sv
|
17 |
+
from PIL import Image
|
18 |
import cv2
|
19 |
|
20 |
import gradio as gr
|
|
|
23 |
TITLE = """
|
24 |
# YOLO-World-Seg
|
25 |
|
26 |
+
This is a demo of zero-shot object detection and instance segmentation using only
|
27 |
+
[YOLO-World](https://github.com/AILab-CVC/YOLO-World) done via newest model YOLO-World-Seg.
|
28 |
|
29 |
+
Annototions Powered by [Supervision](https://github.com/roboflow/supervision).
|
30 |
"""
|
31 |
|
32 |
EXAMPLES = [
|
|
|
62 |
max_num_boxes=100,
|
63 |
):
|
64 |
runner = load_runner()
|
65 |
+
|
66 |
+
image_path='./work_dirs/input.png'
|
67 |
+
os.makedirs('./work_dirs', exist_ok=True)
|
68 |
+
input_image.save(image_path)
|
69 |
|
70 |
texts = [[t.strip()] for t in class_names.split(",")] + [[" "]]
|
71 |
+
data_info = runner.pipeline(dict(img_id=0, img_path=image_path,
|
72 |
texts=texts))
|
73 |
|
74 |
data_batch = dict(
|
|
|
104 |
in zip(detections.class_id, detections.confidence)
|
105 |
]
|
106 |
|
107 |
+
svimage = np.array(input_image)
|
108 |
+
svimage = box_annotator.annotate(svimage, detections)
|
109 |
svimage = label_annotator.annotate(svimage, detections, labels)
|
110 |
svimage = mask_annotator.annotate(svimage,detections)
|
111 |
return svimage
|
|
|
145 |
with gr.Tab(label="Image"):
|
146 |
with gr.Row():
|
147 |
input_image_component = gr.Image(
|
148 |
+
type='pil',
|
149 |
label='Input Image'
|
150 |
)
|
151 |
output_image_component = gr.Image(
|