ftx7go commited on
Commit
35649b4
·
verified ·
1 Parent(s): 752f355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -90,6 +90,18 @@ def generate_report(name, age, gender, weight, height, allergies, cause, xray):
90
 
91
  return report_path # Return file path
92
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  # Gradio Interface
94
  with gr.Blocks() as app:
95
  gr.Markdown("## Bone Fracture Detection System")
@@ -110,9 +122,8 @@ with gr.Blocks() as app:
110
  with gr.Row():
111
  email = gr.Textbox(label="Patient Email", type="email")
112
 
113
- # Preloaded X-ray image
114
- default_xray_path = "default_xray.png" # Ensure this file exists in your project
115
- xray = gr.Image(type="filepath", label="Upload X-ray Image", value=default_xray_path)
116
 
117
  with gr.Row():
118
  submit_button = gr.Button("Generate Report")
 
90
 
91
  return report_path # Return file path
92
 
93
+ # Path to samples folder
94
+ samples_folder = "samples"
95
+
96
+ # Ensure samples directory exists
97
+ if os.path.exists(samples_folder) and os.path.isdir(samples_folder):
98
+ sample_images = [os.path.join(samples_folder, f) for f in os.listdir(samples_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]
99
+ else:
100
+ sample_images = []
101
+
102
+ # Preloaded image (if available)
103
+ preloaded_image = sample_images[0] if sample_images else None
104
+
105
  # Gradio Interface
106
  with gr.Blocks() as app:
107
  gr.Markdown("## Bone Fracture Detection System")
 
122
  with gr.Row():
123
  email = gr.Textbox(label="Patient Email", type="email")
124
 
125
+ # X-ray image upload with preloaded image from "samples"
126
+ xray = gr.Image(type="filepath", label="Upload X-ray Image", value=preloaded_image)
 
127
 
128
  with gr.Row():
129
  submit_button = gr.Button("Generate Report")