Spaces:
Sleeping
Sleeping
Added from Yolov9
Browse files- app.py +22 -0
- best.pt +3 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from ultralytics import YOLO
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Load the YOLOv9 model
|
7 |
+
model = YOLO('best.pt') # Make sure best.pt is in the same folder
|
8 |
+
|
9 |
+
def detect(image):
|
10 |
+
results = model(image)
|
11 |
+
annotated_frame = results[0].plot() # Draw predictions on the image
|
12 |
+
return Image.fromarray(annotated_frame)
|
13 |
+
|
14 |
+
# Launch the Gradio interface
|
15 |
+
gr.Interface(
|
16 |
+
fn=detect,
|
17 |
+
inputs=gr.Image(type="pil"),
|
18 |
+
outputs=gr.Image(type="pil"),
|
19 |
+
title="YOLOv9 (Ultralytics) Object Detection",
|
20 |
+
description="Upload an image to run object detection using your custom YOLOv9 model.",
|
21 |
+
).launch()
|
22 |
+
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bac45e3f015ac183637df63558f4f6d1c0908e87cbc7a91eaa09a6e3e1af276e
|
3 |
+
size 40842779
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ultralytics>=8.1.5
|
2 |
+
gradio
|
3 |
+
Pillow
|