Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
def yoloV8_func(image: gr.Image = None):
|
|
@@ -9,15 +10,15 @@ def yoloV8_func(image: gr.Image = None):
|
|
| 9 |
masks_json = []
|
| 10 |
for result in results:
|
| 11 |
if result.masks:
|
| 12 |
-
masks_json.append(result.masks.xy)
|
| 13 |
-
|
| 14 |
return masks_json
|
| 15 |
|
| 16 |
|
| 17 |
yolo_app = gr.Interface(
|
| 18 |
fn=yoloV8_func,
|
| 19 |
inputs=gr.Image(type="filepath", label="Input Image"),
|
| 20 |
-
outputs=
|
| 21 |
title="YOLOv8: Custom Instance segmentation on lettuce leafs",
|
| 22 |
cache_examples=True,
|
| 23 |
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
|
| 6 |
def yoloV8_func(image: gr.Image = None):
|
|
|
|
| 10 |
masks_json = []
|
| 11 |
for result in results:
|
| 12 |
if result.masks:
|
| 13 |
+
masks_json.append([{"x": format(point[0], '.2f'), "y": format(point[1], '.2f')} for point in result.masks.xy[0]])
|
| 14 |
+
json.dumps(masks_json[0])
|
| 15 |
return masks_json
|
| 16 |
|
| 17 |
|
| 18 |
yolo_app = gr.Interface(
|
| 19 |
fn=yoloV8_func,
|
| 20 |
inputs=gr.Image(type="filepath", label="Input Image"),
|
| 21 |
+
outputs="json",
|
| 22 |
title="YOLOv8: Custom Instance segmentation on lettuce leafs",
|
| 23 |
cache_examples=True,
|
| 24 |
)
|