Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,23 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
inputs=gr.Image(type="pil"),
|
| 25 |
-
outputs=gr.Image(type="pil"),
|
| 26 |
-
title="BCCD Object Detection",
|
| 27 |
-
description="Upload an image to detect RBC, WBC, and Platelets.",
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
# Launch the app
|
| 31 |
-
iface.launch(share=True)
|
| 32 |
-
"""
|
| 33 |
-
|
| 34 |
-
# Save the code to app.py
|
| 35 |
-
with open('/content/BCCD-object/app/app.py', 'w') as f:
|
| 36 |
-
f.write(app_code)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
# Load the trained model
|
| 6 |
+
model = YOLO('bccd_yolov8.pt') # Make sure the model file is in the same folder as app.py
|
| 7 |
+
|
| 8 |
+
# Prediction function
|
| 9 |
+
def predict(image):
|
| 10 |
+
results = model(image)
|
| 11 |
+
annotated_image = results[0].plot() # Draw bounding boxes
|
| 12 |
+
return Image.fromarray(annotated_image)
|
| 13 |
+
|
| 14 |
+
# Gradio Interface
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=predict,
|
| 17 |
+
inputs=gr.Image(type="pil"),
|
| 18 |
+
outputs=gr.Image(type="pil"),
|
| 19 |
+
title="BCCD Object Detection",
|
| 20 |
+
description="Upload an image to detect RBC, WBC, and Platelets.",
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|