Back to Projects

Neural Bite - AI-Powered Nutrition & Food Quality Inspection Mobile App

An Android app combining RAG-based and computer vision with explainable AI.

FREELANCEBuilt during: Android & AI Developer / System Architect
Tags -
Software ApplicationAndroidJetpack ComposeKotlinTensorFlow LiteComputer VisionYOLOMobileNetV2Hugging FaceLLMRetrieval-Augmented GenerationRoom Database
Neural Bite - AI-Powered Nutrition & Food Quality Inspection Mobile App Preview

Project Overview

Neural Bite is a cutting-edge Android application that leverages AI to help users make informed dietary choices and assess food quality.

The app features a Personal AI Nutritionist powered by Retrieval-Augmented Generation (RAG), which provides context-aware, evidence-based nutritional guidance tailored to the user's health profile and scan history.

The AI Freshness Scanner uses a multi-stage computer vision pipeline (YOLO detection + MobileNetV2 classification + OOD detection) to identify fruit type and condition with high accuracy, and visualizes decision areas via attention heatmaps.

Built with modern Android technologies (Jetpack Compose, Material 3, MVVM, Room, Retrofit), the app ensures a smooth, responsive user experience with light/dark mode support.

The complete ML pipeline includes data preparation, YOLO training for fruit detection, MobileNetV2 training for fruit/condition classification, and Mahalanobis distance-based out-of-distribution detection for rejecting non-target objects.

All models are quantized to TFLite format for on-device inference, ensuring privacy and low latency (under 600ms for multi-fruit scenes).

Key Features

  • Personal AI Nutritionist (RAG) — Context-aware chat assistant using Retrieval-Augmented Generation with Hugging Face LLM and embeddings. It remembers user age, gender, health conditions, and previous scan results to provide tailored, verified nutritional advice grounded in a local knowledge base.
  • AI Freshness Scanner — Real-time fruit quality analysis for 5 fruit types (Apple, Banana, Grape, Mango, Orange). Detects condition: Fresh, Rotten, or Formalin-mixed using a YOLO + MobileNetV2 multi-head architecture.
  • Attention Heatmaps (Explainable AI) — Visualizes the AI's focus areas via an integrated attention head that produces 14×14 heatmaps, showing exactly where the model detected quality issues or identifying features.
  • Out-of-Distribution (OOD) Detection — Rejects non-target objects (e.g., non-fruit items) using Mahalanobis distance on 1280-dimensional feature vectors, preventing false positives and ensuring reliability.
  • Image Quality Assessment — Pre-flight checks for blur, brightness, and resolution to guide users for optimal scanning conditions, improving overall accuracy.
  • Personalized Health Profile — Stores user health data (age, gender, conditions) locally via Room database, enabling personalized dietary recommendations from the AI nutritionist.
  • Multi-Fruit Support — Detects and classifies multiple fruits in a single image simultaneously, with individual results for each fruit crop.
  • Modern UI/UX — Built with Jetpack Compose and Material 3, featuring fluid animations, light/dark themes, and a fresh green aesthetic for an engaging user experience.

Technical Highlights

  • Retrieval-Augmented Generation (RAG) — Integrates Hugging Face inference API for LLM and embeddings, enabling contextual, evidence-based nutritional chat that references a local knowledge base and user context.
  • Multi-Stage Computer Vision Pipeline — Combines YOLOv8-nano for fruit detection (trained on 10,154 images) and a custom multi-head MobileNetV2 for fruit/condition classification + attention output. Quantized to INT8 TFLite for mobile efficiency.
  • Explainable AI with Attention Maps — An additional head in the classifier learns a 14×14 spatial attention map, approximating Grad-CAM without backprop, providing visual interpretability of model decisions.
  • Out-of-Distribution Detection — Uses Mahalanobis distance with per-class centroids and precision matrices computed from training features, calibrated with a threshold to reject non-fruit inputs.
  • On-Device Inference — All models are compressed to 3 MB each (quantized), with inference time ~300-500ms for YOLO and ~50-100ms per crop for classifier, total <600ms for 3 fruits on Snapdragon 765G.
  • MVVM Architecture with DI — Clean separation of concerns with ViewModels, Repositories, and manual dependency injection, making the code testable and maintainable.
  • Jetpack Compose & Material 3 — Modern declarative UI toolkit for building responsive, adaptive interfaces with built-in theming and dynamic color support.

Challenges & Solutions

Challenge: Training YOLO for fruit detection with limited labeled bounding boxes; manual annotation would be expensive and time-consuming.
Solution: Automated YOLO annotation using HSV color segmentation for each fruit type, generating tight bounding boxes programmatically. Fallback to full image for edge cases, reducing manual work to zero.
Result: 10,154 YOLO annotations generated in minutes; model achieved mAP50 > 0.85 on test set.
Challenge: Achieving high classification accuracy for subtle conditions (e.g., formalin-mixed vs. fresh) while keeping model lightweight for mobile.
Solution: Used two-phase training: freeze MobileNetV2 backbone and train heads first, then unfreeze with discriminative learning rates. Aggregated attention loss to regularize and improve interpretability. Quantized to INT8 with minimal accuracy loss.
Result: Fruit classification accuracy > 95%, condition accuracy > 85% on test set; TFLite model size only 3 MB.
Challenge: Preventing false positives on non-fruit objects (e.g., hands, tables) in camera input.
Solution: Implemented OOD detection using Mahalanobis distance on 1280-dimensional feature vectors from the classifier backbone. Calibrated threshold on validation set with synthetic OOD samples.
Result: OOD rejection rate > 90% while maintaining > 95% true positive rate on target fruits.
Challenge: Maintaining real-time performance (under 1s) for multi-fruit images on various Android devices.
Solution: Quantized models to INT8, optimized image preprocessing (bitmap operations), used GPU delegate when available, and implemented efficient NMS. Parallelized classifier inference for multiple crops.
Result: Total inference time under 600ms for typical 3-fruit scenes on Snapdragon 765G, acceptable for real-time use.

Tech Stack Breakdown

frontend

Android (Kotlin), Jetpack Compose, Material 3, ViewModel, LiveData/Flow

backend

Hugging Face Inference API (LLM + embeddings), Retrofit, OkHttp

local_storage

Room Database (SQLite) for user profiles and chat history

ml_models

TensorFlow Lite (YOLOv8-nano for detection, custom MobileNetV2 multi-head for classification+attention+OOD features)

ml_development

PyTorch, ultralytics (YOLO), OpenCV, scikit-learn, NumPy

tools

Android Studio, Git, Gradle, Kaggle (model training), ONNX, TensorFlow Converter

deployment

Signed APK, Google Play Store (planned)