Upload yologradio.py
Browse files- yologradio.py +14 -0
yologradio.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
from ultralytics import YOLO
|
5 |
+
model=YOLO("yolov8s.pt")
|
6 |
+
def predict_Image(img):
|
7 |
+
if img.model!="RGB":
|
8 |
+
img=img.convert("RGB")
|
9 |
+
res=model.predict(source=img,conf=0.25)
|
10 |
+
im_array=res[0].plot()
|
11 |
+
pil_img=Image.fromarray(im_array[...,::-1])
|
12 |
+
return pil_img
|
13 |
+
iface=gr.Interface(fn=predict_Image,inputs=gr.Image(type="pil"),outputs="image",examples=["/content/234.jpg"],title="Detection of EBIKE on SparseRCNN",description="upload a picture to detect EBIKE")
|
14 |
+
iface.launch()
|