Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,27 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from ultralytics import YOLO
|
| 3 |
-
import cv2
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from ultralytics import YOLO
|
| 3 |
+
import cv2
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
torch.serialization.add_safe_globals([DetectionModel])
|
| 7 |
+
|
| 8 |
+
# Load your YOLOv8 model
|
| 9 |
+
model = YOLO("best.pt")
|
| 10 |
+
|
| 11 |
+
# Prediction function
|
| 12 |
+
def detect_fracture(image):
|
| 13 |
+
results = model.predict(source=image, save=False) # Run inference
|
| 14 |
+
annotated_img = results[0].plot() # Draw detections
|
| 15 |
+
return annotated_img
|
| 16 |
+
|
| 17 |
+
# Gradio interface
|
| 18 |
+
demo = gr.Interface(
|
| 19 |
+
fn=detect_fracture,
|
| 20 |
+
inputs=gr.Image(type="numpy", label="Upload Bone X-ray"),
|
| 21 |
+
outputs=gr.Image(type="numpy", label="Detection Result"),
|
| 22 |
+
title="Human Bone Fracture Detection",
|
| 23 |
+
description="Upload an X-ray image to detect types of human bone fractures using YOLOv8."
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
demo.launch(debug=True)
|