Spaces:
Sleeping
Sleeping
Commit
·
da48803
1
Parent(s):
ee78881
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import random
|
3 |
+
import numpy as np
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
from ultralytics import YOLO
|
7 |
+
|
8 |
+
|
9 |
+
def predict(path:str):
|
10 |
+
model = YOLO("yolov8s.yaml")
|
11 |
+
model = YOLO("best.pt")
|
12 |
+
imagen = cv2.imread(path)
|
13 |
+
results = model.predict(source=path)
|
14 |
+
|
15 |
+
for r in results:
|
16 |
+
return r.plot(show_conf=True, line_width=None, font_size=None, pil=False, example='abc')
|
17 |
+
|
18 |
+
|
19 |
+
gr.Interface(fn=predict,
|
20 |
+
inputs=gr.components.Image(type="filepath", label="Input"),
|
21 |
+
outputs=gr.components.Image(type="numpy", label="Output")).launch()
|