Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +29 -0
- best.pt +3 -0
- requirements.txt +11 -0
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
+
import os
|
| 4 |
+
import glob
|
| 5 |
+
# Load the trained YOLOv10 model
|
| 6 |
+
model = YOLO('/content/runs/detect/train/weights/best.pt')
|
| 7 |
+
|
| 8 |
+
# Inference function for Gradio
|
| 9 |
+
def detect_objects(image):
|
| 10 |
+
# Run prediction
|
| 11 |
+
results = model.predict(source=image, save=True, conf=0.5)
|
| 12 |
+
|
| 13 |
+
# Get the path of the saved image
|
| 14 |
+
predicted_image_dir = 'runs/detect/predict'
|
| 15 |
+
predicted_image_path = glob.glob(f"{predicted_image_dir}/*")
|
| 16 |
+
|
| 17 |
+
return predicted_image_path[0]
|
| 18 |
+
|
| 19 |
+
# Create the Gradio interface
|
| 20 |
+
app = gr.Interface(
|
| 21 |
+
fn=detect_objects,
|
| 22 |
+
inputs=gr.Image(type="filepath", label="Upload Image"),
|
| 23 |
+
outputs=gr.Image(type="filepath", label="Detected Image"),
|
| 24 |
+
title="YOLOv10 Object Detection App",
|
| 25 |
+
description="Upload an image to detect blood cells (RBC, WBC, Platelets) using the fine-tuned YOLOv10 model."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Launch the app
|
| 29 |
+
app.launch(share=True)
|
best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:72c82d84ee8a69ee767873b795dca016186afc721bbfab86b8e6c88d736c135a
|
| 3 |
+
size 5738931
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ultralytics
|
| 2 |
+
opencv-python-headless
|
| 3 |
+
gradio
|
| 4 |
+
torch
|
| 5 |
+
glob
|
| 6 |
+
Image
|
| 7 |
+
cv2
|
| 8 |
+
matplotlib
|
| 9 |
+
os
|
| 10 |
+
shutil
|
| 11 |
+
sklearn
|