Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +25 -0
- best.pt +3 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralytics import YOLO
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Load the trained YOLOv8 model for human detection
|
| 7 |
+
model = YOLO("best.pt") # Replace with the correct path to your human detection model
|
| 8 |
+
|
| 9 |
+
# Define prediction function
|
| 10 |
+
def detect_humans(image):
|
| 11 |
+
results = model(image) # Perform inference
|
| 12 |
+
result_img = results[0].plot() # Draw bounding boxes
|
| 13 |
+
return Image.fromarray(result_img.astype(np.uint8)) # Return image with boxes
|
| 14 |
+
|
| 15 |
+
# Build Gradio interface
|
| 16 |
+
interface = gr.Interface(
|
| 17 |
+
fn=detect_humans,
|
| 18 |
+
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 19 |
+
outputs=gr.Image(type="pil", label="Detected Humans"),
|
| 20 |
+
title="Human Detection (YOLOv8)",
|
| 21 |
+
description="Upload an image. The model will detect humans using your trained YOLOv8 model."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Launch the interface
|
| 25 |
+
interface.launch(debug=True)
|
best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46226e84be7b995285cf35f9db84521c4af254c1f3449d9aeeacb63a934980ba
|
| 3 |
+
size 6229987
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ultralytics>=8.0.20
|
| 2 |
+
gradio>=4.0.0
|
| 3 |
+
pillow
|
| 4 |
+
opencv-python
|
| 5 |
+
numpy
|