# -*- coding: utf-8 -*- """day1deployobjectdetection.ipynb Automatically generated by Colab. Original file is located at https://colab.research.google.com/drive/1CwEhyaDiq5FTGAq5PgIHhd1K_mZygEub """ from ultralytics import YOLO import cv2 import time import gradio as gr from PIL import Image import numpy as np # create the model model = YOLO("yolov8n.pt") # create function to detect the image def detectImage(image): # if the image is none, then skip it if image is None: return None # get the result results = model.predict(source=image, save=False) # create the boxes resultImage = results[0].plot() return Image.fromarray(resultImage) # create the website application app = gr.Interface( fn=detectImage, inputs=gr.Image(type="numpy", label="just upload the some random image"), outputs=gr.Image(type="pil", label="the result of the object detection goes here"), title="my object detection using yolo", description="just upload a random image and then wait until the object detection result show" ) app.launch(debug=True)