File size: 782 Bytes
c38745d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# from fastapi import FastAPI, File, UploadFile
# from fastapi.responses import StreamingResponse
from io import BytesIO
import cv2
import numpy as np
import gradio as gr
from ultralytics import YOLO
# Inicializar o modelo YOLO
model = YOLO("/content/best.pt")
# Definir a função para detecção de objetos
def detect_objects(image):
# Realizar a detecção de objetos com YOLOv8
detections = model.predict(image)
# Renderizar as detecções na imagem
rendered_image = detections.render()
return rendered_image
# Criar a interface Gradio
app = gr.Interface(
fn=detect_objects,
inputs="image",
outputs="image",
title="YOLOv8 Object Detection",
description="Detect objects in images using YOLOv8.",
)
# Executar o aplicativo
app.launch()
|