ma4389 commited on
Commit
980e3d0
·
verified ·
1 Parent(s): 274d88d

Update app.py

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