| import torch | |
| import gradio as gr | |
| from PIL import Image | |
| from ultralytics import YOLO | |
| model=YOLO("yolov8s.pt") | |
| def predict_Image(img): | |
| if img.model!="RGB": | |
| img=img.convert("RGB") | |
| res=model.predict(source=img,conf=0.25) | |
| im_array=res[0].plot() | |
| pil_img=Image.fromarray(im_array[...,::-1]) | |
| return pil_img | |
| iface=gr.Interface(fn=predict_Image,inputs=gr.Image(type="pil"),outputs="image",examples=["/input_img/ds.jpg"],title="Detection of EBIKE on SparseRCNN",description="upload a picture to detect EBIKE") | |
| iface.launch() |