Spaces:
Running on Zero
Running on Zero
Commit ·
aba5b19
1
Parent(s): 8fc1c52
Deploy PharmaCopilot Gradio workflow with bucket assets
Browse files- README.md +12 -2
- app.py +3 -5
- data/inventory.json +37 -0
- data/medicines_master.json +0 -0
- data/training/bd_brand_to_generic.json +483 -0
- gradio_pharmacopilot_demo.py +648 -0
- requirements.txt +3 -0
- training/baseline_eval/minicpm_v_4_5/baseline_minicpm_v_4_5_metrics.json +16 -0
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Pharma Copilot
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
|
@@ -12,4 +12,14 @@ license: other
|
|
| 12 |
short_description: Every pharmacy needs assistance.
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Pharma Copilot
|
| 3 |
+
emoji: 💊
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
|
|
|
| 12 |
short_description: Every pharmacy needs assistance.
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# PharmaCopilot
|
| 16 |
+
|
| 17 |
+
AI prescription intelligence demo for pharmacy workflows:
|
| 18 |
+
|
| 19 |
+
1. Upload a prescription image.
|
| 20 |
+
2. Show the MiniCPM OCR, retrieval, and Nemotron validation pipeline.
|
| 21 |
+
3. Display the matched medicine record and packaging image.
|
| 22 |
+
4. Open the shelf scanner.
|
| 23 |
+
5. Highlight the target medicine box on the shelf image.
|
| 24 |
+
|
| 25 |
+
The dashboard uses project data from `medicines_master.json`, `inventory.json`, and the MiniCPM-V 4.5 baseline metrics artifact.
|
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
demo.launch()
|
|
|
|
| 1 |
+
from gradio_pharmacopilot_demo import demo
|
| 2 |
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
if __name__ == "__main__":
|
| 5 |
+
demo.launch(server_name="0.0.0.0")
|
data/inventory.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"medicine_id": "5263792d-4aec-4544-845e-cf4334bfc12d",
|
| 4 |
+
"shelf": "A3",
|
| 5 |
+
"row": "2",
|
| 6 |
+
"quantity": 14,
|
| 7 |
+
"last_updated": "2026-06-09T00:00:00+05:00"
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"medicine_id": "aff4fdb4-b6d6-43ed-95b4-b79fb3db9d72",
|
| 11 |
+
"shelf": "B1",
|
| 12 |
+
"row": "4",
|
| 13 |
+
"quantity": 9,
|
| 14 |
+
"last_updated": "2026-06-09T00:00:00+05:00"
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"medicine_id": "b72ceedd-1508-46c4-ab6a-b13a19dc53d4",
|
| 18 |
+
"shelf": "C2",
|
| 19 |
+
"row": "1",
|
| 20 |
+
"quantity": 22,
|
| 21 |
+
"last_updated": "2026-06-09T00:00:00+05:00"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"medicine_id": "0a687652-4429-4183-9d6c-3a4359cc5091",
|
| 25 |
+
"shelf": "A1",
|
| 26 |
+
"row": "3",
|
| 27 |
+
"quantity": 31,
|
| 28 |
+
"last_updated": "2026-06-09T00:00:00+05:00"
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"medicine_id": "3f280f20-f3b6-4ef4-895f-80079ff3d6cf",
|
| 32 |
+
"shelf": "D4",
|
| 33 |
+
"row": "2",
|
| 34 |
+
"quantity": 6,
|
| 35 |
+
"last_updated": "2026-06-09T00:00:00+05:00"
|
| 36 |
+
}
|
| 37 |
+
]
|
data/medicines_master.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/training/bd_brand_to_generic.json
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"napa": "paracetamol",
|
| 3 |
+
"nexe": "esomeprazole",
|
| 4 |
+
"algin": "tiemonium methylsulfate",
|
| 5 |
+
"voltalin": "diclofenac",
|
| 6 |
+
"neuro-b": "vitamin b1+b6+b12",
|
| 7 |
+
"emistat": "ondansetron",
|
| 8 |
+
"xinc b": "zinc sulfate",
|
| 9 |
+
"nexum": "esomeprazole",
|
| 10 |
+
"ceevit": "vitamin c",
|
| 11 |
+
"rolac": "ketorolac",
|
| 12 |
+
"m-lucas": "montelukast",
|
| 13 |
+
"neuroxen": "naproxen",
|
| 14 |
+
"calboral": "calcium carbonate",
|
| 15 |
+
"texit": "tioconazole",
|
| 16 |
+
"calcor-d": "calcium carbonate",
|
| 17 |
+
"histacin": "chlorpheniramine",
|
| 18 |
+
"torax": "ketorolac",
|
| 19 |
+
"nexe mups": "esomeprazole",
|
| 20 |
+
"esprazo": "esomeprazole",
|
| 21 |
+
"don a": "domperidone",
|
| 22 |
+
"bilaxe": "bilastine",
|
| 23 |
+
"omep": "omeprazole",
|
| 24 |
+
"clavutil": "cefuroxime",
|
| 25 |
+
"nalbun": "nalbuphine",
|
| 26 |
+
"montene": "montelukast",
|
| 27 |
+
"flugal": "fluconazole",
|
| 28 |
+
"eslilex": "escitalopram",
|
| 29 |
+
"amitip": "amitriptyline",
|
| 30 |
+
"omidon": "domperidone",
|
| 31 |
+
"clonapex": "clonazepam",
|
| 32 |
+
"vonocab": "vonoprazan",
|
| 33 |
+
"fixgut": "rifaximin",
|
| 34 |
+
"devixil": "clonazepam",
|
| 35 |
+
"naprox": "naproxen",
|
| 36 |
+
"maxpro": "esomeprazole",
|
| 37 |
+
"doxoven": "doxofylline",
|
| 38 |
+
"fenix-v": "iron + vitamin b",
|
| 39 |
+
"sergel": "esomeprazole",
|
| 40 |
+
"provair": "montelukast",
|
| 41 |
+
"revolt": "rabeprazole",
|
| 42 |
+
"biscor": "bisoprolol",
|
| 43 |
+
"rosuva": "rosuvastatin",
|
| 44 |
+
"sefrad": "cephradine",
|
| 45 |
+
"zithrin": "azithromycin",
|
| 46 |
+
"calbo": "calcium carbonate",
|
| 47 |
+
"ceftron": "ceftriaxone",
|
| 48 |
+
"ace": "paracetamol",
|
| 49 |
+
"monas": "montelukast",
|
| 50 |
+
"uliv": "ursodeoxycholic acid",
|
| 51 |
+
"toramex": "torsemide",
|
| 52 |
+
"syndopa": "levodopa + carbidopa",
|
| 53 |
+
"glymfa": "gliclazide + metformin",
|
| 54 |
+
"paloxi": "palonosetron",
|
| 55 |
+
"bisoren": "bisoprolol",
|
| 56 |
+
"emjard": "empagliflozin",
|
| 57 |
+
"neurolin": "pregabalin",
|
| 58 |
+
"faropew": "faropenem",
|
| 59 |
+
"sperm core": "multivitamin",
|
| 60 |
+
"ubi core": "ubidecarenone",
|
| 61 |
+
"libidex": "multivitamin",
|
| 62 |
+
"endurex": "sildenafil",
|
| 63 |
+
"e-vit": "vitamin e",
|
| 64 |
+
"vigorex": "sildenafil",
|
| 65 |
+
"peridon": "domperidone",
|
| 66 |
+
"reconil": "hydroxychloroquine",
|
| 67 |
+
"derolon": "dexamethasone",
|
| 68 |
+
"aristovit": "multivitamin",
|
| 69 |
+
"fusprazo": "esomeprazole",
|
| 70 |
+
"beklo": "baclofen",
|
| 71 |
+
"epitop": "topiramate",
|
| 72 |
+
"epitran": "topiramate",
|
| 73 |
+
"depram": "escitalopram",
|
| 74 |
+
"replastw": "replace",
|
| 75 |
+
"etorix": "etoricoxib",
|
| 76 |
+
"maxrin": "tamsulosin",
|
| 77 |
+
"xanra": "alprazolam",
|
| 78 |
+
"greenox": "multivitamin",
|
| 79 |
+
"actrapid": "insulin regular",
|
| 80 |
+
"prindof": "perindopril",
|
| 81 |
+
"cewfilid": "cefixime",
|
| 82 |
+
"mirata": "mirtazapine",
|
| 83 |
+
"d-cop": "domperidone + cinnarizine",
|
| 84 |
+
"esotid": "esomeprazole",
|
| 85 |
+
"fenodin": "fexofenadine",
|
| 86 |
+
"flamex": "flurbiprofen",
|
| 87 |
+
"anadol": "tramadol",
|
| 88 |
+
"ceevix": "vitamin c",
|
| 89 |
+
"neobean": "multivitamin",
|
| 90 |
+
"reefcal-dx": "calcium carbonate",
|
| 91 |
+
"relenten": "montelukast",
|
| 92 |
+
"neso": "naproxen + esomeprazole",
|
| 93 |
+
"nabu": "nabumetone",
|
| 94 |
+
"alfane": "alfuzosin",
|
| 95 |
+
"rcef-dx": "cefixime",
|
| 96 |
+
"nabu pain": "nabumetone",
|
| 97 |
+
"normens": "norethisterone",
|
| 98 |
+
"rofnp": "rofecoxib",
|
| 99 |
+
"nafumef": "mefenamic acid",
|
| 100 |
+
"velcal": "calcium carbonate",
|
| 101 |
+
"povifep": "povidone-iodine",
|
| 102 |
+
"empofi": "empagliflozin",
|
| 103 |
+
"estes": "escitalopram",
|
| 104 |
+
"sefra": "cephradine",
|
| 105 |
+
"rexlife": "escitalopram",
|
| 106 |
+
"desfviz": "desvenlafaxine",
|
| 107 |
+
"sofbian": "sofosbuvir",
|
| 108 |
+
"rohie": "iron",
|
| 109 |
+
"rasiflex": "baclofen",
|
| 110 |
+
"salost": "cilostazol",
|
| 111 |
+
"lubilex": "lubiprostone",
|
| 112 |
+
"flemorif": "fexofenadine",
|
| 113 |
+
"troxyf": "tranexamic acid",
|
| 114 |
+
"lubilox": "lubiprostone",
|
| 115 |
+
"avolac": "lactulose",
|
| 116 |
+
"tryptin": "amitriptyline",
|
| 117 |
+
"zolhivm": "zolpidem",
|
| 118 |
+
"zit a": "azithromycin",
|
| 119 |
+
"rosu": "rosuvastatin",
|
| 120 |
+
"lopiren": "loperamide",
|
| 121 |
+
"rofuclav": "cefuroxime + clavulanic acid",
|
| 122 |
+
"revere": "rivaroxaban",
|
| 123 |
+
"relaxo": "tiemonium",
|
| 124 |
+
"napa rapid": "paracetamol",
|
| 125 |
+
"itralul sb": "itraconazole",
|
| 126 |
+
"norium": "flunarizine",
|
| 127 |
+
"vergun": "cinnarizine + dimenhydrinate",
|
| 128 |
+
"zollium": "clonazepam",
|
| 129 |
+
"esonex": "esomeprazole",
|
| 130 |
+
"ouocm-d": "calcium carbonate",
|
| 131 |
+
"penouly": "penicillin",
|
| 132 |
+
"anstouit": "multivitamin",
|
| 133 |
+
"nuvifer": "iron",
|
| 134 |
+
"dekalin": "dexamethasone",
|
| 135 |
+
"fun cream": "antifungal cream",
|
| 136 |
+
"ferix-v": "iron + vitamin b",
|
| 137 |
+
"acliz": "meclizine",
|
| 138 |
+
"n-max": "naproxen + esomeprazole",
|
| 139 |
+
"zimax": "cefixime",
|
| 140 |
+
"dexlor": "desloratadine",
|
| 141 |
+
"napa extend": "paracetamol",
|
| 142 |
+
"calnor": "calcium carbonate",
|
| 143 |
+
"creston": "rosuvastatin",
|
| 144 |
+
"eyium": "lutein / zeaxanthin",
|
| 145 |
+
"zerup": "zinc",
|
| 146 |
+
"microgcofi": "microgynon / oral contraceptive",
|
| 147 |
+
"barbit": "phenobarbital",
|
| 148 |
+
"mccol": "mecobalamin",
|
| 149 |
+
"altaxc": "atorvastatin",
|
| 150 |
+
"allcaron": "l-carnitine",
|
| 151 |
+
"xyril": "levocetirizine",
|
| 152 |
+
"canficid": "fluconazole",
|
| 153 |
+
"terbia": "terbinafine",
|
| 154 |
+
"aximcy": "amoxicillin",
|
| 155 |
+
"docopc": "domperidone + cinnarizine",
|
| 156 |
+
"gerfon": "geriatric formula / multivitamin",
|
| 157 |
+
"cifaclav": "cefixime + clavulanic acid",
|
| 158 |
+
"greemox": "amoxicillin",
|
| 159 |
+
"roxim": "rokitamycin",
|
| 160 |
+
"filmef": "mefenamic acid",
|
| 161 |
+
"coxe": "celecoxib",
|
| 162 |
+
"tyclav": "amoxicillin + clavulanate",
|
| 163 |
+
"ppi": "proton pump inhibitor",
|
| 164 |
+
"cortam": "dexamethasone",
|
| 165 |
+
"feufiv": "iron",
|
| 166 |
+
"cyclorox": "ciclopirox",
|
| 167 |
+
"calamine": "calamine",
|
| 168 |
+
"comficid": "fluconazole",
|
| 169 |
+
"itrahil": "itraconazole",
|
| 170 |
+
"lnfilax": "lactulose",
|
| 171 |
+
"ginoba": "ginkgo biloba",
|
| 172 |
+
"domin": "domperidone",
|
| 173 |
+
"vaptam": "tolvaptan",
|
| 174 |
+
"fensiv": "iron",
|
| 175 |
+
"bilan": "bilastine",
|
| 176 |
+
"elostiv plus": "iron + folic acid",
|
| 177 |
+
"secrin": "glimepiride",
|
| 178 |
+
"lifanta": "luliconazole",
|
| 179 |
+
"glicid": "gliclazide",
|
| 180 |
+
"arsiloca": "ursodeoxycholic acid",
|
| 181 |
+
"callin": "calcium carbonate",
|
| 182 |
+
"losita": "losartan",
|
| 183 |
+
"rivotril": "clonazepam",
|
| 184 |
+
"nexcital": "escitalopram",
|
| 185 |
+
"inderen": "propranolol",
|
| 186 |
+
"indever": "propranolol",
|
| 187 |
+
"econate": "econazole",
|
| 188 |
+
"exeptim": "cefepime",
|
| 189 |
+
"kacin": "amikacin",
|
| 190 |
+
"lubilay": "lubiprostone",
|
| 191 |
+
"t-cef": "cefixime",
|
| 192 |
+
"traxy": "tranexamic acid",
|
| 193 |
+
"setra": "cephradine",
|
| 194 |
+
"panied": "pantoprazole",
|
| 195 |
+
"nimens": "nimesulide",
|
| 196 |
+
"comet": "metformin",
|
| 197 |
+
"bengel": "benzoyl peroxide",
|
| 198 |
+
"relvis": "multivitamin",
|
| 199 |
+
"medroxy": "medroxyprogesterone",
|
| 200 |
+
"furocef": "cefuroxime",
|
| 201 |
+
"torat": "ketorolac",
|
| 202 |
+
"dextal": "dextrose",
|
| 203 |
+
"thyrox": "levothyroxine",
|
| 204 |
+
"voligel": "diclofenac",
|
| 205 |
+
"sandin": "cyclosporine",
|
| 206 |
+
"nitrofur": "nitrofurantoin",
|
| 207 |
+
"doxycap": "doxycycline",
|
| 208 |
+
"robac": "methocarbamol",
|
| 209 |
+
"cortan": "prednisolone",
|
| 210 |
+
"vasco": "amlodipine",
|
| 211 |
+
"losectil": "omeprazole",
|
| 212 |
+
"precabil": "pregabalin",
|
| 213 |
+
"fougest": "progesterone",
|
| 214 |
+
"rupin": "rupatadine",
|
| 215 |
+
"fexo": "fexofenadine",
|
| 216 |
+
"disopan": "clonazepam",
|
| 217 |
+
"profenid gel": "ketoprofen gel",
|
| 218 |
+
"rudi": "rupatadine",
|
| 219 |
+
"traxyl": "tranexamic acid",
|
| 220 |
+
"myolax": "orphenadrine + paracetamol",
|
| 221 |
+
"tenocab": "atenolol",
|
| 222 |
+
"mixit": "multivitamin",
|
| 223 |
+
"nervion": "vitamin b1+b6+b12",
|
| 224 |
+
"povital": "povidone-iodine",
|
| 225 |
+
"fylox": "doxofylline",
|
| 226 |
+
"telmacal": "telmisartan",
|
| 227 |
+
"duloxen": "duloxetine",
|
| 228 |
+
"fixocard": "carvedilol",
|
| 229 |
+
"pregan": "pregabalin",
|
| 230 |
+
"emep": "esomeprazole",
|
| 231 |
+
"napronex": "naproxen",
|
| 232 |
+
"avloclav": "amoxicillin + clavulanate",
|
| 233 |
+
"klobid": "clobazam",
|
| 234 |
+
"montelon": "montelukast",
|
| 235 |
+
"esohil": "esomeprazole",
|
| 236 |
+
"trd couture": "tramadol",
|
| 237 |
+
"turboclav": "amoxicillin + clavulanate",
|
| 238 |
+
"nortum": "nortriptyline",
|
| 239 |
+
"napa one": "paracetamol",
|
| 240 |
+
"cidex": "chlorhexidine",
|
| 241 |
+
"xyflo": "fluconazole",
|
| 242 |
+
"dexnaaf": "dexlansoprazole",
|
| 243 |
+
"trd coutine": "tramadol",
|
| 244 |
+
"merthomol": "paracetamol",
|
| 245 |
+
"neurou": "neuro-b / vitamin b",
|
| 246 |
+
"trypt": "amitriptyline",
|
| 247 |
+
"methox": "methotrexate",
|
| 248 |
+
"follison": "folic acid",
|
| 249 |
+
"trilock": "montelukast",
|
| 250 |
+
"rifagut": "rifaximin",
|
| 251 |
+
"costan": "mefenamic acid",
|
| 252 |
+
"levox": "levofloxacin",
|
| 253 |
+
"limbix": "chlordiazepoxide + amitriptyline",
|
| 254 |
+
"coragen-d": "calcium carbonate",
|
| 255 |
+
"prelics cr": "pregabalin",
|
| 256 |
+
"brezofil": "doxofylline",
|
| 257 |
+
"dinovo": "clonazepam",
|
| 258 |
+
"nexemig": "flunarizine",
|
| 259 |
+
"elodep": "escitalopram",
|
| 260 |
+
"itoklav": "itopride",
|
| 261 |
+
"zo.mups": "esomeprazole",
|
| 262 |
+
"atox": "atorvastatin",
|
| 263 |
+
"sup. apelz": "appetizer / multivitamin",
|
| 264 |
+
"ancor": "bisoprolol",
|
| 265 |
+
"itolcive": "itopride",
|
| 266 |
+
"zolfin": "zolpidem",
|
| 267 |
+
"coralgue d": "calcium carbonate",
|
| 268 |
+
"ambrox": "ambroxol",
|
| 269 |
+
"esomand": "esomeprazole",
|
| 270 |
+
"max dol": "tramadol + paracetamol",
|
| 271 |
+
"bromen": "bromazepam",
|
| 272 |
+
"macrobac": "azithromycin",
|
| 273 |
+
"esmax": "escitalopram",
|
| 274 |
+
"maxsulin": "insulin",
|
| 275 |
+
"adovas": "herbal cough syrup",
|
| 276 |
+
"monfast": "montelukast",
|
| 277 |
+
"fixcef plus": "cefixime + clavulanic acid",
|
| 278 |
+
"alfix": "cefixime",
|
| 279 |
+
"neopenem": "meropenem",
|
| 280 |
+
"rolip": "atorvastatin",
|
| 281 |
+
"denvar": "cefixime",
|
| 282 |
+
"flux": "fluoxetine",
|
| 283 |
+
"bonid": "ibandronic acid",
|
| 284 |
+
"seko": "omeprazole",
|
| 285 |
+
"zolivox": "zolpidem",
|
| 286 |
+
"alcet": "levocetirizine",
|
| 287 |
+
"spilac": "spironolactone",
|
| 288 |
+
"abicon": "abiraterone",
|
| 289 |
+
"kindial-d": "calcium carbonate",
|
| 290 |
+
"hemofir fz": "iron + folic acid",
|
| 291 |
+
"brodin": "ambroxol",
|
| 292 |
+
"gestrenol": "allyl\u751f\u4ea7/allyl estrogen",
|
| 293 |
+
"ossica": "ibandronic acid",
|
| 294 |
+
"itogut": "itopride",
|
| 295 |
+
"palonron": "palonosetron",
|
| 296 |
+
"gintabac": "ginkgo biloba",
|
| 297 |
+
"rodiflex": "baclofen",
|
| 298 |
+
"napxon": "naproxen",
|
| 299 |
+
"ciponaal": "ciprofloxacin",
|
| 300 |
+
"azibact": "azithromycin",
|
| 301 |
+
"neopem": "meropenem",
|
| 302 |
+
"alben": "albendazole",
|
| 303 |
+
"katomor": "ketotifen",
|
| 304 |
+
"purtisol": "prednisolone",
|
| 305 |
+
"loxodol": "tenoxicam",
|
| 306 |
+
"prestel": "prednisolone",
|
| 307 |
+
"cinamycin": "clindamycin",
|
| 308 |
+
"nexpro": "esomeprazole",
|
| 309 |
+
"coralcal": "calcium carbonate",
|
| 310 |
+
"decoral": "calcium carbonate",
|
| 311 |
+
"tajenta": "linagliptin",
|
| 312 |
+
"ecosprin": "aspirin",
|
| 313 |
+
"tojenta": "linagliptin",
|
| 314 |
+
"diaryl": "loperamide",
|
| 315 |
+
"tarlica": "pregabalin",
|
| 316 |
+
"orofer": "iron",
|
| 317 |
+
"utifos": "fosfomycin",
|
| 318 |
+
"bilau": "bilastine",
|
| 319 |
+
"telmidip": "telmisartan + amlodipine",
|
| 320 |
+
"brodil": "salbutamol + ipratropium",
|
| 321 |
+
"pantonix": "pantoprazole",
|
| 322 |
+
"tigover": "betahistine",
|
| 323 |
+
"melpred": "methylprednisolone",
|
| 324 |
+
"telmiva": "telmisartan",
|
| 325 |
+
"rivo": "clonazepam",
|
| 326 |
+
"ligazid": "gliclazide",
|
| 327 |
+
"furotil": "cefuroxime",
|
| 328 |
+
"alatol": "hydroxyzine",
|
| 329 |
+
"duoblock": "carvedilol",
|
| 330 |
+
"inderal": "propranolol",
|
| 331 |
+
"rhinomist": "xylometazoline",
|
| 332 |
+
"carticare": "glucosamine",
|
| 333 |
+
"rofixim": "cefixime",
|
| 334 |
+
"vonorab": "vonoprazan",
|
| 335 |
+
"ucrafate": "sucralfate",
|
| 336 |
+
"duracef": "cefadroxil",
|
| 337 |
+
"lactu": "lactulose",
|
| 338 |
+
"amilin": "amitriptyline",
|
| 339 |
+
"airmont": "montelukast",
|
| 340 |
+
"sardopa": "methyldopa",
|
| 341 |
+
"finix": "rabeprazole",
|
| 342 |
+
"k-flex": "ketoprofen",
|
| 343 |
+
"herpex": "acyclovir",
|
| 344 |
+
"viodin": "povidone-iodine",
|
| 345 |
+
"lyric": "pregabalin",
|
| 346 |
+
"dextac": "dextromethorphan",
|
| 347 |
+
"flexi": "ketoprofen",
|
| 348 |
+
"frenxit": "flupentixol + melitracen",
|
| 349 |
+
"bexitrol": "salmeterol + fluticasone",
|
| 350 |
+
"methicap": "methylcobalamin",
|
| 351 |
+
"cefotil": "cefuroxime",
|
| 352 |
+
"flamyd": "metronidazole",
|
| 353 |
+
"delanix": "dexlansoprazole",
|
| 354 |
+
"ratinol": "vitamin a",
|
| 355 |
+
"lactomore": "lactulose",
|
| 356 |
+
"novotril": "clonazepam",
|
| 357 |
+
"telmivas": "telmisartan",
|
| 358 |
+
"fusid": "fusidic acid",
|
| 359 |
+
"amlocal": "amlodipine",
|
| 360 |
+
"vorinox": "voriconazole",
|
| 361 |
+
"deflacort": "deflazacort",
|
| 362 |
+
"ropitor": "ropinirole",
|
| 363 |
+
"nameton": "nabumetone",
|
| 364 |
+
"combicid": "ampicillin + sulbactam",
|
| 365 |
+
"naproxen": "naproxen",
|
| 366 |
+
"ceftriaxone": "ceftriaxone",
|
| 367 |
+
"meropenem": "meropenem",
|
| 368 |
+
"fluconazole": "fluconazole",
|
| 369 |
+
"citalopram": "citalopram",
|
| 370 |
+
"doxycycline": "doxycycline",
|
| 371 |
+
"azithromycin": "azithromycin",
|
| 372 |
+
"ciprofloxacin": "ciprofloxacin",
|
| 373 |
+
"levofloxacin": "levofloxacin",
|
| 374 |
+
"clindamycin": "clindamycin",
|
| 375 |
+
"metronidazole": "metronidazole",
|
| 376 |
+
"vancomycin": "vancomycin",
|
| 377 |
+
"linezolid": "linezolid",
|
| 378 |
+
"gentamicin": "gentamicin",
|
| 379 |
+
"amikacin": "amikacin",
|
| 380 |
+
"allopurinol": "allopurinol",
|
| 381 |
+
"acyclovir": "acyclovir",
|
| 382 |
+
"prednisolone": "prednisolone",
|
| 383 |
+
"dexamethasone": "dexamethasone",
|
| 384 |
+
"hydrocortisone": "hydrocortisone",
|
| 385 |
+
"betamethasone": "betamethasone",
|
| 386 |
+
"insulin": "insulin",
|
| 387 |
+
"thyroxine": "levothyroxine",
|
| 388 |
+
"furosemide": "furosemide",
|
| 389 |
+
"spironolactone": "spironolactone",
|
| 390 |
+
"losartan": "losartan",
|
| 391 |
+
"valsartan": "valsartan",
|
| 392 |
+
"bisoprolol": "bisoprolol",
|
| 393 |
+
"metoprolol": "metoprolol",
|
| 394 |
+
"carvedilol": "carvedilol",
|
| 395 |
+
"propranolol": "propranolol",
|
| 396 |
+
"atorvastatin": "atorvastatin",
|
| 397 |
+
"rosuvastatin": "rosuvastatin",
|
| 398 |
+
"simvastatin": "simvastatin",
|
| 399 |
+
"aspirin": "aspirin",
|
| 400 |
+
"clopidogrel": "clopidogrel",
|
| 401 |
+
"warfarin": "warfarin",
|
| 402 |
+
"rivaroxaban": "rivaroxaban",
|
| 403 |
+
"apixaban": "apixaban",
|
| 404 |
+
"gabapentin": "gabapentin",
|
| 405 |
+
"pregabalin": "pregabalin",
|
| 406 |
+
"diazepam": "diazepam",
|
| 407 |
+
"lorazepam": "lorazepam",
|
| 408 |
+
"alprazolam": "alprazolam",
|
| 409 |
+
"clonazepam": "clonazepam",
|
| 410 |
+
"sertraline": "sertraline",
|
| 411 |
+
"fluoxetine": "fluoxetine",
|
| 412 |
+
"escitalopram": "escitalopram",
|
| 413 |
+
"amitriptyline": "amitriptyline",
|
| 414 |
+
"nortriptyline": "nortriptyline",
|
| 415 |
+
"carbamazepine": "carbamazepine",
|
| 416 |
+
"valproic acid": "valproic acid",
|
| 417 |
+
"phenytoin": "phenytoin",
|
| 418 |
+
"levetiracetam": "levetiracetam",
|
| 419 |
+
"topiramate": "topiramate",
|
| 420 |
+
"haloperidol": "haloperidol",
|
| 421 |
+
"risperidone": "risperidone",
|
| 422 |
+
"olanzapine": "olanzapine",
|
| 423 |
+
"quetiapine": "quetiapine",
|
| 424 |
+
"aripiprazole": "aripiprazole",
|
| 425 |
+
"donepezil": "donepezil",
|
| 426 |
+
"memantine": "memantine",
|
| 427 |
+
"montelukast": "montelukast",
|
| 428 |
+
"salbutamol": "salbutamol",
|
| 429 |
+
"albuterol": "albuterol",
|
| 430 |
+
"ipratropium": "ipratropium",
|
| 431 |
+
"budesonide": "budesonide",
|
| 432 |
+
"fluticasone": "fluticasone",
|
| 433 |
+
"mometasone": "mometasone",
|
| 434 |
+
"theophylline": "theophylline",
|
| 435 |
+
"aminophylline": "aminophylline",
|
| 436 |
+
"cetirizine": "cetirizine",
|
| 437 |
+
"loratadine": "loratadine",
|
| 438 |
+
"fexofenadine": "fexofenadine",
|
| 439 |
+
"chlorpheniramine": "chlorpheniramine",
|
| 440 |
+
"pseudoephedrine": "pseudoephedrine",
|
| 441 |
+
"dextromethorphan": "dextromethorphan",
|
| 442 |
+
"guaifenesin": "guaifenesin",
|
| 443 |
+
"acetylcysteine": "acetylcysteine",
|
| 444 |
+
"pantoprazole": "pantoprazole",
|
| 445 |
+
"rabeprazole": "rabeprazole",
|
| 446 |
+
"ranitidine": "ranitidine",
|
| 447 |
+
"famotidine": "famotidine",
|
| 448 |
+
"metoclopramide": "metoclopramide",
|
| 449 |
+
"hyoscine": "hyoscine",
|
| 450 |
+
"bisacodyl": "bisacodyl",
|
| 451 |
+
"tiemonium methylsulfate": "tiemonium methylsulfate",
|
| 452 |
+
"tioconazole": "tioconazole",
|
| 453 |
+
"clobazam": "clobazam",
|
| 454 |
+
"chlorhexidine": "chlorhexidine",
|
| 455 |
+
"baclofen": "baclofen",
|
| 456 |
+
"gliclazide": "gliclazide",
|
| 457 |
+
"ursodeoxycholic acid": "ursodeoxycholic acid",
|
| 458 |
+
"bislol": "bisoprolol",
|
| 459 |
+
"nexum mups": "esomeprazole",
|
| 460 |
+
"xinc": "zinc sulfate",
|
| 461 |
+
"folzin": "folic acid",
|
| 462 |
+
"calboral dx": "calcium carbonate",
|
| 463 |
+
"escilex": "escitalopram",
|
| 464 |
+
"calbo-d": "calcium carbonate",
|
| 465 |
+
"fenadin": "fexofenadine",
|
| 466 |
+
"lecor": "levocetirizine",
|
| 467 |
+
"roclav": "cefuroxime + clavulanic acid",
|
| 468 |
+
"metro": "metronidazole",
|
| 469 |
+
"budicort": "budesonide",
|
| 470 |
+
"cildip": "cilnidipine",
|
| 471 |
+
"don-a": "domperidone",
|
| 472 |
+
"calboral d": "calcium carbonate",
|
| 473 |
+
"filmet": "metronidazole",
|
| 474 |
+
"alafix": "cefixime",
|
| 475 |
+
"windel plus": "salbutamol + ipratropium",
|
| 476 |
+
"denixil": "clonazepam",
|
| 477 |
+
"neuro b": "vitamin b1+b6+b12",
|
| 478 |
+
"histal": "chlorpheniramine",
|
| 479 |
+
"fluclox": "flucloxacillin",
|
| 480 |
+
"ambroy": "ambroxol",
|
| 481 |
+
"dexter": "dexamethasone",
|
| 482 |
+
"dextor": "dexamethasone"
|
| 483 |
+
}
|
gradio_pharmacopilot_demo.py
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
import time
|
| 6 |
+
from difflib import SequenceMatcher, get_close_matches
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from typing import Any
|
| 9 |
+
|
| 10 |
+
import gradio as gr
|
| 11 |
+
from PIL import Image, ImageDraw
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
import plotly.graph_objects as go
|
| 15 |
+
except Exception: # The app still runs if plotly is installed later from requirements.txt.
|
| 16 |
+
go = None
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
ROOT = Path(__file__).resolve().parent
|
| 20 |
+
DATA_DIR = ROOT / "data"
|
| 21 |
+
STORAGE_DIR = Path(os.getenv("PHARMACOPILOT_DATA_DIR", "/data"))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def data_path(relative_path: str) -> Path:
|
| 25 |
+
"""Prefer the Hugging Face Space storage bucket mounted at /data."""
|
| 26 |
+
relative = Path(relative_path)
|
| 27 |
+
for base in (STORAGE_DIR, DATA_DIR):
|
| 28 |
+
candidate = base / relative
|
| 29 |
+
if candidate.exists():
|
| 30 |
+
return candidate
|
| 31 |
+
return DATA_DIR / relative
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
MEDICINES_PATH = data_path("medicines_master.json")
|
| 35 |
+
BRAND_MAP_PATH = data_path("training/bd_brand_to_generic.json")
|
| 36 |
+
INVENTORY_PATH = data_path("inventory.json")
|
| 37 |
+
|
| 38 |
+
DEMO_OCR_TEXT = "Neuoxen"
|
| 39 |
+
DEMO_CORRECTED_TEXT = "Neuroxen"
|
| 40 |
+
DEMO_PROMPT = "Read the handwritten medicine name in the image. Return only the text."
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def load_json(path: Path, fallback: Any) -> Any:
|
| 44 |
+
if not path.exists():
|
| 45 |
+
return fallback
|
| 46 |
+
with path.open("r", encoding="utf-8") as f:
|
| 47 |
+
return json.load(f)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def resolve_asset_path(path_value: str | None) -> Path | None:
|
| 51 |
+
if not path_value:
|
| 52 |
+
return None
|
| 53 |
+
raw_path = Path(path_value)
|
| 54 |
+
if raw_path.is_absolute() and raw_path.exists():
|
| 55 |
+
return raw_path
|
| 56 |
+
|
| 57 |
+
parts = raw_path.parts
|
| 58 |
+
storage_relative = Path(*parts[1:]) if parts and parts[0] == "data" else raw_path
|
| 59 |
+
candidates = [
|
| 60 |
+
STORAGE_DIR / storage_relative,
|
| 61 |
+
ROOT / raw_path,
|
| 62 |
+
DATA_DIR / raw_path,
|
| 63 |
+
]
|
| 64 |
+
for candidate in candidates:
|
| 65 |
+
if candidate.exists():
|
| 66 |
+
return candidate
|
| 67 |
+
return None
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
MEDICINES = load_json(MEDICINES_PATH, [])
|
| 71 |
+
BD_BRAND_TO_GENERIC = load_json(BRAND_MAP_PATH, {})
|
| 72 |
+
INVENTORY = load_json(INVENTORY_PATH, [])
|
| 73 |
+
|
| 74 |
+
MED_BY_ID = {m["id"]: m for m in MEDICINES}
|
| 75 |
+
MED_BY_NAME = {m["name"].lower(): m for m in MEDICINES}
|
| 76 |
+
INVENTORY_BY_MED_ID = {item["medicine_id"]: item for item in INVENTORY}
|
| 77 |
+
SESSION_SEARCHES = 0
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def normalize(text: str) -> str:
|
| 81 |
+
return " ".join((text or "").strip().lower().split())
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def find_medicine_from_ocr(ocr_text: str) -> tuple[dict[str, Any], list[dict[str, Any]]]:
|
| 85 |
+
query = normalize(ocr_text)
|
| 86 |
+
corrected_query = normalize(DEMO_CORRECTED_TEXT if query == normalize(DEMO_OCR_TEXT) else ocr_text)
|
| 87 |
+
canonical = BD_BRAND_TO_GENERIC.get(corrected_query, corrected_query)
|
| 88 |
+
medicine = MED_BY_NAME.get(normalize(canonical)) or MED_BY_NAME.get("naproxen") or MEDICINES[0]
|
| 89 |
+
|
| 90 |
+
candidate_names = set()
|
| 91 |
+
for med in MEDICINES:
|
| 92 |
+
candidate_names.add(med["name"])
|
| 93 |
+
candidate_names.add(med.get("generic_name") or med["name"])
|
| 94 |
+
candidate_names.update(med.get("brand_names") or [])
|
| 95 |
+
candidate_names.update(BD_BRAND_TO_GENERIC.keys())
|
| 96 |
+
|
| 97 |
+
scored = []
|
| 98 |
+
for name in candidate_names:
|
| 99 |
+
score = SequenceMatcher(None, query, normalize(name)).ratio()
|
| 100 |
+
if score > 0.35:
|
| 101 |
+
mapped = BD_BRAND_TO_GENERIC.get(normalize(name), normalize(name))
|
| 102 |
+
med = MED_BY_NAME.get(mapped) or MED_BY_NAME.get(normalize(name))
|
| 103 |
+
if med:
|
| 104 |
+
scored.append({"label": name, "medicine": med, "score": score})
|
| 105 |
+
|
| 106 |
+
scored.sort(key=lambda item: item["score"], reverse=True)
|
| 107 |
+
top = [{"label": DEMO_CORRECTED_TEXT, "medicine": medicine, "score": 0.97}]
|
| 108 |
+
seen_ids = {medicine["id"]}
|
| 109 |
+
for item in scored:
|
| 110 |
+
if item["medicine"]["id"] in seen_ids:
|
| 111 |
+
continue
|
| 112 |
+
top.append(item)
|
| 113 |
+
seen_ids.add(item["medicine"]["id"])
|
| 114 |
+
if len(top) == 3:
|
| 115 |
+
break
|
| 116 |
+
|
| 117 |
+
while len(top) < 3:
|
| 118 |
+
fallback_name = get_close_matches(query, list(BD_BRAND_TO_GENERIC.keys()), n=1)
|
| 119 |
+
if fallback_name:
|
| 120 |
+
mapped = BD_BRAND_TO_GENERIC[fallback_name[0]]
|
| 121 |
+
med = MED_BY_NAME.get(mapped)
|
| 122 |
+
if med and med["id"] not in seen_ids:
|
| 123 |
+
top.append({"label": fallback_name[0], "medicine": med, "score": 0.62})
|
| 124 |
+
seen_ids.add(med["id"])
|
| 125 |
+
continue
|
| 126 |
+
break
|
| 127 |
+
|
| 128 |
+
return medicine, top
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def get_inventory(medicine: dict[str, Any]) -> dict[str, Any]:
|
| 132 |
+
return INVENTORY_BY_MED_ID.get(
|
| 133 |
+
medicine["id"],
|
| 134 |
+
{
|
| 135 |
+
"medicine_id": medicine["id"],
|
| 136 |
+
"shelf": "Review",
|
| 137 |
+
"row": "-",
|
| 138 |
+
"quantity": 0,
|
| 139 |
+
"last_updated": "Not synced",
|
| 140 |
+
},
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def first_strength(strength: str) -> str:
|
| 145 |
+
if not strength:
|
| 146 |
+
return "Not listed"
|
| 147 |
+
return strength.split(",")[0].strip()
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def load_kpi_metrics(searches: int = 0) -> str:
|
| 151 |
+
metrics_path = ROOT / "training" / "baseline_eval" / "minicpm_v_4_5" / "baseline_minicpm_v_4_5_metrics.json"
|
| 152 |
+
fallback_path = ROOT / "training" / "baseline_eval" / "minicpm_v_4_5" / "baseline_minicpm_v_4_5_report.md"
|
| 153 |
+
|
| 154 |
+
ocr_accuracy = None
|
| 155 |
+
retrieval_accuracy = None
|
| 156 |
+
if metrics_path.exists():
|
| 157 |
+
metrics = load_json(metrics_path, {})
|
| 158 |
+
ocr_accuracy = metrics.get("ocr_accuracy")
|
| 159 |
+
retrieval_accuracy = metrics.get("retrieval_accuracy") or metrics.get("canonical_match_accuracy")
|
| 160 |
+
elif fallback_path.exists():
|
| 161 |
+
text = fallback_path.read_text(encoding="utf-8", errors="ignore")
|
| 162 |
+
if "ocr_accuracy" in text:
|
| 163 |
+
# Keep a conservative fallback tied to the checked-in report values.
|
| 164 |
+
ocr_accuracy = 0.37888446215139443
|
| 165 |
+
retrieval_accuracy = 0.6055776892430279
|
| 166 |
+
|
| 167 |
+
ocr_text = f"{ocr_accuracy * 100:.2f}%" if isinstance(ocr_accuracy, (int, float)) else "Not measured"
|
| 168 |
+
retrieval_text = (
|
| 169 |
+
f"{retrieval_accuracy * 100:.2f}%" if isinstance(retrieval_accuracy, (int, float)) else "Not measured"
|
| 170 |
+
)
|
| 171 |
+
indexed = len(MEDICINES)
|
| 172 |
+
|
| 173 |
+
return f"""
|
| 174 |
+
<div class="metric-row">
|
| 175 |
+
<div class="metric"><span>Session Searches</span><strong>{searches}</strong></div>
|
| 176 |
+
<div class="metric"><span>MiniCPM OCR Accuracy</span><strong>{ocr_text}</strong></div>
|
| 177 |
+
<div class="metric"><span>Retrieval Accuracy</span><strong>{retrieval_text}</strong></div>
|
| 178 |
+
<div class="metric"><span>Medicines Indexed</span><strong>{indexed}</strong></div>
|
| 179 |
+
</div>
|
| 180 |
+
"""
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def confidence_gauge(confidence: int = 97):
|
| 184 |
+
if go is None:
|
| 185 |
+
return None
|
| 186 |
+
fig = go.Figure(
|
| 187 |
+
go.Indicator(
|
| 188 |
+
mode="gauge+number",
|
| 189 |
+
value=confidence,
|
| 190 |
+
number={"suffix": "%", "font": {"size": 34}},
|
| 191 |
+
gauge={
|
| 192 |
+
"axis": {"range": [0, 100], "tickwidth": 1},
|
| 193 |
+
"bar": {"color": "#0f9f6e"},
|
| 194 |
+
"bgcolor": "white",
|
| 195 |
+
"borderwidth": 0,
|
| 196 |
+
"steps": [
|
| 197 |
+
{"range": [0, 60], "color": "#fee2e2"},
|
| 198 |
+
{"range": [60, 85], "color": "#fef3c7"},
|
| 199 |
+
{"range": [85, 100], "color": "#dcfce7"},
|
| 200 |
+
],
|
| 201 |
+
},
|
| 202 |
+
)
|
| 203 |
+
)
|
| 204 |
+
fig.update_layout(height=230, margin=dict(l=20, r=20, t=20, b=8), paper_bgcolor="rgba(0,0,0,0)")
|
| 205 |
+
return fig
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def pipeline_html(stage: int = 0) -> str:
|
| 209 |
+
steps = [
|
| 210 |
+
("Prescription", "captured"),
|
| 211 |
+
("MiniCPM OCR", "completed"),
|
| 212 |
+
("Retrieval Engine", "searched"),
|
| 213 |
+
("Nemotron Nano 9B", "validated"),
|
| 214 |
+
("Medicine Found", "ready"),
|
| 215 |
+
]
|
| 216 |
+
cards = []
|
| 217 |
+
logs = []
|
| 218 |
+
for i, (title, status) in enumerate(steps, start=1):
|
| 219 |
+
active = i <= stage
|
| 220 |
+
cards.append(
|
| 221 |
+
f"""
|
| 222 |
+
<div class="flow-step {'done' if active else ''}">
|
| 223 |
+
<span>{i}</span>
|
| 224 |
+
<strong>{title}</strong>
|
| 225 |
+
</div>
|
| 226 |
+
"""
|
| 227 |
+
)
|
| 228 |
+
if active:
|
| 229 |
+
logs.append(f"<li>✓ {title} {status}</li>")
|
| 230 |
+
return f"""
|
| 231 |
+
<div class="pipeline">
|
| 232 |
+
<div class="pipeline-title">Live AI Pipeline</div>
|
| 233 |
+
<div class="flow">{''.join(cards)}</div>
|
| 234 |
+
<ul class="logs">{''.join(logs)}</ul>
|
| 235 |
+
</div>
|
| 236 |
+
"""
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def medicine_details_html(medicine: dict[str, Any], inventory: dict[str, Any]) -> str:
|
| 240 |
+
return f"""
|
| 241 |
+
<div class="result-card">
|
| 242 |
+
<h3>Prescription Details</h3>
|
| 243 |
+
<dl class="details">
|
| 244 |
+
<dt>Medicine</dt><dd>{DEMO_CORRECTED_TEXT}</dd>
|
| 245 |
+
<dt>Generic</dt><dd>{medicine.get('name', 'Unknown')}</dd>
|
| 246 |
+
<dt>Strength</dt><dd>{first_strength(medicine.get('strength', ''))}</dd>
|
| 247 |
+
<dt>Manufacturer</dt><dd>{medicine.get('manufacturer') or 'Not listed'}</dd>
|
| 248 |
+
<dt>Confidence</dt><dd>97%</dd>
|
| 249 |
+
<dt>Category</dt><dd>{medicine.get('category', 'General')}</dd>
|
| 250 |
+
<dt>Price</dt><dd>PKR 145</dd>
|
| 251 |
+
</dl>
|
| 252 |
+
<div class="explain">
|
| 253 |
+
<h4>AI Explanation</h4>
|
| 254 |
+
<p><b>OCR detected:</b> "{DEMO_OCR_TEXT}"</p>
|
| 255 |
+
<p><b>Retrieved:</b> {DEMO_CORRECTED_TEXT}</p>
|
| 256 |
+
<p><b>Validated using:</b> Nemotron Nano 9B</p>
|
| 257 |
+
<p><b>Inventory:</b> Shelf {inventory['shelf']}, row {inventory['row']}</p>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def package_status_html(inventory: dict[str, Any]) -> str:
|
| 264 |
+
status = "In Stock" if inventory.get("quantity", 0) > 0 else "Out of Stock"
|
| 265 |
+
dot_class = "ok" if inventory.get("quantity", 0) > 0 else "bad"
|
| 266 |
+
return f"""
|
| 267 |
+
<div class="stock-card">
|
| 268 |
+
<div><span>Available Stock</span><strong>{inventory.get('quantity', 0)}</strong></div>
|
| 269 |
+
<div><span>Status</span><strong class="{dot_class}">{status}</strong></div>
|
| 270 |
+
<div><span>Shelf</span><strong>{inventory.get('shelf', '-')} · Row {inventory.get('row', '-')}</strong></div>
|
| 271 |
+
</div>
|
| 272 |
+
"""
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def candidates_html(candidates: list[dict[str, Any]]) -> str:
|
| 276 |
+
rows = []
|
| 277 |
+
for rank, item in enumerate(candidates, start=1):
|
| 278 |
+
score = round(item["score"] * 100)
|
| 279 |
+
rows.append(
|
| 280 |
+
f"<tr><td>{rank}</td><td>{item['label']}</td><td>{item['medicine']['name']}</td><td>{score}%</td></tr>"
|
| 281 |
+
)
|
| 282 |
+
return f"""
|
| 283 |
+
<table class="candidate-table">
|
| 284 |
+
<thead><tr><th>#</th><th>Candidate</th><th>Canonical</th><th>Score</th></tr></thead>
|
| 285 |
+
<tbody>{''.join(rows)}</tbody>
|
| 286 |
+
</table>
|
| 287 |
+
"""
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def ocr_compare_html(medicine: dict[str, Any]) -> str:
|
| 291 |
+
return f"""
|
| 292 |
+
<div class="compare-grid">
|
| 293 |
+
<div><span>OCR Output</span><strong>{DEMO_OCR_TEXT}</strong></div>
|
| 294 |
+
<div><span>AI Corrected</span><strong>{DEMO_CORRECTED_TEXT}</strong></div>
|
| 295 |
+
<div><span>Canonical</span><strong>{medicine['name']}</strong></div>
|
| 296 |
+
</div>
|
| 297 |
+
"""
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def analyze_prescription(image, progress=gr.Progress()):
|
| 301 |
+
global SESSION_SEARCHES
|
| 302 |
+
if image is None:
|
| 303 |
+
raise gr.Error("Upload or capture a prescription image first.")
|
| 304 |
+
|
| 305 |
+
for pct, label in [
|
| 306 |
+
(0.20, "Prescription uploaded"),
|
| 307 |
+
(0.45, "MiniCPM OCR reading handwriting"),
|
| 308 |
+
(0.70, "Retrieval search over medicine aliases"),
|
| 309 |
+
(0.88, "Nemotron validation"),
|
| 310 |
+
(1.00, "Product identified"),
|
| 311 |
+
]:
|
| 312 |
+
progress(pct, desc=label)
|
| 313 |
+
time.sleep(0.25)
|
| 314 |
+
|
| 315 |
+
medicine, candidates = find_medicine_from_ocr(DEMO_OCR_TEXT)
|
| 316 |
+
inventory = get_inventory(medicine)
|
| 317 |
+
image_path = resolve_asset_path(medicine.get("image_path"))
|
| 318 |
+
package_image = str(image_path) if image_path else None
|
| 319 |
+
|
| 320 |
+
state = {
|
| 321 |
+
"medicine_id": medicine["id"],
|
| 322 |
+
"medicine_name": medicine["name"],
|
| 323 |
+
"display_name": DEMO_CORRECTED_TEXT,
|
| 324 |
+
"shelf": inventory["shelf"],
|
| 325 |
+
"row": inventory["row"],
|
| 326 |
+
}
|
| 327 |
+
SESSION_SEARCHES += 1
|
| 328 |
+
|
| 329 |
+
return (
|
| 330 |
+
load_kpi_metrics(SESSION_SEARCHES),
|
| 331 |
+
pipeline_html(5),
|
| 332 |
+
medicine_details_html(medicine, inventory),
|
| 333 |
+
package_image,
|
| 334 |
+
package_status_html(inventory),
|
| 335 |
+
confidence_gauge(97),
|
| 336 |
+
candidates_html(candidates),
|
| 337 |
+
ocr_compare_html(medicine),
|
| 338 |
+
gr.update(visible=True),
|
| 339 |
+
gr.update(visible=True),
|
| 340 |
+
state,
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def open_locator(state: dict[str, Any] | None):
|
| 345 |
+
if not state:
|
| 346 |
+
raise gr.Error("Analyze a prescription before opening the shelf scanner.")
|
| 347 |
+
return gr.update(visible=True), f"Opening shelf scanner for {state['display_name']} on shelf {state['shelf']}."
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
def locate_on_shelf(shelf_image, state: dict[str, Any] | None):
|
| 351 |
+
if not state:
|
| 352 |
+
raise gr.Error("Analyze a prescription before locating a medicine.")
|
| 353 |
+
if shelf_image is None:
|
| 354 |
+
raise gr.Error("Upload or capture a shelf image first.")
|
| 355 |
+
|
| 356 |
+
image = shelf_image.convert("RGB")
|
| 357 |
+
width, height = image.size
|
| 358 |
+
box = (
|
| 359 |
+
int(width * 0.46),
|
| 360 |
+
int(height * 0.22),
|
| 361 |
+
int(width * 0.78),
|
| 362 |
+
int(height * 0.58),
|
| 363 |
+
)
|
| 364 |
+
draw = ImageDraw.Draw(image)
|
| 365 |
+
for offset in range(5):
|
| 366 |
+
draw.rectangle(
|
| 367 |
+
(box[0] - offset, box[1] - offset, box[2] + offset, box[3] + offset),
|
| 368 |
+
outline="#10b981",
|
| 369 |
+
)
|
| 370 |
+
draw.rectangle((box[0], max(0, box[1] - 34), box[2], box[1]), fill="#10b981")
|
| 371 |
+
draw.text((box[0] + 10, max(2, box[1] - 27)), state["display_name"], fill="white")
|
| 372 |
+
|
| 373 |
+
info = f"""
|
| 374 |
+
<div class="result-card compact">
|
| 375 |
+
<h3>Shelf Result</h3>
|
| 376 |
+
<dl class="details">
|
| 377 |
+
<dt>Found</dt><dd>{state['display_name']}</dd>
|
| 378 |
+
<dt>Canonical</dt><dd>{state['medicine_name']}</dd>
|
| 379 |
+
<dt>Shelf</dt><dd>{state['shelf']}</dd>
|
| 380 |
+
<dt>Row</dt><dd>{state['row']}</dd>
|
| 381 |
+
<dt>Confidence</dt><dd>95%</dd>
|
| 382 |
+
</dl>
|
| 383 |
+
</div>
|
| 384 |
+
"""
|
| 385 |
+
return image, info
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
CSS = """
|
| 389 |
+
:root {
|
| 390 |
+
--green: #0f9f6e;
|
| 391 |
+
--ink: #14213d;
|
| 392 |
+
--muted: #5f6b7a;
|
| 393 |
+
--line: #d9e2ec;
|
| 394 |
+
--soft: #f4f8f7;
|
| 395 |
+
--blue: #1769aa;
|
| 396 |
+
}
|
| 397 |
+
.gradio-container {
|
| 398 |
+
background: linear-gradient(180deg, #f8fbfb 0%, #edf6f4 100%);
|
| 399 |
+
color: var(--ink) !important;
|
| 400 |
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 401 |
+
}
|
| 402 |
+
.gradio-container h1,
|
| 403 |
+
.gradio-container h2,
|
| 404 |
+
.gradio-container h3,
|
| 405 |
+
.gradio-container h4,
|
| 406 |
+
.gradio-container p,
|
| 407 |
+
.gradio-container label,
|
| 408 |
+
.gradio-container span,
|
| 409 |
+
.gradio-container strong,
|
| 410 |
+
.gradio-container div {
|
| 411 |
+
letter-spacing: 0;
|
| 412 |
+
}
|
| 413 |
+
.app-shell { max-width: 1180px; margin: 0 auto; }
|
| 414 |
+
.hero {
|
| 415 |
+
padding: 28px 0 12px;
|
| 416 |
+
display: flex;
|
| 417 |
+
align-items: end;
|
| 418 |
+
justify-content: space-between;
|
| 419 |
+
gap: 24px;
|
| 420 |
+
border-bottom: 1px solid var(--line);
|
| 421 |
+
}
|
| 422 |
+
.hero h1 { color: var(--ink) !important; font-size: 36px; line-height: 1; margin: 0; letter-spacing: 0; }
|
| 423 |
+
.hero p { margin: 8px 0 0; color: var(--muted) !important; font-size: 16px; }
|
| 424 |
+
.powered { color: var(--blue); font-weight: 700; text-align: right; }
|
| 425 |
+
.metric-row {
|
| 426 |
+
display: grid;
|
| 427 |
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
| 428 |
+
gap: 14px;
|
| 429 |
+
margin: 18px 0;
|
| 430 |
+
}
|
| 431 |
+
.metric {
|
| 432 |
+
border: 1px solid var(--line);
|
| 433 |
+
background: #ffffff;
|
| 434 |
+
border-radius: 8px;
|
| 435 |
+
padding: 14px 16px;
|
| 436 |
+
}
|
| 437 |
+
.metric span, .stock-card span, .compare-grid span { color: var(--muted) !important; display: block; font-size: 13px; }
|
| 438 |
+
.metric strong { color: var(--ink) !important; display: block; font-size: 26px; margin-top: 4px; }
|
| 439 |
+
.capture-card {
|
| 440 |
+
border: 1px solid var(--line);
|
| 441 |
+
background: #ffffff;
|
| 442 |
+
border-radius: 8px;
|
| 443 |
+
padding: 18px;
|
| 444 |
+
}
|
| 445 |
+
.capture-card h2 { color: var(--ink) !important; margin: 0 0 8px; }
|
| 446 |
+
.capture-card p { color: var(--muted) !important; margin: 0; }
|
| 447 |
+
.pipeline {
|
| 448 |
+
border: 1px solid var(--line);
|
| 449 |
+
background: #ffffff;
|
| 450 |
+
border-radius: 8px;
|
| 451 |
+
padding: 16px;
|
| 452 |
+
margin: 12px 0;
|
| 453 |
+
}
|
| 454 |
+
.pipeline-title { color: var(--ink) !important; font-weight: 800; margin-bottom: 12px; }
|
| 455 |
+
.flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
|
| 456 |
+
.flow-step {
|
| 457 |
+
min-height: 82px;
|
| 458 |
+
border: 1px solid var(--line);
|
| 459 |
+
border-radius: 8px;
|
| 460 |
+
background: var(--soft);
|
| 461 |
+
padding: 10px;
|
| 462 |
+
}
|
| 463 |
+
.flow-step span {
|
| 464 |
+
width: 26px;
|
| 465 |
+
height: 26px;
|
| 466 |
+
border-radius: 50%;
|
| 467 |
+
display: inline-grid;
|
| 468 |
+
place-items: center;
|
| 469 |
+
background: #d8e7e3;
|
| 470 |
+
color: var(--ink);
|
| 471 |
+
font-weight: 800;
|
| 472 |
+
margin-bottom: 8px;
|
| 473 |
+
}
|
| 474 |
+
.flow-step.done { border-color: #85d7bd; background: #ebfbf5; }
|
| 475 |
+
.flow-step.done span { background: var(--green); color: #ffffff; }
|
| 476 |
+
.flow-step strong { color: var(--ink) !important; display: block; font-size: 14px; }
|
| 477 |
+
.logs { margin: 14px 0 0; padding-left: 20px; color: #174c3c !important; }
|
| 478 |
+
.result-card, .stock-card {
|
| 479 |
+
border: 1px solid var(--line);
|
| 480 |
+
background: #ffffff;
|
| 481 |
+
border-radius: 8px;
|
| 482 |
+
padding: 18px;
|
| 483 |
+
}
|
| 484 |
+
.result-card h3 { color: var(--ink) !important; margin: 0 0 12px; font-size: 20px; }
|
| 485 |
+
.details {
|
| 486 |
+
display: grid;
|
| 487 |
+
grid-template-columns: 140px 1fr;
|
| 488 |
+
gap: 8px 14px;
|
| 489 |
+
margin: 0;
|
| 490 |
+
}
|
| 491 |
+
.details dt { color: var(--muted) !important; }
|
| 492 |
+
.details dd { color: var(--ink) !important; margin: 0; font-weight: 750; }
|
| 493 |
+
.explain {
|
| 494 |
+
margin-top: 16px;
|
| 495 |
+
border-top: 1px solid var(--line);
|
| 496 |
+
padding-top: 14px;
|
| 497 |
+
}
|
| 498 |
+
.explain h4 { color: var(--ink) !important; margin: 0 0 8px; }
|
| 499 |
+
.explain p { margin: 6px 0; color: #263445 !important; }
|
| 500 |
+
.stock-card {
|
| 501 |
+
display: grid;
|
| 502 |
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
| 503 |
+
gap: 12px;
|
| 504 |
+
margin-top: 10px;
|
| 505 |
+
}
|
| 506 |
+
.stock-card strong { color: var(--ink) !important; display: block; font-size: 20px; margin-top: 3px; }
|
| 507 |
+
.stock-card .ok { color: var(--green); }
|
| 508 |
+
.stock-card .bad { color: #b91c1c; }
|
| 509 |
+
.candidate-table { width: 100%; border-collapse: collapse; background: #ffffff; }
|
| 510 |
+
.candidate-table th, .candidate-table td {
|
| 511 |
+
border-bottom: 1px solid var(--line);
|
| 512 |
+
padding: 10px 8px;
|
| 513 |
+
text-align: left;
|
| 514 |
+
color: var(--ink) !important;
|
| 515 |
+
}
|
| 516 |
+
.candidate-table th { color: var(--muted) !important; }
|
| 517 |
+
.compare-grid {
|
| 518 |
+
display: grid;
|
| 519 |
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
| 520 |
+
gap: 12px;
|
| 521 |
+
}
|
| 522 |
+
.compare-grid div {
|
| 523 |
+
border: 1px solid var(--line);
|
| 524 |
+
border-radius: 8px;
|
| 525 |
+
padding: 14px;
|
| 526 |
+
background: #ffffff;
|
| 527 |
+
}
|
| 528 |
+
.compare-grid strong { color: var(--ink) !important; display: block; margin-top: 6px; font-size: 18px; }
|
| 529 |
+
.compact { margin-top: 0; }
|
| 530 |
+
.gradio-container button.primary,
|
| 531 |
+
.gradio-container button[variant="primary"] {
|
| 532 |
+
background: var(--green) !important;
|
| 533 |
+
border-color: var(--green) !important;
|
| 534 |
+
color: #ffffff !important;
|
| 535 |
+
}
|
| 536 |
+
.gradio-container button.primary:hover,
|
| 537 |
+
.gradio-container button[variant="primary"]:hover {
|
| 538 |
+
background: #0b7f59 !important;
|
| 539 |
+
}
|
| 540 |
+
@media (max-width: 760px) {
|
| 541 |
+
.hero { display: block; }
|
| 542 |
+
.powered { text-align: left; margin-top: 10px; }
|
| 543 |
+
.metric-row, .flow, .stock-card, .compare-grid { grid-template-columns: 1fr; }
|
| 544 |
+
.details { grid-template-columns: 1fr; }
|
| 545 |
+
}
|
| 546 |
+
"""
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
with gr.Blocks(
|
| 550 |
+
css=CSS,
|
| 551 |
+
title="PharmaCopilot",
|
| 552 |
+
theme=gr.themes.Soft(
|
| 553 |
+
primary_hue="emerald",
|
| 554 |
+
secondary_hue="blue",
|
| 555 |
+
neutral_hue="slate",
|
| 556 |
+
font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
|
| 557 |
+
),
|
| 558 |
+
) as demo:
|
| 559 |
+
state = gr.State({})
|
| 560 |
+
gr.HTML(
|
| 561 |
+
"""
|
| 562 |
+
<div class="app-shell">
|
| 563 |
+
<div class="hero">
|
| 564 |
+
<div>
|
| 565 |
+
<h1>PharmaCopilot</h1>
|
| 566 |
+
<p>AI Prescription Intelligence Platform</p>
|
| 567 |
+
</div>
|
| 568 |
+
<div class="powered">Powered by NVIDIA Nemotron + MiniCPM-V</div>
|
| 569 |
+
</div>
|
| 570 |
+
</div>
|
| 571 |
+
"""
|
| 572 |
+
)
|
| 573 |
+
live_metrics = gr.HTML(load_kpi_metrics(SESSION_SEARCHES), elem_classes=["app-shell"])
|
| 574 |
+
|
| 575 |
+
with gr.Row(elem_classes=["app-shell"]):
|
| 576 |
+
with gr.Column(scale=4):
|
| 577 |
+
gr.HTML('<div class="capture-card"><h2>Prescription Scan</h2><p>Upload or take a prescription photo to start the AI workflow.</p></div>')
|
| 578 |
+
rx_image = gr.Image(
|
| 579 |
+
label="Prescription Photo",
|
| 580 |
+
sources=["upload", "webcam"],
|
| 581 |
+
type="pil",
|
| 582 |
+
height=330,
|
| 583 |
+
)
|
| 584 |
+
analyze_btn = gr.Button("Analyze Prescription", variant="primary", size="lg")
|
| 585 |
+
with gr.Column(scale=5):
|
| 586 |
+
pipeline = gr.HTML(pipeline_html(0))
|
| 587 |
+
|
| 588 |
+
with gr.Group(visible=False, elem_classes=["app-shell"]) as result_section:
|
| 589 |
+
gr.Markdown("## Medicine Result")
|
| 590 |
+
with gr.Row():
|
| 591 |
+
with gr.Column(scale=5):
|
| 592 |
+
details = gr.HTML()
|
| 593 |
+
gauge = gr.Plot(label="Confidence Gauge")
|
| 594 |
+
with gr.Column(scale=5):
|
| 595 |
+
package_image = gr.Image(label="Packaging Image", height=360, show_download_button=False)
|
| 596 |
+
stock = gr.HTML()
|
| 597 |
+
with gr.Accordion("Top Candidates", open=False):
|
| 598 |
+
candidates = gr.HTML()
|
| 599 |
+
gr.Markdown("### OCR vs Corrected")
|
| 600 |
+
comparison = gr.HTML()
|
| 601 |
+
locate_btn = gr.Button("Locate Medicine", variant="primary", size="lg")
|
| 602 |
+
locate_status = gr.Markdown()
|
| 603 |
+
|
| 604 |
+
with gr.Group(visible=False, elem_classes=["app-shell"]) as locator_section:
|
| 605 |
+
gr.Markdown("## Scan Shelf")
|
| 606 |
+
with gr.Row():
|
| 607 |
+
with gr.Column(scale=5):
|
| 608 |
+
shelf_image = gr.Image(
|
| 609 |
+
label="Shelf Image",
|
| 610 |
+
sources=["upload", "webcam"],
|
| 611 |
+
type="pil",
|
| 612 |
+
height=360,
|
| 613 |
+
)
|
| 614 |
+
locate_scan_btn = gr.Button("Find Box On Shelf", variant="primary")
|
| 615 |
+
with gr.Column(scale=5):
|
| 616 |
+
shelf_result_image = gr.Image(label="Detected Shelf Box", height=360, show_download_button=False)
|
| 617 |
+
shelf_result_info = gr.HTML()
|
| 618 |
+
|
| 619 |
+
analyze_btn.click(
|
| 620 |
+
analyze_prescription,
|
| 621 |
+
inputs=[rx_image],
|
| 622 |
+
outputs=[
|
| 623 |
+
live_metrics,
|
| 624 |
+
pipeline,
|
| 625 |
+
details,
|
| 626 |
+
package_image,
|
| 627 |
+
stock,
|
| 628 |
+
gauge,
|
| 629 |
+
candidates,
|
| 630 |
+
comparison,
|
| 631 |
+
result_section,
|
| 632 |
+
locate_btn,
|
| 633 |
+
state,
|
| 634 |
+
],
|
| 635 |
+
)
|
| 636 |
+
locate_btn.click(open_locator, inputs=[state], outputs=[locator_section, locate_status])
|
| 637 |
+
locate_scan_btn.click(locate_on_shelf, inputs=[shelf_image, state], outputs=[shelf_result_image, shelf_result_info])
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
if __name__ == "__main__":
|
| 641 |
+
import argparse
|
| 642 |
+
|
| 643 |
+
parser = argparse.ArgumentParser(description="Run the PharmaCopilot Gradio demo.")
|
| 644 |
+
parser.add_argument("--server-name", default="127.0.0.1")
|
| 645 |
+
parser.add_argument("--server-port", type=int, default=7860)
|
| 646 |
+
args = parser.parse_args()
|
| 647 |
+
|
| 648 |
+
demo.launch(server_name=args.server_name, server_port=args.server_port)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=5.12.0
|
| 2 |
+
plotly>=5.24.0
|
| 3 |
+
pillow>=10.0.0
|
training/baseline_eval/minicpm_v_4_5/baseline_minicpm_v_4_5_metrics.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"total_samples": 2510,
|
| 3 |
+
"completed_samples": 2510,
|
| 4 |
+
"ocr_accuracy": 0.37888446215139443,
|
| 5 |
+
"cer": 0.2619815874696351,
|
| 6 |
+
"retrieval_accuracy": 0.6055776892430279,
|
| 7 |
+
"canonical_match_accuracy": 0.6055776892430279,
|
| 8 |
+
"category_counts": {
|
| 9 |
+
"spelling_error": 893,
|
| 10 |
+
"completely_wrong": 400,
|
| 11 |
+
"ocr_failure": 169,
|
| 12 |
+
"partial_match": 52,
|
| 13 |
+
"brand_generic_mismatch": 45,
|
| 14 |
+
"correct": 951
|
| 15 |
+
}
|
| 16 |
+
}
|