Identify any resistor instantly — upload a photo, use your camera, or pick bands manually.
A clean, minimal web app that decodes resistor color bands. Runs fully offline using trained ONNX models, with an optional Gemini API fallback.
Photo → YOLOv8n (detects band bounding boxes) → resistance formula → result
Model trained on Google Colab (free T4 GPU), exported to ONNX. Zero API costs. Runs on CPU.
- AI photo detection — works in any lighting once models are trained
- Live camera — capture and analyze in one tap
- Manual band picker — live resistor SVG, 3/4/5/6-band support, updates in real time
- Auto band orientation — automatically flips reversed bands (gold/silver detected first)
- Correct resistance math — separate formulas per band count, tolerance and tempco display
- Offline-first — ONNX inference, no internet needed after setup
- Gemini override — toggle to use Gemini Vision AI instead of local models
git clone https://github.com/praneel7015/resist
cd resist
python -m venv .venv
source .venv/bin/activate # Windows: .\.venv\Scripts\Activate.ps1
pip install -r requirements.txtGet a free key at aistudio.google.com:
cp .env.example .env
# Edit .env: GEMINI_API_KEY=AIza...
python app.py# Place trained models in:
# inference/models/band_detector.onnx
# inference/models/band_classes.json
python app.py # auto-detects models and runs offlineYou can also check the "Use Gemini AI" toggle in the UI to override local detection and use the Gemini API instead.
The detection pipeline uses YOLOv8n to find where each band is on the resistor body (object detection).
Open notebooks/resist_train.ipynb in Google Colab.
Or open directly:
In Colab: Runtime → Change runtime type → T4 GPU
- Create a free account at roboflow.com
- Profile icon → Settings → Roboflow API → copy your key
- Paste it into the notebook cell
Dataset used: Resistor Band Detection — annotated resistor images with per-band bounding boxes and color labels.
The notebook (~25 minutes on T4) will:
- Download and inspect the dataset
- Train YOLOv8n for color detection
- Export model to ONNX
- Save files to your Google Drive
Copy from Google Drive → resist_models/ into your project:
resist/
└── inference/
└── models/
├── band_detector.onnx (~11 MB)
└── band_classes.json
Restart Flask — it will auto-detect the models and switch to offline mode.
resist/
├── app.py # Flask server — auto-selects local vs Gemini
├── requirements.txt
├── Dockerfile
├── .env.example
├── notebooks/
│ └── resist_train.ipynb # Full Colab training notebook
├── inference/
│ ├── detector.py # ONNX inference — YOLOv8 pipeline
│ └── models/ # Put your .onnx files here (not in git)
├── templates/
│ └── index.html
└── static/
├── style.css
└── app.js
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Only without local models | Free key from aistudio.google.com |
PORT |
No | Server port (default 8080 in Docker, 5000 local) |
docker build -t resist .
docker run -p 8080:8080 resist
# Add -e GEMINI_API_KEY=... if using Gemini fallbackApp Runner scales near-zero when idle.
- Push to GitHub
- AWS Console → App Runner → Create service
- Source: Repository → connect GitHub → select this repo
- Build: Dockerfile (auto-detected)
- Port:
8080 - Environment variable:
GEMINI_API_KEY(only needed without local models) - Health check:
/health - Deploy — auto-redeploys on every push to main
Add mangum to requirements.txt, then:
# bottom of app.py
from mangum import Mangum
handler = Mangum(app)- Manual band picker (3–6 bands, live SVG preview)
- Camera capture mode
- Gemini Vision API integration
- YOLOv8 pipeline (Colab notebook)
- ONNX export for zero-dependency inference
- Auto band orientation (flips reversed gold/silver)
- Gemini override toggle in UI
- Ohm's law calculator
- LED resistor calculator (supply voltage + LED specs → resistor value)
- Voltage divider calculator
- Series / parallel resistance calculator
- E12 / E24 / E96 nearest standard value finder
- SMD resistor code decoder
- Scan history
- Good even lighting — avoid shadows across the bands
- Plain background (white or black) behind the resistor
- Get close so the resistor body fills most of the frame
- If confidence shows "low", try the Manual tab or toggle on Gemini AI
Pull requests welcome. If you've improved the training pipeline or have a better dataset, please open an issue first.
MIT — see LICENSE