Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# Face Detection-Based AI Automation of Lab Tests
|
2 |
-
# Gradio App - Cleaned for Hugging Face Compatibility
|
3 |
|
4 |
import gradio as gr
|
5 |
import cv2
|
@@ -86,37 +86,38 @@ def analyze_face(image):
|
|
86 |
|
87 |
flags = generate_flags_extended([hb, wbc, platelets, iron, ferritin, tibc, bilirubin, creatinine, tsh, cortisol, fbs, hba1c])
|
88 |
|
89 |
-
|
90 |
-
### 🩸 Hematology
|
91 |
-
- Hemoglobin (Hb): {hb} g/dL - {get_risk_color(hb, (13.5, 17.5))}
|
92 |
-
- WBC Count: {wbc} x10^3/uL - {get_risk_color(wbc, (4.0, 11.0))}
|
93 |
-
- Platelet Count: {platelets} x10^3/uL - {get_risk_color(platelets, (150, 450))}
|
94 |
-
|
95 |
-
### 🧬 Iron & Liver Panel
|
96 |
-
- Iron: {iron} µg/dL - {get_risk_color(iron, (60, 170))}
|
97 |
-
- Ferritin: {ferritin} ng/mL - {get_risk_color(ferritin, (30, 300))}
|
98 |
-
- TIBC: {tibc} µg/dL - {get_risk_color(tibc, (250, 400))}
|
99 |
-
- Bilirubin: {bilirubin} mg/dL - {get_risk_color(bilirubin, (0.3, 1.2))}
|
100 |
-
|
101 |
-
### 🧪 Kidney, Thyroid & Stress
|
102 |
-
- Creatinine: {creatinine} mg/dL - {get_risk_color(creatinine, (0.6, 1.2))}
|
103 |
-
- TSH: {tsh} µIU/mL - {get_risk_color(tsh, (0.4, 4.0))}
|
104 |
-
- Cortisol: {cortisol} µg/dL - {get_risk_color(cortisol, (5, 25))}
|
105 |
-
|
106 |
-
### 🧁 Metabolic Panel
|
107 |
-
- Fasting Blood Sugar: {fbs} mg/dL - {get_risk_color(fbs, (70, 110))}
|
108 |
-
- HbA1c: {hba1c}% - {get_risk_color(hba1c, (4.0, 5.7))}
|
109 |
-
|
110 |
-
### ❤️ Vital Signs
|
111 |
-
- SpO2: {spo2}% - {get_risk_color(spo2, (95, 100))}
|
112 |
-
- Heart Rate: {heart_rate} bpm - {get_risk_color(heart_rate, (60, 100))}
|
113 |
-
- Respiratory Rate: {rr} breaths/min - {get_risk_color(rr, (12, 20))}
|
114 |
-
- Blood Pressure: Low (simulated)
|
115 |
-
|
116 |
-
### ⚠️ Risk Flags
|
117 |
-
- {"
|
118 |
-
|
119 |
-
return
|
|
|
120 |
|
121 |
demo = gr.Interface(
|
122 |
fn=analyze_face,
|
|
|
1 |
# Face Detection-Based AI Automation of Lab Tests
|
2 |
+
# Gradio App - Cleaned and Fixed for Hugging Face Compatibility
|
3 |
|
4 |
import gradio as gr
|
5 |
import cv2
|
|
|
86 |
|
87 |
flags = generate_flags_extended([hb, wbc, platelets, iron, ferritin, tibc, bilirubin, creatinine, tsh, cortisol, fbs, hba1c])
|
88 |
|
89 |
+
report_lines = [
|
90 |
+
"### 🩸 Hematology",
|
91 |
+
f"- Hemoglobin (Hb): {hb} g/dL - {get_risk_color(hb, (13.5, 17.5))}",
|
92 |
+
f"- WBC Count: {wbc} x10^3/uL - {get_risk_color(wbc, (4.0, 11.0))}",
|
93 |
+
f"- Platelet Count: {platelets} x10^3/uL - {get_risk_color(platelets, (150, 450))}",
|
94 |
+
|
95 |
+
"### 🧬 Iron & Liver Panel",
|
96 |
+
f"- Iron: {iron} µg/dL - {get_risk_color(iron, (60, 170))}",
|
97 |
+
f"- Ferritin: {ferritin} ng/mL - {get_risk_color(ferritin, (30, 300))}",
|
98 |
+
f"- TIBC: {tibc} µg/dL - {get_risk_color(tibc, (250, 400))}",
|
99 |
+
f"- Bilirubin: {bilirubin} mg/dL - {get_risk_color(bilirubin, (0.3, 1.2))}",
|
100 |
+
|
101 |
+
"### 🧪 Kidney, Thyroid & Stress",
|
102 |
+
f"- Creatinine: {creatinine} mg/dL - {get_risk_color(creatinine, (0.6, 1.2))}",
|
103 |
+
f"- TSH: {tsh} µIU/mL - {get_risk_color(tsh, (0.4, 4.0))}",
|
104 |
+
f"- Cortisol: {cortisol} µg/dL - {get_risk_color(cortisol, (5, 25))}",
|
105 |
+
|
106 |
+
"### 🧁 Metabolic Panel",
|
107 |
+
f"- Fasting Blood Sugar: {fbs} mg/dL - {get_risk_color(fbs, (70, 110))}",
|
108 |
+
f"- HbA1c: {hba1c}% - {get_risk_color(hba1c, (4.0, 5.7))}",
|
109 |
+
|
110 |
+
"### ❤️ Vital Signs",
|
111 |
+
f"- SpO2: {spo2}% - {get_risk_color(spo2, (95, 100))}",
|
112 |
+
f"- Heart Rate: {heart_rate} bpm - {get_risk_color(heart_rate, (60, 100))}",
|
113 |
+
f"- Respiratory Rate: {rr} breaths/min - {get_risk_color(rr, (12, 20))}",
|
114 |
+
"- Blood Pressure: Low (simulated)",
|
115 |
+
|
116 |
+
"### ⚠️ Risk Flags",
|
117 |
+
] + [f"- {flag}" for flag in flags]
|
118 |
+
|
119 |
+
return "
|
120 |
+
".join(report_lines), frame_rgb
|
121 |
|
122 |
demo = gr.Interface(
|
123 |
fn=analyze_face,
|