Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import google.generativeai as genai
|
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
from typing import Dict, Any, Union, List
|
| 8 |
-
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
import gradio as gr
|
| 11 |
|
|
@@ -595,78 +595,31 @@ make it detailed
|
|
| 595 |
|
| 596 |
raise HTTPException(status_code=500, detail=f"Prediction error: {str(e)}")
|
| 597 |
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
urea, creatinine, uric_acid, calcium, phosphorus, sodium, potassium, chloride,
|
| 601 |
-
amylase, lipase, bicarbonate, egfr, serum_osmolality, ionized_calcium,
|
| 602 |
-
wbc, hemoglobin, mcv, rdw, lymphocytes,
|
| 603 |
-
fasting_blood_sugar, hb1ac, insulin, c_peptide, homa_ir,
|
| 604 |
-
total_cholesterol, ldl, hdl, cholesterol_hdl_ratio, triglycerides,
|
| 605 |
-
apo_a1, apo_b, apo_ratio,
|
| 606 |
-
albumin, total_protein, alt, ast, alp, ggt, ld, globulin, albumin_globulin_ratio,
|
| 607 |
-
magnesium, total_bilirubin, direct_bilirubin, indirect_bilirubin, ammonia,
|
| 608 |
-
hs_crp, ck, ck_mb, homocysteine, zinc, copper, selenium,
|
| 609 |
-
iron, tibc, transferrin,
|
| 610 |
-
vitamin_d, vitamin_b12,
|
| 611 |
-
total_testosterone, free_testosterone, estrogen, progesterone, dhea_s, shbg,
|
| 612 |
-
lh, fsh, tsh, free_t3, free_t4, total_t3, total_t4, reverse_t3, tpo_ab, tg_ab,
|
| 613 |
-
cortisol, acth, igf1, leptin, adiponectin,
|
| 614 |
-
ca125, ca15_3, ca19_9, psa, cea, calcitonin, afp,
|
| 615 |
-
tnf, ana, ige, igg, anti_ccp, dsdna, ssa_ssb, rnp, sm_antibodies, anca, anti_ena,
|
| 616 |
-
il6, allergy_panel):
|
| 617 |
-
|
| 618 |
-
req = BiomarkerRequest(
|
| 619 |
-
age=int(age), gender=gender, height=height, weight=weight,
|
| 620 |
-
urea=urea, creatinine=creatinine, uric_acid=uric_acid, calcium=calcium, phosphorus=phosphorus,
|
| 621 |
-
sodium=sodium, potassium=potassium, chloride=chloride, amylase=amylase, lipase=lipase,
|
| 622 |
-
bicarbonate=bicarbonate, egfr=egfr, serum_osmolality=serum_osmolality, ionized_calcium=ionized_calcium,
|
| 623 |
-
wbc=wbc, hemoglobin=hemoglobin, mcv=mcv, rdw=rdw, lymphocytes=lymphocytes,
|
| 624 |
-
fasting_blood_sugar=fasting_blood_sugar, hb1ac=hb1ac, insulin=insulin, c_peptide=c_peptide, homa_ir=homa_ir,
|
| 625 |
-
total_cholesterol=total_cholesterol, ldl=ldl, hdl=hdl, cholesterol_hdl_ratio=cholesterol_hdl_ratio,
|
| 626 |
-
triglycerides=triglycerides, apo_a1=apo_a1, apo_b=apo_b, apo_ratio=apo_ratio,
|
| 627 |
-
albumin=albumin, total_protein=total_protein, alt=alt, ast=ast, alp=alp, ggt=ggt, ld=ld,
|
| 628 |
-
globulin=globulin, albumin_globulin_ratio=albumin_globulin_ratio,
|
| 629 |
-
magnesium=magnesium, total_bilirubin=total_bilirubin, direct_bilirubin=direct_bilirubin,
|
| 630 |
-
indirect_bilirubin=indirect_bilirubin, ammonia=ammonia, hs_crp=hs_crp,
|
| 631 |
-
ck=ck, ck_mb=ck_mb, homocysteine=homocysteine, zinc=zinc, copper=copper, selenium=selenium,
|
| 632 |
-
iron=iron, tibc=tibc, transferrin=transferrin,
|
| 633 |
-
vitamin_d=vitamin_d, vitamin_b12=vitamin_b12,
|
| 634 |
-
total_testosterone=total_testosterone, free_testosterone=free_testosterone,
|
| 635 |
-
estrogen=estrogen, progesterone=progesterone, dhea_s=dhea_s, shbg=shbg,
|
| 636 |
-
lh=lh, fsh=fsh, tsh=tsh, free_t3=free_t3, free_t4=free_t4,
|
| 637 |
-
total_t3=total_t3, total_t4=total_t4, reverse_t3=reverse_t3,
|
| 638 |
-
tpo_ab=tpo_ab, tg_ab=tg_ab,
|
| 639 |
-
cortisol=cortisol, acth=acth, igf1=igf1, leptin=leptin, adiponectin=adiponectin,
|
| 640 |
-
ca125=ca125, ca15_3=ca15_3, ca19_9=ca19_9, psa=psa, cea=cea, calcitonin=calcitonin, afp=afp,
|
| 641 |
-
tnf=tnf, ana=ana, ige=ige, igg=igg, anti_ccp=anti_ccp, dsdna=dsdna,
|
| 642 |
-
ssa_ssb=ssa_ssb, rnp=rnp, sm_antibodies=sm_antibodies, anca=anca, anti_ena=anti_ena,
|
| 643 |
-
il6=il6, allergy_panel=allergy_panel
|
| 644 |
-
)
|
| 645 |
-
return generate_report(req)
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
# ---------------- Gradio UI (Vertical Layout) ----------------
|
| 649 |
with gr.Blocks(theme="soft", title="LLM Biomarker Analyzer") as iface:
|
| 650 |
gr.Markdown("# 🧬 LLM Biomarker Analyzer")
|
| 651 |
gr.Markdown("Enter your full biomarker and demographic data below to generate a **Gemini-powered comprehensive medical insight report**:")
|
| 652 |
|
| 653 |
with gr.Column():
|
| 654 |
-
|
|
|
|
| 655 |
age = gr.Number(label="Age (years)", value=52)
|
| 656 |
gender = gr.Radio(["male", "female"], label="Gender", value="female")
|
| 657 |
-
with gr.Row():
|
| 658 |
height = gr.Number(label="Height (cm)", value=165)
|
| 659 |
weight = gr.Number(label="Weight (kg)", value=70)
|
| 660 |
|
| 661 |
-
gr.
|
| 662 |
-
with gr.Row():
|
| 663 |
urea = gr.Number(label="Urea (mg/dL)", value=30)
|
| 664 |
creatinine = gr.Number(label="Creatinine (mg/dL)", value=1.0)
|
| 665 |
uric_acid = gr.Number(label="Uric Acid (mg/dL)", value=5.0)
|
| 666 |
egfr = gr.Number(label="eGFR (mL/min)", value=100)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
|
| 668 |
-
gr.
|
| 669 |
-
with gr.Row():
|
| 670 |
sodium = gr.Number(label="Sodium (mEq/L)", value=140)
|
| 671 |
potassium = gr.Number(label="Potassium (mEq/L)", value=4.2)
|
| 672 |
chloride = gr.Number(label="Chloride (mEq/L)", value=102)
|
|
@@ -675,89 +628,131 @@ with gr.Blocks(theme="soft", title="LLM Biomarker Analyzer") as iface:
|
|
| 675 |
magnesium = gr.Number(label="Magnesium (mg/dL)", value=2.0)
|
| 676 |
ionized_calcium = gr.Number(label="Ionized Calcium (mmol/L)", value=1.25)
|
| 677 |
|
| 678 |
-
gr.
|
| 679 |
-
with gr.Row():
|
| 680 |
albumin = gr.Number(label="Albumin (g/dL)", value=4.2)
|
| 681 |
total_protein = gr.Number(label="Total Protein (g/dL)", value=7.0)
|
| 682 |
globulin = gr.Number(label="Globulin (g/dL)", value=3.0)
|
| 683 |
albumin_globulin_ratio = gr.Number(label="A/G Ratio", value=1.4)
|
| 684 |
-
with gr.Row():
|
| 685 |
alt = gr.Number(label="ALT (U/L)", value=25)
|
| 686 |
ast = gr.Number(label="AST (U/L)", value=24)
|
| 687 |
alp = gr.Number(label="ALP (U/L)", value=120)
|
| 688 |
ggt = gr.Number(label="GGT (U/L)", value=20)
|
| 689 |
ld = gr.Number(label="LD (U/L)", value=180)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 690 |
|
| 691 |
-
gr.
|
| 692 |
-
with gr.Row():
|
| 693 |
wbc = gr.Number(label="WBC (×10³/μL)", value=6.0)
|
| 694 |
hemoglobin = gr.Number(label="Hemoglobin (g/dL)", value=14.0)
|
| 695 |
mcv = gr.Number(label="MCV (fL)", value=90)
|
| 696 |
rdw = gr.Number(label="RDW (%)", value=13.5)
|
| 697 |
lymphocytes = gr.Number(label="Lymphocytes (%)", value=30)
|
| 698 |
|
| 699 |
-
gr.
|
| 700 |
-
with gr.Row():
|
| 701 |
fasting_blood_sugar = gr.Number(label="Fasting Blood Sugar (mg/dL)", value=85)
|
| 702 |
hb1ac = gr.Number(label="HbA1c (%)", value=5.4)
|
| 703 |
insulin = gr.Number(label="Insulin (μU/mL)", value=10)
|
| 704 |
c_peptide = gr.Number(label="C-Peptide (ng/mL)", value=1.2)
|
| 705 |
homa_ir = gr.Number(label="HOMA-IR", value=1.2)
|
| 706 |
|
| 707 |
-
gr.
|
| 708 |
-
with gr.Row():
|
| 709 |
total_cholesterol = gr.Number(label="Total Cholesterol (mg/dL)", value=180)
|
| 710 |
ldl = gr.Number(label="LDL (mg/dL)", value=90)
|
| 711 |
hdl = gr.Number(label="HDL (mg/dL)", value=50)
|
| 712 |
triglycerides = gr.Number(label="Triglycerides (mg/dL)", value=120)
|
| 713 |
cholesterol_hdl_ratio = gr.Number(label="Chol/HDL Ratio", value=3.0)
|
|
|
|
|
|
|
|
|
|
| 714 |
|
| 715 |
-
gr.
|
| 716 |
-
with gr.Row():
|
| 717 |
hs_crp = gr.Number(label="hs-CRP (mg/L)", value=1.0)
|
| 718 |
homocysteine = gr.Number(label="Homocysteine (μmol/L)", value=10)
|
| 719 |
-
ferritin = gr.Number(label="Ferritin (ng/mL)", value=100)
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
tsh = gr.Number(label="TSH (μIU/mL)", value=2.0)
|
| 724 |
-
free_t4 = gr.Number(label="Free T4 (ng/dL)", value=1.2)
|
| 725 |
free_t3 = gr.Number(label="Free T3 (pg/mL)", value=3.2)
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 731 |
|
| 732 |
submit_btn = gr.Button("🧠 Generate Comprehensive Medical Report", variant="primary", size="lg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
|
| 734 |
-
output_md = gr.Markdown(label="AI-Generated Medical Report")
|
| 735 |
-
|
| 736 |
-
submit_btn.click(
|
| 737 |
-
fn=gradio_interface,
|
| 738 |
-
inputs=[
|
| 739 |
-
age, gender, height, weight,
|
| 740 |
-
urea, creatinine, uric_acid, calcium, phosphorus, sodium, potassium, chloride,
|
| 741 |
-
amylase, lipase, bicarbonate, egfr, serum_osmolality, ionized_calcium,
|
| 742 |
-
wbc, hemoglobin, mcv, rdw, lymphocytes,
|
| 743 |
-
fasting_blood_sugar, hb1ac, insulin, c_peptide, homa_ir,
|
| 744 |
-
total_cholesterol, ldl, hdl, cholesterol_hdl_ratio, triglycerides,
|
| 745 |
-
apo_a1, apo_b, apo_ratio,
|
| 746 |
-
albumin, total_protein, alt, ast, alp, ggt, ld, globulin, albumin_globulin_ratio,
|
| 747 |
-
magnesium, total_bilirubin, direct_bilirubin, indirect_bilirubin, ammonia,
|
| 748 |
-
hs_crp, ck, ck_mb, homocysteine, zinc, copper, selenium,
|
| 749 |
-
iron, tibc, transferrin,
|
| 750 |
-
vitamin_d, vitamin_b12,
|
| 751 |
-
total_testosterone, free_testosterone, estrogen, progesterone, dhea_s, shbg,
|
| 752 |
-
lh, fsh, tsh, free_t3, free_t4, total_t3, total_t4, reverse_t3, tpo_ab, tg_ab,
|
| 753 |
-
cortisol, acth, igf1, leptin, adiponectin,
|
| 754 |
-
ca125, ca15_3, ca19_9, psa, cea, calcitonin, afp,
|
| 755 |
-
tnf, ana, ige, igg, anti_ccp, dsdna, ssa_ssb, rnp, sm_antibodies, anca, anti_ena,
|
| 756 |
-
il6, allergy_panel
|
| 757 |
-
],
|
| 758 |
-
outputs=output_md
|
| 759 |
-
)
|
| 760 |
-
|
| 761 |
-
# ---------------- Launch ----------------
|
| 762 |
if __name__ == "__main__":
|
| 763 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
from typing import Dict, Any, Union, List
|
| 8 |
+
from your_fastapi_module import gradio_interface # your predict function
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
import gradio as gr
|
| 11 |
|
|
|
|
| 595 |
|
| 596 |
raise HTTPException(status_code=500, detail=f"Prediction error: {str(e)}")
|
| 597 |
|
| 598 |
+
|
| 599 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
with gr.Blocks(theme="soft", title="LLM Biomarker Analyzer") as iface:
|
| 601 |
gr.Markdown("# 🧬 LLM Biomarker Analyzer")
|
| 602 |
gr.Markdown("Enter your full biomarker and demographic data below to generate a **Gemini-powered comprehensive medical insight report**:")
|
| 603 |
|
| 604 |
with gr.Column():
|
| 605 |
+
|
| 606 |
+
with gr.Accordion("👤 Demographics", open=True):
|
| 607 |
age = gr.Number(label="Age (years)", value=52)
|
| 608 |
gender = gr.Radio(["male", "female"], label="Gender", value="female")
|
|
|
|
| 609 |
height = gr.Number(label="Height (cm)", value=165)
|
| 610 |
weight = gr.Number(label="Weight (kg)", value=70)
|
| 611 |
|
| 612 |
+
with gr.Accordion("🩸 Basic Chemistry & Kidney Function", open=False):
|
|
|
|
| 613 |
urea = gr.Number(label="Urea (mg/dL)", value=30)
|
| 614 |
creatinine = gr.Number(label="Creatinine (mg/dL)", value=1.0)
|
| 615 |
uric_acid = gr.Number(label="Uric Acid (mg/dL)", value=5.0)
|
| 616 |
egfr = gr.Number(label="eGFR (mL/min)", value=100)
|
| 617 |
+
amylase = gr.Number(label="Amylase (U/L)", value=70)
|
| 618 |
+
lipase = gr.Number(label="Lipase (U/L)", value=50)
|
| 619 |
+
bicarbonate = gr.Number(label="Bicarbonate (mmol/L)", value=24)
|
| 620 |
+
serum_osmolality = gr.Number(label="Serum Osmolality (mOsm/kg)", value=290)
|
| 621 |
|
| 622 |
+
with gr.Accordion("⚡ Electrolytes & Minerals", open=False):
|
|
|
|
| 623 |
sodium = gr.Number(label="Sodium (mEq/L)", value=140)
|
| 624 |
potassium = gr.Number(label="Potassium (mEq/L)", value=4.2)
|
| 625 |
chloride = gr.Number(label="Chloride (mEq/L)", value=102)
|
|
|
|
| 628 |
magnesium = gr.Number(label="Magnesium (mg/dL)", value=2.0)
|
| 629 |
ionized_calcium = gr.Number(label="Ionized Calcium (mmol/L)", value=1.25)
|
| 630 |
|
| 631 |
+
with gr.Accordion("🥼 Liver & Proteins", open=False):
|
|
|
|
| 632 |
albumin = gr.Number(label="Albumin (g/dL)", value=4.2)
|
| 633 |
total_protein = gr.Number(label="Total Protein (g/dL)", value=7.0)
|
| 634 |
globulin = gr.Number(label="Globulin (g/dL)", value=3.0)
|
| 635 |
albumin_globulin_ratio = gr.Number(label="A/G Ratio", value=1.4)
|
|
|
|
| 636 |
alt = gr.Number(label="ALT (U/L)", value=25)
|
| 637 |
ast = gr.Number(label="AST (U/L)", value=24)
|
| 638 |
alp = gr.Number(label="ALP (U/L)", value=120)
|
| 639 |
ggt = gr.Number(label="GGT (U/L)", value=20)
|
| 640 |
ld = gr.Number(label="LD (U/L)", value=180)
|
| 641 |
+
total_bilirubin = gr.Number(label="Total Bilirubin (mg/dL)", value=1.0)
|
| 642 |
+
direct_bilirubin = gr.Number(label="Direct Bilirubin (mg/dL)", value=0.3)
|
| 643 |
+
indirect_bilirubin = gr.Number(label="Indirect Bilirubin (mg/dL)", value=0.7)
|
| 644 |
+
ammonia = gr.Number(label="Ammonia (µmol/L)", value=35)
|
| 645 |
|
| 646 |
+
with gr.Accordion("🩺 Hematology", open=False):
|
|
|
|
| 647 |
wbc = gr.Number(label="WBC (×10³/μL)", value=6.0)
|
| 648 |
hemoglobin = gr.Number(label="Hemoglobin (g/dL)", value=14.0)
|
| 649 |
mcv = gr.Number(label="MCV (fL)", value=90)
|
| 650 |
rdw = gr.Number(label="RDW (%)", value=13.5)
|
| 651 |
lymphocytes = gr.Number(label="Lymphocytes (%)", value=30)
|
| 652 |
|
| 653 |
+
with gr.Accordion("🍬 Diabetes & Insulin Resistance", open=False):
|
|
|
|
| 654 |
fasting_blood_sugar = gr.Number(label="Fasting Blood Sugar (mg/dL)", value=85)
|
| 655 |
hb1ac = gr.Number(label="HbA1c (%)", value=5.4)
|
| 656 |
insulin = gr.Number(label="Insulin (μU/mL)", value=10)
|
| 657 |
c_peptide = gr.Number(label="C-Peptide (ng/mL)", value=1.2)
|
| 658 |
homa_ir = gr.Number(label="HOMA-IR", value=1.2)
|
| 659 |
|
| 660 |
+
with gr.Accordion("❤️ Lipids", open=False):
|
|
|
|
| 661 |
total_cholesterol = gr.Number(label="Total Cholesterol (mg/dL)", value=180)
|
| 662 |
ldl = gr.Number(label="LDL (mg/dL)", value=90)
|
| 663 |
hdl = gr.Number(label="HDL (mg/dL)", value=50)
|
| 664 |
triglycerides = gr.Number(label="Triglycerides (mg/dL)", value=120)
|
| 665 |
cholesterol_hdl_ratio = gr.Number(label="Chol/HDL Ratio", value=3.0)
|
| 666 |
+
apo_a1 = gr.Number(label="Apo A1 (mg/dL)", value=140)
|
| 667 |
+
apo_b = gr.Number(label="Apo B (mg/dL)", value=90)
|
| 668 |
+
apo_ratio = gr.Number(label="Apo A1/B Ratio", value=1.55)
|
| 669 |
|
| 670 |
+
with gr.Accordion("🔥 Inflammation & Others", open=False):
|
|
|
|
| 671 |
hs_crp = gr.Number(label="hs-CRP (mg/L)", value=1.0)
|
| 672 |
homocysteine = gr.Number(label="Homocysteine (μmol/L)", value=10)
|
| 673 |
+
ferritin = gr.Number(label="Ferritin (ng/mL)", value=100)
|
| 674 |
+
ck = gr.Number(label="CK (U/L)", value=150)
|
| 675 |
+
ck_mb = gr.Number(label="CK-MB (ng/mL)", value=5)
|
| 676 |
+
zinc = gr.Number(label="Zinc (µg/dL)", value=90)
|
| 677 |
+
copper = gr.Number(label="Copper (µg/dL)", value=110)
|
| 678 |
+
selenium = gr.Number(label="Selenium (µg/L)", value=120)
|
| 679 |
+
iron = gr.Number(label="Iron (µg/dL)", value=80)
|
| 680 |
+
tibc = gr.Number(label="TIBC (µg/dL)", value=300)
|
| 681 |
+
transferrin = gr.Number(label="Transferrin (mg/dL)", value=250)
|
| 682 |
+
allergy_panel = gr.Number(label="Allergy Panel Score", value=0)
|
| 683 |
+
|
| 684 |
+
with gr.Accordion("🌡️ Hormones & Vitamins", open=False):
|
| 685 |
tsh = gr.Number(label="TSH (μIU/mL)", value=2.0)
|
|
|
|
| 686 |
free_t3 = gr.Number(label="Free T3 (pg/mL)", value=3.2)
|
| 687 |
+
free_t4 = gr.Number(label="Free T4 (ng/dL)", value=1.2)
|
| 688 |
+
total_t3 = gr.Number(label="Total T3 (ng/dL)", value=1.3)
|
| 689 |
+
total_t4 = gr.Number(label="Total T4 (µg/dL)", value=7.8)
|
| 690 |
+
reverse_t3 = gr.Number(label="Reverse T3 (ng/dL)", value=15)
|
| 691 |
+
tpo_ab = gr.Number(label="TPO Ab (IU/mL)", value=10)
|
| 692 |
+
tg_ab = gr.Number(label="TG Ab (IU/mL)", value=12)
|
| 693 |
+
total_testosterone = gr.Number(label="Total Testosterone (ng/dL)", value=500)
|
| 694 |
+
free_testosterone = gr.Number(label="Free Testosterone (ng/dL)", value=15)
|
| 695 |
+
estrogen = gr.Number(label="Estrogen (pg/mL)", value=50)
|
| 696 |
+
progesterone = gr.Number(label="Progesterone (ng/mL)", value=1.2)
|
| 697 |
+
dhea_s = gr.Number(label="DHEA-S (µg/dL)", value=200)
|
| 698 |
+
shbg = gr.Number(label="SHBG (nmol/L)", value=40)
|
| 699 |
+
lh = gr.Number(label="LH (mIU/mL)", value=5)
|
| 700 |
+
fsh = gr.Number(label="FSH (mIU/mL)", value=6)
|
| 701 |
+
cortisol = gr.Number(label="Cortisol (µg/dL)", value=12)
|
| 702 |
+
acth = gr.Number(label="ACTH (pg/mL)", value=25)
|
| 703 |
+
igf1 = gr.Number(label="IGF-1 (ng/mL)", value=150)
|
| 704 |
+
leptin = gr.Number(label="Leptin (ng/mL)", value=10)
|
| 705 |
+
adiponectin = gr.Number(label="Adiponectin (µg/mL)", value=8)
|
| 706 |
+
|
| 707 |
+
with gr.Accordion("🧬 Tumor Markers", open=False):
|
| 708 |
+
ca125 = gr.Number(label="CA-125 (U/mL)", value=20)
|
| 709 |
+
ca15_3 = gr.Number(label="CA 15-3 (U/mL)", value=25)
|
| 710 |
+
ca19_9 = gr.Number(label="CA 19-9 (U/mL)", value=15)
|
| 711 |
+
psa = gr.Number(label="PSA (ng/mL)", value=2.0)
|
| 712 |
+
cea = gr.Number(label="CEA (ng/mL)", value=3.0)
|
| 713 |
+
calcitonin = gr.Number(label="Calcitonin (pg/mL)", value=5)
|
| 714 |
+
afp = gr.Number(label="AFP (ng/mL)", value=10)
|
| 715 |
+
|
| 716 |
+
with gr.Accordion("🧪 Immunology", open=False):
|
| 717 |
+
tnf = gr.Number(label="TNF-α (pg/mL)", value=10)
|
| 718 |
+
ana = gr.Number(label="ANA (IU/mL)", value=5)
|
| 719 |
+
ige = gr.Number(label="IgE (IU/mL)", value=100)
|
| 720 |
+
igg = gr.Number(label="IgG (IU/mL)", value=1200)
|
| 721 |
+
anti_ccp = gr.Number(label="Anti-CCP (U/mL)", value=5)
|
| 722 |
+
dsdna = gr.Number(label="dsDNA (IU/mL)", value=10)
|
| 723 |
+
ssa_ssb = gr.Number(label="SSA/SSB (U/mL)", value=10)
|
| 724 |
+
rnp = gr.Number(label="RNP (U/mL)", value=5)
|
| 725 |
+
sm_antibodies = gr.Number(label="Sm Antibodies (U/mL)", value=5)
|
| 726 |
+
anca = gr.Number(label="ANCA (U/mL)", value=5)
|
| 727 |
+
anti_ena = gr.Number(label="Anti-ENA (U/mL)", value=5)
|
| 728 |
+
il6 = gr.Number(label="IL-6 (pg/mL)", value=5)
|
| 729 |
|
| 730 |
submit_btn = gr.Button("🧠 Generate Comprehensive Medical Report", variant="primary", size="lg")
|
| 731 |
+
output_md = gr.Markdown(label="AI-Generated Medical Report")
|
| 732 |
+
|
| 733 |
+
submit_btn.click(
|
| 734 |
+
fn=gradio_interface,
|
| 735 |
+
inputs=[
|
| 736 |
+
age, gender, height, weight,
|
| 737 |
+
urea, creatinine, uric_acid, calcium, phosphorus, sodium, potassium, chloride,
|
| 738 |
+
amylase, lipase, bicarbonate, egfr, serum_osmolality, ionized_calcium,
|
| 739 |
+
wbc, hemoglobin, mcv, rdw, lymphocytes,
|
| 740 |
+
fasting_blood_sugar, hb1ac, insulin, c_peptide, homa_ir,
|
| 741 |
+
total_cholesterol, ldl, hdl, cholesterol_hdl_ratio, triglycerides, apo_a1, apo_b, apo_ratio,
|
| 742 |
+
albumin, total_protein, alt, ast, alp, ggt, ld, globulin, albumin_globulin_ratio,
|
| 743 |
+
magnesium, total_bilirubin, direct_bilirubin, indirect_bilirubin, ammonia,
|
| 744 |
+
hs_crp, ck, ck_mb, homocysteine, zinc, copper, selenium,
|
| 745 |
+
iron, tibc, transferrin,
|
| 746 |
+
vitamin_d, vitamin_b12,
|
| 747 |
+
total_testosterone, free_testosterone, estrogen, progesterone, dhea_s, shbg,
|
| 748 |
+
lh, fsh, tsh, free_t3, free_t4, total_t3, total_t4, reverse_t3, tpo_ab, tg_ab,
|
| 749 |
+
cortisol, acth, igf1, leptin, adiponectin,
|
| 750 |
+
ca125, ca15_3, ca19_9, psa, cea, calcitonin, afp,
|
| 751 |
+
tnf, ana, ige, igg, anti_ccp, dsdna, ssa_ssb, rnp, sm_antibodies, anca, anti_ena,
|
| 752 |
+
il6, allergy_panel
|
| 753 |
+
],
|
| 754 |
+
outputs=output_md
|
| 755 |
+
)
|
| 756 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 757 |
if __name__ == "__main__":
|
| 758 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|