A multimodal AI system to digitize medication instructions with 100% offline reliability, mitigating clinical errors in low-resource settings.
π Winner: Best Poster Presenter, NIRAMAYA Conference (2026)
- 100% Offline Processing - Works perfectly without internet connection
- Instant Results - <1 second processing time
- Privacy-First - All data stays on your device by default
- Zero Cost - No API charges for normal operation
- Dual-Layer Offline Pipeline - Combines ML Kit for text recognition with a custom computer vision validation module.
- Interpretable Computer Vision - Hand-engineered marker detection using dual-axis spatial projection histograms, adaptive ROI localization (silver foil segmentation), and valley-splitting peak detection.
- Gemini 2.0 Flash - Optional cloud enhancement for complex cases
- TensorFlow.js - 1024-dimensional visual embeddings for medication matching
- Fuzzy Matching - Spell-corrects OCR errors against medication database
- Multi-image scanning (front + back of packaging)
- Handwritten dosage detection (circles, loops, marks)
- Grid layout detection (2x5, 3x7, etc.)
- Visual medication matching
- Nepali/English support
- Medication reminders & scheduling
- English - Full support
- Nepali - Full support (Devanagari script)
- Dosage pattern detection for both languages
- Context-aware timing extraction ("ΰ€ΰ€Ύΰ€¨ΰ€Ύ ΰ€ͺΰ€ΰ€Ώ" / "after food")
- β Offline-first: No data sent to cloud by default
- β Local storage: All medications stored on-device
- β No tracking: No analytics or telemetry
- β Optional cloud: Explicit user consent required
- β Medical data: Complies with privacy best practices
πΈ Scan Blister Pack Image
β
π Layer 1: ML Kit OCR (Extract Text / Brand / Instructions)
β
ποΈ Layer 2: Custom CV Validation (Spatial Histograms for Handwritten Marks)
β
π§ Offline Parser + Fuzzy Matching (Reconcile OCR & CV outputs)
β
β
Return Results (<1 second total)
β
πΎ Save to Local Database (WatermelonDB)
// For complex cases, users can manually enhance:
import { enhanceWithCloudAI } from '@/services/ai/ocr';
const enhanced = await enhanceWithCloudAI(imageUri, currentData);
console.log(`Confidence improved by ${(enhanced.confidence - currentData.confidence) * 100}%`);- React Native - Cross-platform mobile framework
- Expo - Development tooling and SDK
- TypeScript - Type-safe JavaScript
- Expo Router - File-based navigation
- @google/generative-ai - Gemini 2.0 Flash (optional cloud)
- @tensorflow/tfjs - Machine learning in JavaScript
- @tensorflow/tfjs-react-native - TensorFlow for React Native
- @react-native-ml-kit/text-recognition - Offline OCR
- @nozbe/watermelondb - Offline-first reactive database
- zustand - Lightweight state management
- @react-native-async-storage/async-storage - Persistent storage
- nativewind - Tailwind CSS for React Native
- react-native-reanimated - Smooth animations
- expo-notifications - Local medication reminders
- expo-haptics - Tactile feedback
- Node.js 18+ and npm
- Expo CLI
- iOS Simulator or Android Emulator (or physical device)
-
Clone and install dependencies
cd PillReminder npm install -
Start the development server
npx expo start
-
Run on device
- Press
ifor iOS simulator - Press
afor Android emulator - Scan QR code with Expo Go app on physical device
- Press
Create a .env file in the root directory:
# Optional: Only needed if enabling cloud enhancement
EXPO_PUBLIC_GEMINI_API_KEY=your_api_key_hereNote: App works fully without this key (offline-only mode).
// services/ai/config.ts
const DEFAULT_CONFIG = {
processingMode: 'offline-only', // No cloud by default
logPerformance: true, // Track processing times
trackOfflineAccuracy: true, // Collect data for model training
};import { setAIConfig } from '@/services/ai/config';
await setAIConfig({
processingMode: 'allow-cloud-enhancement'
});- Enable airplane mode on your test device
- Open PillReminder app
- Scan a medication image
- Verify instant results without errors
Expected: Processing completes in <1 second with no network errors.
PillReminder/
βββ app/ # Expo Router screens
β βββ camera.tsx # Medication scanning
β βββ modal.tsx # Add/edit medication
β βββ alarm.tsx # Medication reminders
β βββ ...
βββ services/
β βββ ai/
β β βββ ocr.ts # Main AI processing (offline-first)
β β βββ config.ts # AI preferences & metrics
β β βββ vision-matcher.ts # 1024-dim embeddings
β β βββ marker-detector.ts # Handwriting CV
β β βββ offline-parser.ts # Text parsing
β β βββ medication-db.ts # Fuzzy matching
β βββ db/ # WatermelonDB models
β βββ scheduler.ts # Notification scheduling
βββ components/ # Reusable UI components
βββ lib/ # Utilities & state
| Metric | Target | Actual |
|---|---|---|
| Processing Time (Offline) | <1s | ~800ms β‘ |
| Processing Time (Online) | <5s | ~3-4s |
| Offline Accuracy (Simple) | >80% | ~85% |
| Offline Accuracy (Complex) | >70% | ~75% |
| Cloud Accuracy | >90% | ~95% |
Metrics tracked automatically via config.ts
The app tracks offline processing metrics for future improvements:
// Automatically logged
interface ProcessingMetrics {
timestamp: number;
processingTime: number;
confidence: number;
mode: 'offline' | 'online';
medicationName: string;
}Roadmap:
- Collect 1000+ medication scans with user corrections
- Train specialized OCR model for medication packaging
- Fine-tune handwriting detection for local practices
- Deploy updated TensorFlow.js model
# iOS: Rebuild with camera permissions
npx expo prebuild --clean
npx expo run:ios- Check device specs (needs TensorFlow.js support)
- Reduce image size in camera settings
- Verify ML Kit is installed correctly
# Rebuild with proper types
rm -rf node_modules
npm install
npx expo start --clearThis project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini - Multimodal AI capabilities
- TensorFlow.js - Edge ML framework
- ML Kit - Fast offline OCR
- Expo - Development platform
For questions, support, or to contribute, please visit the GitHub Repository and open an issue.
Built with β€οΈ for improving medication safety in low-resource settings