Spaces:
Running
A newer version of the Gradio SDK is available: 6.20.0
title: PillPal
emoji: π
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 6.16.0
python_version: '3.13'
app_file: server.py
pinned: false
license: mit
short_description: Photo a pill bottle, get a daily schedule + refill alert
models:
- openbmb/MiniCPM-V-4.6
tags:
- build-small-hackathon
- backyard-ai
- minicpm
- vision
- gradio
- healthcare
π PillPal
Photograph a pill bottle and get a clear daily schedule β plus a heads-up before you run out. A small vision model reads the label; everything else is plain, testable Python.
Built for the Build Small Hackathon Β· Backyard AI track β a real tool for a real person (a parent, neighbor, or anyone juggling medications).
Demo video
Model
- MiniCPM-V 4.6 (OpenBMB) via
the hosted MiniCPM-V API (
https://api.modelbest.cn/v1, OpenAI-compatible). The model has exactly one job: read the label and return JSON.
Targets the OpenBMB special award (built on MiniCPM models).
What we're targeting
Track: π‘ Backyard AI β solve a real problem for someone you actually know.
| Target | Status | How |
|---|---|---|
| π OpenBMB special award | π― | the label reader runs on MiniCPM-V 4.6 (OpenBMB) |
| π¨ Off-Brand | β | fully custom dashboard UI (upload β confirm β schedule), not default Gradio |
| π‘ Sharing is Caring | optional | could share a sample-label dataset / trace on the Hub |
| π Off the Grid | βοΈ n/a | uses the hosted MiniCPM-V API (switch PILLPAL_BACKEND=llama for a fully-offline run) |
| π¦ Llama Champion | βοΈ n/a | not a Llama model (available via the llama backend if desired) |
| π― Well-Tuned | βοΈ n/a | no fine-tuned model β uses MiniCPM-V as-is |
Why it fits the track
Medication mix-ups are a real, everyday problem. PillPal does one helpful thing well: turn a photo into a schedule and a refill warning. The AI is used narrowly (label β structured JSON); all the trust-critical logic β scheduling, run-out math β is deterministic Python you can unit-test, so it never invents dosing.
How it works
photo ββΊ MiniCPM-V reads the label ββΊ JSON ββΊ you confirm/correct ββΊ schedule + refill date
- Read β MiniCPM-V returns strict JSON:
drug_name, dose, frequency_text, quantity, refill_or_expiry_date. - Confirm β you check/correct the fields in the form.
- Schedule β
logic.pyturns the instruction into concrete times of day. - Refill β
logic.pyestimates the run-out date and warns if it's near.
- server.py β
gradio.Server: endpoints/read_label,/save_med,/delete_med,/clear_all,/state; serves the dashboard. - index.html β a custom dashboard UI (upload + read, confirm/correct form, today's schedule, light/dark theme).
- logic.py β
safe_parse,build_schedule,check_refill(the real work). - vision.py β label β JSON via the MiniCPM-V API (or local backends).
- storage.py β local JSON persistence (
meds.json).
Run locally
pip install -r requirements.txt
export PILLPAL_API_KEY=sk-... # your MiniCPM-V API key (or use a Space secret)
python server.py
Without a key, the label reader shows a friendly "enter details manually" message
and the rest of the app still works. Use PILLPAL_MOCK=1 for canned label data.
Test
pytest -q # logic tests, fully offline
Config (env vars)
| Var | Default | Purpose |
|---|---|---|
PILLPAL_API_KEY |
(none β set it) | MiniCPM-V API key (provide via env / Space secret) |
PILLPAL_API_MODEL |
MiniCPM-V-4.6-Instruct |
or MiniCPM-V-4.6-Thinking |
PILLPAL_API_URL |
https://api.modelbest.cn/v1/chat/completions |
MiniCPM-V endpoint |
PILLPAL_BACKEND |
api |
transformers (local/ZeroGPU) or llama (offline llama.cpp) |
PILLPAL_MOCK |
0 |
1 = canned label data, skip the model |
PILLPAL_STORE |
meds.json |
where the medication list is saved |
