Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,17 +24,6 @@ FASTAPI_URL = "http://localhost:7860/analyze" # Adjust if your FastAPI server i
|
|
24 |
SENDER_EMAIL = "[email protected]"
|
25 |
SENDER_PASSWORD = "1w3r5y7i9pW$"
|
26 |
|
27 |
-
# Read HTML content from `re.html`
|
28 |
-
with open("templates/re.html", "r", encoding="utf-8") as file:
|
29 |
-
html_content = file.read()
|
30 |
-
|
31 |
-
# List of sample images
|
32 |
-
sample_images = [f"samples/{img}" for img in os.listdir("samples") if img.endswith((".png", ".jpg", ".jpeg"))]
|
33 |
-
|
34 |
-
def image_to_base64(image_path):
|
35 |
-
with open(image_path, "rb") as image_file:
|
36 |
-
return base64.b64encode(image_file.read()).decode('utf-8')
|
37 |
-
|
38 |
# Function to process X-ray and generate a PDF report
|
39 |
def generate_report(name, age, gender, weight, height, allergies, cause, xray, email):
|
40 |
image_size = (224, 224)
|
@@ -175,13 +164,9 @@ def generate_report(name, age, gender, weight, height, allergies, cause, xray, e
|
|
175 |
except Exception as e:
|
176 |
return f"Error sending email: {e}"
|
177 |
|
178 |
-
# Function to select a sample image
|
179 |
-
def use_sample_image(sample_image_path):
|
180 |
-
return sample_image_path # Returns selected sample image filepath
|
181 |
-
|
182 |
# Define Gradio Interface
|
183 |
with gr.Blocks() as app:
|
184 |
-
|
185 |
gr.Markdown("## Bone Fracture Detection System")
|
186 |
|
187 |
with gr.Row():
|
@@ -200,15 +185,12 @@ with gr.Blocks() as app:
|
|
200 |
with gr.Row():
|
201 |
xray = gr.Image(type="filepath", label="Upload X-ray Image")
|
202 |
|
203 |
-
|
204 |
-
sample_selector = gr.Dropdown(choices=sample_images, label="Use Sample Image")
|
205 |
-
select_button = gr.Button("Load Sample Image")
|
206 |
-
|
207 |
email = gr.Textbox(label="Patient Email Address")
|
208 |
submit_button = gr.Button("Generate Report and Send Email")
|
209 |
output_file = gr.File(label="Download Report")
|
210 |
|
211 |
-
|
212 |
|
213 |
submit_button.click(
|
214 |
generate_report,
|
|
|
24 |
SENDER_EMAIL = "[email protected]"
|
25 |
SENDER_PASSWORD = "1w3r5y7i9pW$"
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Function to process X-ray and generate a PDF report
|
28 |
def generate_report(name, age, gender, weight, height, allergies, cause, xray, email):
|
29 |
image_size = (224, 224)
|
|
|
164 |
except Exception as e:
|
165 |
return f"Error sending email: {e}"
|
166 |
|
|
|
|
|
|
|
|
|
167 |
# Define Gradio Interface
|
168 |
with gr.Blocks() as app:
|
169 |
+
# Remove the HTML content loading
|
170 |
gr.Markdown("## Bone Fracture Detection System")
|
171 |
|
172 |
with gr.Row():
|
|
|
185 |
with gr.Row():
|
186 |
xray = gr.Image(type="filepath", label="Upload X-ray Image")
|
187 |
|
188 |
+
# Remove the sample image selector
|
|
|
|
|
|
|
189 |
email = gr.Textbox(label="Patient Email Address")
|
190 |
submit_button = gr.Button("Generate Report and Send Email")
|
191 |
output_file = gr.File(label="Download Report")
|
192 |
|
193 |
+
# Remove the sample image loading functionality
|
194 |
|
195 |
submit_button.click(
|
196 |
generate_report,
|