Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,19 @@ import gradio as gr
|
|
| 2 |
from ultralytics import YOLO
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
model_path = "best.pt"
|
|
|
|
|
|
|
| 7 |
model = YOLO(model_path)
|
| 8 |
|
| 9 |
# Define the object detection function
|
| 10 |
def detect_objects(image):
|
| 11 |
results = model(image)
|
| 12 |
-
|
| 13 |
-
# Extract logs from YOLO results
|
| 14 |
-
logs = results[0].verbose()
|
| 15 |
-
|
| 16 |
-
return results[0].plot(), logs # Return image + logs
|
| 17 |
|
| 18 |
# Create a Gradio interface
|
| 19 |
-
app = gr.Interface(fn=detect_objects, inputs="image", outputs=
|
| 20 |
|
| 21 |
# Launch Gradio app
|
| 22 |
-
app.launch()
|
|
|
|
| 2 |
from ultralytics import YOLO
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Download the model from Google Drive if it's not present
|
| 6 |
model_path = "best.pt"
|
| 7 |
+
|
| 8 |
+
# Load the YOLOv8 model
|
| 9 |
model = YOLO(model_path)
|
| 10 |
|
| 11 |
# Define the object detection function
|
| 12 |
def detect_objects(image):
|
| 13 |
results = model(image)
|
| 14 |
+
return results[0].plot()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Create a Gradio interface
|
| 17 |
+
app = gr.Interface(fn=detect_objects, inputs="image", outputs="image")
|
| 18 |
|
| 19 |
# Launch Gradio app
|
| 20 |
+
app.launch()
|