SuriRaja commited on
Commit
c6b8538
·
verified ·
1 Parent(s): 716658c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -114,7 +114,29 @@ def app():
114
  summary_text = "<li>Your hemoglobin is a bit low...</li><li>Consider iron tests.</li>" # Placeholder
115
  pdf_path = generate_pdf_report(image, results_dict, summary_text)
116
 
117
- return "Preview complete. You can download your report.", frame_rgb, pdf_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  with gr.Blocks() as demo:
120
  gr.Markdown("""# 🧠 Face-Based Lab Test AI Report""")
@@ -124,7 +146,7 @@ def app():
124
  button = gr.Button("🔍 Run Analysis")
125
  pdf_output = gr.File(label="📄 Download Report")
126
  with gr.Column():
127
- note = gr.Textbox(label="Status")
128
  preview = gr.Image(label="Scan Preview")
129
 
130
  button.click(fn=process, inputs=image, outputs=[note, preview, pdf_output])
 
114
  summary_text = "<li>Your hemoglobin is a bit low...</li><li>Consider iron tests.</li>" # Placeholder
115
  pdf_path = generate_pdf_report(image, results_dict, summary_text)
116
 
117
+ table_html = "<table style='width:100%;border-collapse:collapse;margin-top:10px;'>"
118
+ table_html += "<tr><th style='border:1px solid #ccc;padding:6px;'>Test</th><th style='border:1px solid #ccc;padding:6px;'>Result</th><th style='border:1px solid #ccc;padding:6px;'>Status</th></tr>"
119
+ for k, v in results_dict.items():
120
+ if k in ["Hemoglobin", "WBC Count", "Platelets"]:
121
+ status, icon, bg = get_risk_color(v, (13.5, 17.5) if k == "Hemoglobin" else (4.0, 11.0) if k == "WBC Count" else (150, 450))
122
+ table_html += f"<tr style='background:{bg}'><td style='border:1px solid #ccc;padding:6px;'>{k}</td><td style='border:1px solid #ccc;padding:6px;'>{v}</td><td style='border:1px solid #ccc;padding:6px;'>{icon} {status}</td></tr>"
123
+ else:
124
+ table_html += f"<tr><td style='border:1px solid #ccc;padding:6px;'>{k}</td><td style='border:1px solid #ccc;padding:6px;'>{v}</td><td style='border:1px solid #ccc;padding:6px;'>-</td></tr>"
125
+ table_html += "</table>"
126
+
127
+ summary_block = """
128
+ <div style='margin-top:20px;padding:12px;border:1px dashed #999;background:#f9f9f9;'>
129
+ <h4>📝 Summary in Your Language</h4>
130
+ <details><summary><b>Hindi</b></summary>
131
+ <ul><li>आपका हीमोग्लोबिन थोड़ा कम है — यह हल्के एनीमिया का संकेत हो सकता है। कृपया CBC और आयरन टेस्ट करवाएं।</li></ul>
132
+ </details>
133
+ <details><summary><b>Telugu</b></summary>
134
+ <ul><li>మీ హిమోగ్లోబిన్ తక్కువగా ఉంది — ఇది అనీమియా సూచించవచ్చు. CBC, Iron పరీక్షలు చేయించండి.</li></ul>
135
+ </details>
136
+ </div>"""
137
+
138
+ full_html = table_html + summary_block
139
+ return full_html, frame_rgb, pdf_path
140
 
141
  with gr.Blocks() as demo:
142
  gr.Markdown("""# 🧠 Face-Based Lab Test AI Report""")
 
146
  button = gr.Button("🔍 Run Analysis")
147
  pdf_output = gr.File(label="📄 Download Report")
148
  with gr.Column():
149
+ note = gr.HTML(label="AI-Predicted Test Results Table")
150
  preview = gr.Image(label="Scan Preview")
151
 
152
  button.click(fn=process, inputs=image, outputs=[note, preview, pdf_output])