Spaces:
Runtime error
Runtime error
Pawel_Mar
commited on
Commit
·
612b741
1
Parent(s):
4e05e43
appilcation should be finished
Browse files- app.py +17 -7
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -1,12 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 12 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
|
| 4 |
|
| 5 |
+
def yoloV8_func(image: gr.inputs.Image = None):
|
| 6 |
+
model_path = "models/last.pt"
|
| 7 |
+
model = YOLO(model_path)
|
| 8 |
+
results = model.predict(image)
|
| 9 |
+
mask_json = results[0].masks.data.tojson()
|
| 10 |
|
| 11 |
+
return str(mask_json)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
yolo_app = gr.Interface(
|
| 15 |
+
fn=yoloV8_func,
|
| 16 |
+
inputs=gr.inputs.Image(type="filepath", label="Input Image"),
|
| 17 |
+
outputs=gr.Textbox(),
|
| 18 |
+
title="YOLOv8: Custom Instance segmentation on lettuce leafs",
|
| 19 |
+
cache_examples=True,
|
| 20 |
+
)
|
| 21 |
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 22 |
+
yolo_app.launch()
|
requirements.txt
CHANGED
|
@@ -2,4 +2,4 @@ opencv-python-headless
|
|
| 2 |
pandas
|
| 3 |
ultralytics
|
| 4 |
Pillow
|
| 5 |
-
|
|
|
|
| 2 |
pandas
|
| 3 |
ultralytics
|
| 4 |
Pillow
|
| 5 |
+
gradio
|