Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,10 @@ from reportlab.pdfgen import canvas
|
|
12 |
# Load the trained model
|
13 |
model = tf.keras.models.load_model("my_keras_model.h5")
|
14 |
|
|
|
|
|
|
|
|
|
15 |
# Function to process X-rays and generate a PDF report
|
16 |
def generate_report(name, age, gender, xray1, xray2):
|
17 |
image_size = (224, 224)
|
@@ -56,20 +60,28 @@ def generate_report(name, age, gender, xray1, xray2):
|
|
56 |
return report_path # Return path for auto-download
|
57 |
|
58 |
# Define Gradio Interface
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
gr.
|
65 |
-
gr.
|
66 |
-
gr.
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
# Launch the Gradio app
|
74 |
if __name__ == "__main__":
|
75 |
-
|
|
|
12 |
# Load the trained model
|
13 |
model = tf.keras.models.load_model("my_keras_model.h5")
|
14 |
|
15 |
+
# Read HTML content from `re.html`
|
16 |
+
with open("templates/re.html", "r", encoding="utf-8") as file:
|
17 |
+
html_content = file.read()
|
18 |
+
|
19 |
# Function to process X-rays and generate a PDF report
|
20 |
def generate_report(name, age, gender, xray1, xray2):
|
21 |
image_size = (224, 224)
|
|
|
60 |
return report_path # Return path for auto-download
|
61 |
|
62 |
# Define Gradio Interface
|
63 |
+
with gr.Blocks() as app:
|
64 |
+
gr.HTML(html_content) # Display `re.html` content in Gradio
|
65 |
+
gr.Markdown("## Bone Fracture Detection System")
|
66 |
+
|
67 |
+
with gr.Row():
|
68 |
+
name = gr.Textbox(label="Patient Name")
|
69 |
+
age = gr.Number(label="Age")
|
70 |
+
gender = gr.Radio(["Male", "Female", "Other"], label="Gender")
|
71 |
+
|
72 |
+
with gr.Row():
|
73 |
+
xray1 = gr.Image(type="filepath", label="Upload X-ray Image 1")
|
74 |
+
xray2 = gr.Image(type="filepath", label="Upload X-ray Image 2")
|
75 |
+
|
76 |
+
submit_button = gr.Button("Generate Report")
|
77 |
+
output_file = gr.File(label="Download Report")
|
78 |
+
|
79 |
+
submit_button.click(
|
80 |
+
generate_report,
|
81 |
+
inputs=[name, age, gender, xray1, xray2],
|
82 |
+
outputs=[output_file],
|
83 |
+
)
|
84 |
|
85 |
# Launch the Gradio app
|
86 |
if __name__ == "__main__":
|
87 |
+
app.launch()
|