-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterface.py
29 lines (25 loc) · 1.32 KB
/
Interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
class GradioApp:
def __init__(self, classifier, fracture_detector):
self.classifier = classifier
self.fracture_detector = fracture_detector
def classify_image(self, image_path):
class_name = self.classifier.predict_image(image_path)
image_with_boxes, num_boxes = self.fracture_detector.predict_boxes(image_path)
fracture_message = f"{num_boxes} fracture(s) detected" if num_boxes > 0 else "No fractures detected"
return class_name, image_with_boxes, fracture_message
def launch(self):
iface = gr.Interface(
fn=self.classify_image,
inputs=gr.Image(type="filepath", label="Upload an Image"),
outputs=[
gr.Textbox(label="Body Part", lines=2, placeholder="Predicted body part class will appear here"),
gr.Image(label="Fracture Detection"),
gr.Textbox(label="Number of Fracture Detection", lines=2,
placeholder="Fracture detection result will appear here")
],
title="X-ray Body Part Classifier & Fracture Detection",
description="Upload an X-ray image (jpg or DICOM) to classify the body part and detect fractures.",
theme=gr.themes.Monochrome(primary_hue='red')
)
iface.launch(share=True)