Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import joblib
|
|
10 |
from datetime import datetime
|
11 |
import shutil
|
12 |
from reportlab.lib.pagesizes import letter
|
13 |
-
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
14 |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
15 |
from reportlab.lib import colors
|
16 |
|
@@ -203,18 +203,17 @@ def build_health_card(profile_image, test_results, summary, patient_name="", pat
|
|
203 |
</div>
|
204 |
|
205 |
<div style="display: flex; gap: 15px; justify-content: center; flex-wrap: wrap;">
|
206 |
-
<
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
</button>
|
212 |
</div>
|
213 |
</div>
|
214 |
<style>
|
215 |
@media print {{
|
216 |
/* Hide input sections during print */
|
217 |
-
.
|
218 |
/* Keep only the health card visible */
|
219 |
#health-card {{ display: block; }}
|
220 |
}}
|
@@ -301,7 +300,6 @@ def analyze_face(input_data):
|
|
301 |
build_table("❤️ Vitals",
|
302 |
[("SpO2", spo2, (95, 100)),
|
303 |
("Heart Rate", heart_rate, (60, 100)),
|
304 |
-
("Respiratory Rate", rr, (12, 20)),
|
305 |
("Temperature", test_values["Temperature"], (97, 99)),
|
306 |
("BP Systolic", test_values["BP Systolic"], (90, 120)),
|
307 |
("BP Diastolic", test_values["BP Diastolic"], (60, 80))])
|
@@ -336,26 +334,6 @@ def analyze_face(input_data):
|
|
336 |
return health_card_html, temp_pdf_path
|
337 |
|
338 |
|
339 |
-
# Modified route_inputs function
|
340 |
-
def route_inputs(mode, image, video, patient_name, patient_age, patient_gender, patient_id):
|
341 |
-
if mode == "Image" and image is None:
|
342 |
-
return "<div style='color:red;'>⚠️ Error: No image provided.</div>", None
|
343 |
-
if mode == "Video" and video is None:
|
344 |
-
return "<div style='color:red;'>⚠️ Error: No video provided.</div>", None
|
345 |
-
|
346 |
-
# Store patient details globally for use in analyze_face
|
347 |
-
global current_patient_details
|
348 |
-
current_patient_details = {
|
349 |
-
'name': patient_name,
|
350 |
-
'age': patient_age,
|
351 |
-
'gender': patient_gender,
|
352 |
-
'id': patient_id
|
353 |
-
}
|
354 |
-
|
355 |
-
health_card_html, pdf_file_path = analyze_face(image if mode == "Image" else video)
|
356 |
-
return health_card_html, pdf_file_path
|
357 |
-
|
358 |
-
|
359 |
# Create Gradio interface
|
360 |
with gr.Blocks() as demo:
|
361 |
gr.Markdown("""# 🧠 Face-Based Lab Test AI Report (Video Mode)""")
|
@@ -384,4 +362,4 @@ with gr.Blocks() as demo:
|
|
384 |
outputs=[result_html, result_pdf])
|
385 |
|
386 |
# Launch Gradio for Replit
|
387 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
10 |
from datetime import datetime
|
11 |
import shutil
|
12 |
from reportlab.lib.pagesizes import letter
|
13 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
14 |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
15 |
from reportlab.lib import colors
|
16 |
|
|
|
203 |
</div>
|
204 |
|
205 |
<div style="display: flex; gap: 15px; justify-content: center; flex-wrap: wrap;">
|
206 |
+
<a href="{pdf_filepath}" download="Health_Report.pdf">
|
207 |
+
<button style="padding: 12px 24px; background: linear-gradient(135deg, #4caf50, #45a049); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3); transition: all 0.3s;">
|
208 |
+
📥 Download Report
|
209 |
+
</button>
|
210 |
+
</a>
|
|
|
211 |
</div>
|
212 |
</div>
|
213 |
<style>
|
214 |
@media print {{
|
215 |
/* Hide input sections during print */
|
216 |
+
.input-container {{ display: none; }}
|
217 |
/* Keep only the health card visible */
|
218 |
#health-card {{ display: block; }}
|
219 |
}}
|
|
|
300 |
build_table("❤️ Vitals",
|
301 |
[("SpO2", spo2, (95, 100)),
|
302 |
("Heart Rate", heart_rate, (60, 100)),
|
|
|
303 |
("Temperature", test_values["Temperature"], (97, 99)),
|
304 |
("BP Systolic", test_values["BP Systolic"], (90, 120)),
|
305 |
("BP Diastolic", test_values["BP Diastolic"], (60, 80))])
|
|
|
334 |
return health_card_html, temp_pdf_path
|
335 |
|
336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
# Create Gradio interface
|
338 |
with gr.Blocks() as demo:
|
339 |
gr.Markdown("""# 🧠 Face-Based Lab Test AI Report (Video Mode)""")
|
|
|
362 |
outputs=[result_html, result_pdf])
|
363 |
|
364 |
# Launch Gradio for Replit
|
365 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|