mojad121's picture
Upload 4 files
0e04e8e verified
raw
history blame contribute delete
839 Bytes
# -*- coding: utf-8 -*-
"""app.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1nIR_ak2SXq9fwQmKpq4eupLwQU_SI4fn
"""
import gradio as gr
import torch
import cv2
from ultralytics import YOLO
import numpy as np
model = YOLO("best.torchscript")
def predict(image):
results = model(image)
annotated = results[0].plot()
annotated_rgb = cv2.cvtColor(annotated, cv2.COLOR_BGR2RGB)
return annotated_rgb
iface = gr.Interface(
fn=predict,
inputs=gr.Image(type="numpy", label="Upload an image"),
outputs=gr.Image(type="numpy", label="Detected image"),
title="YOLOv8 Object Detection",
description="Upload an image to detect objects using a YOLOv8 model in TorchScript format.",
examples=None
)
if __name__ == "__main__":
iface.launch()