Spaces:
Runtime error
Runtime error
Commit
·
05a6472
1
Parent(s):
c2d444a
UPDATED app.py and requirements
Browse files- app.py +10 -20
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,26 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
3 |
-
from PIL import Image
|
4 |
|
5 |
-
# Load
|
6 |
-
model = YOLO("best_int8_openvino_model", task="detect")
|
7 |
|
8 |
-
#
|
9 |
-
def
|
10 |
-
|
11 |
-
results
|
12 |
-
annotated_image = results[0].plot() # Get annotated image as a NumPy array
|
13 |
-
return Image.fromarray(annotated_image[..., ::-1]) # Convert BGR to RGB for PIL
|
14 |
|
15 |
# Create the Gradio interface
|
16 |
-
demo = gr.Interface(
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
title="Object Detection App",
|
21 |
-
description="Upload an image to detect objects using a YOLO model."
|
22 |
-
)
|
23 |
-
|
24 |
-
# Launch the app
|
25 |
-
if __name__ == "__main__":
|
26 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
|
|
3 |
|
4 |
+
# Load your YOLO model (ensure correct path to your model)
|
5 |
+
model = YOLO("best_int8_openvino_model.pt", task="detect")
|
6 |
|
7 |
+
# Define the prediction function
|
8 |
+
def predict_image(image):
|
9 |
+
results = model(image)
|
10 |
+
return results.plot() # Returns the image with detected objects
|
|
|
|
|
11 |
|
12 |
# Create the Gradio interface
|
13 |
+
demo = gr.Interface(fn=predict_image,
|
14 |
+
inputs=gr.Image(type="pil"), # Updated syntax
|
15 |
+
outputs=gr.Image()) # Outputs an image
|
16 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
ultralytics
|
2 |
-
|
|
|
1 |
ultralytics
|
2 |
+
huggingface_hub
|