Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesFiles changed (3)
- app.pyAdded+25
- best.ptAdded+3
- requirements.txtAdded+5
12345678910111213141516171819202122232425from ultralytics import YOLO
import gradio as gr
from PIL import Image
import numpy as np
# Load the trained YOLOv8 model for human detection
model = YOLO("best.pt") # Replace with the correct path to your human detection model
# Define prediction function
def detect_humans(image):
results = model(image) # Perform inference
result_img = results[0].plot() # Draw bounding boxes
return Image.fromarray(result_img.astype(np.uint8)) # Return image with boxes
# Build Gradio interface
interface = gr.Interface(
fn=detect_humans,
inputs=gr.Image(type="pil", label="Upload Image"),
outputs=gr.Image(type="pil", label="Detected Humans"),
title="Human Detection (YOLOv8)",
description="Upload an image. The model will detect humans using your trained YOLOv8 model."
)
# Launch the interface
interface.launch(debug=True)123version https://git-lfs.github.com/spec/v1oid sha256:46226e84be7b995285cf35f9db84521c4af254c1f3449d9aeeacb63a934980basize 622998712345ultralytics>=8.0.20
gradio>=4.0.0
pillow
opencv-python
numpyapp.pyAdded+25
best.ptAdded+3
requirements.txtAdded+5