ftx7go commited on
Commit
11dec21
·
verified ·
1 Parent(s): 75ae599

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -14
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
- interface = gr.Interface(
60
- fn=generate_report,
61
- inputs=[
62
- gr.Textbox(label="Patient Name"),
63
- gr.Number(label="Age"),
64
- gr.Radio(["Male", "Female", "Other"], label="Gender"),
65
- gr.Image(type="filepath", label="Upload X-ray Image 1"),
66
- gr.Image(type="filepath", label="Upload X-ray Image 2"),
67
- ],
68
- outputs=gr.File(label="Download Report"),
69
- title="Bone Fracture Detection & Medical Report",
70
- description="Enter patient details, upload two X-ray images, and generate a detailed medical report with treatment suggestions and cost estimates."
71
- )
 
 
 
 
 
 
 
 
72
 
73
  # Launch the Gradio app
74
  if __name__ == "__main__":
75
- interface.launch()
 
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()