import gradio as gr | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
from ultralytics import YOLO | |
model = YOLO('best (1).pt') | |
def response(image): | |
for i, r in enumerate(results): | |
# Plot results image | |
im_bgr = r.plot() # BGR-order numpy array | |
im_rgb = im_bgr[..., ::-1] # Convert BGR to RGB | |
plt.figure(figsize=(10, 10)) | |
plt.imshow(im_rgb) | |
plt.axis('off') | |
plt.show() | |
return results | |
iface = gr.Interface(fn=response, inputs="image", outputs="image") | |
iface.launch() |