AI-Powered Handwriting App with Real-Time Gesture Recognition
Demo β’ Features β’ Structure β’ Architecture β’ Get Started
Handwritten note-taking apps force constant interruptionsβswitching tools, tapping buttons, navigating menus. Each micro-interaction breaks focus and slows you down.
OnePen eliminates toolbar dependency through real-time gesture recognition. Draw naturally, and ML interprets your intentβgrouping content, applying styles, or triggering app features instantly.
6 gesture modifiers recognized in real-time β instant formatting & actions
One pen. Zero interruptions. ~30% faster note-taking.
https://github.com/user-attachments/assets/a4335d94-51ff-4345-89c7-b58fddd72268
Try Live App β Β· Works offline after first load
OnePen/
βββ app/ # Progressive Web App (Frontend)
β βββ index.html # Main interface
β βββ main.js # Core app logic & gesture handling
β βββ draw.js # Canvas rendering engine
β βββ predict.js # TensorFlow.js inference
β βββ saveNote.js # IndexedDB persistence
β βββ signin.js # Google Drive authentication
β βββ feedbackCollector.js # Implicit feedback for data flywheel
β βββ config.js # App configuration
β βββ sw.js # Service worker (offline support)
β βββ tfjs/ # Deployed TF.js model
β βββ icons/ # PWA icons
β
βββ trainer/ # ML training pipeline (compact, self-contained)
β βββ data.py # raw JSON β 96Γ96 image + 12-D features (+ augment)
β βββ model.py # MobileNetV3-Small hybrid β 8-way softmax
β βββ train.py # load β train β evaluate β export (entry point)
β βββ export_tfjs.py # Keras β SavedModel β TF.js graph-model
β βββ Dockerfile # GPU image (TF 2.19) for Akash / any NVIDIA host
β βββ akash-deploy.yaml # Akash SDL to rent a GPU and run it
β
βββ data/raw/ # Raw stroke data by contributor (the dataset)
β
βββ assets/ # Documentation images
| ### Gesture Recognition - **7 gesture types** recognized in real-time - **Draw + Hold** opens radial tool menu - 1 delete gestures + 6 raw auto-style getures + 6 gestures + hold x 8 tools = **55 quick actions** - Fully customizable gesture-to-action mapping | ### Study Tools - **Tape Flashcards** β Cover keywords with decorative tape for active recall; tap to reveal. Each tape becomes a reviewable flashcard. - **Auto-Summaries** β Generate study sheets from highlights - **Table of Contents** β Auto-built from headings - **Reminders** β Time-based notifications |
| ### Smart Notes - **Sticky Notes** β Floating annotations with mini canvas - **Embed Links** β Clickable web previews - **Math Solver** β Handwritten β LaTeX β solved | ### Export & Sync - **Google Drive** auto-backup - **PDF Export** with full fidelity - **Offline-first** PWA architecture - **Cross-device** via portable JSON |
Hybrid CNN + Geometric Features β Combining visual and numerical inputs for robust gesture classification.
Image Input (96Γ96) Geometric Features (12D)
β β
βΌ βΌ
βββββββββββββββββββββ βββββββββββββββββββ
β MobileNetV3 β β Dense 128β64 β
β + SE Attention β β + LayerNorm β
βββββββββββ¬ββββββββββ ββββββββββ¬βββββββββ
β β
ββββββββββββββββ¬βββββββββββββββββββββ
βΌ
βββββββββββββββββββ
β Fusion Layer β
β 384 β 192 β
ββββββββββ¬βββββββββ
βΌ
βββββββββββββββββββ
β 8 Classes β
β (softmax) β
βββββββββββββββββββ
Why hybrid? Image-only models confused similar gestures (box vs bracket). Adding geometric features improved accuracy by 5-8%.
| Feature | Purpose |
|---|---|
| Closure ratio | Detects closed loops (boxes) |
| Aspect ratio | Distinguishes wide vs tall strokes |
| Path length | Identifies wavy/complex strokes |
| Verticality | Separates diagonal deletes from horizontal underlines |
| Point density | Distinguishes quick strokes from deliberate ones |
| + 7 more | Fine-grained disambiguation |
| Metric | Value |
|---|---|
| Accuracy | 99.89% |
| Inference | ~20ms |
| Model Size | 2.5 MB |
| Classes | 8 gesture types |
# Clone repository
git clone https://github.com/AndyHuynh24/OnePen.git
cd OnePen
# Run the app
cd app && python -m http.server 8000
# Open http://localhost:8000
The training pipeline lives in trainer/ β see trainer/README.md
for full docs (local, Docker, and Akash GPU).
cd trainer
pip install -r requirements.txt
python train.py --finetune # reads ../data/raw β writes ./out + app-v2/public/tfjs
# β¦or on a rented GPU via Docker (build from repo root):
docker build -f trainer/Dockerfile -t onepen-trainer .
docker run --gpus all -v "$PWD/out:/output" onepen-trainer --finetune
| Layer | Technologies |
|---|---|
| Frontend | JavaScript, HTML5 Canvas API, TensorFlow.js, IndexedDB, Web Workers |
| ML/AI | TensorFlow, Keras, MobileNetV3, Squeeze-and-Excitation Networks, Weights & Biases |
| Infrastructure | Progressive Web App (PWA), Service Workers, Firebase Hosting, Google Drive API |
| Quality | pytest, ruff, mypy, GitHub Actions CI/CD |
MIT
Built by Andy Huynh