npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@souscheflabs/ml-vision

v0.1.3

Published

ML-powered product detection for React Native - multi-barcode scanning, receipt OCR, and visual product recognition

Readme

@souscheflabs/ml-vision

npm version license TypeScript React Native

ML-powered product detection for React Native. Speed up kitchen inventory onboarding with multi-barcode scanning, receipt OCR, and visual product recognition.

Features

  • Multi-Barcode Scanning - Scan multiple barcodes from a single photo
  • Receipt OCR - Photograph grocery receipts to auto-extract items
  • Visual Product Recognition - Recognize fridge/pantry contents by appearance
  • Video Scanning - Real-time product detection from camera feed
  • On-Device ML - Fast inference using TFLite with GPU acceleration
  • Server Fallback - Optional server-side processing for better accuracy

Installation

npm install @souscheflabs/ml-vision
# or
yarn add @souscheflabs/ml-vision

Peer Dependencies

This package requires the following peer dependencies:

npm install react-native-vision-camera react-native-mmkv

For on-device ML inference (Phase 3+):

npm install react-native-fast-tflite

iOS Setup

cd ios && pod install

Add camera permissions to Info.plist:

<key>NSCameraUsageDescription</key>
<string>Camera is used to scan products and receipts</string>

Android Setup

Add camera permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

Quick Start

1. Wrap your app with the provider

import { MLVisionProvider } from '@souscheflabs/ml-vision';
import { MMKV } from 'react-native-mmkv';

// Create MMKV instance for caching
const storage = new MMKV({ id: 'ml-vision-cache' });

function App() {
  return (
    <MLVisionProvider
      config={{
        serverUrl: 'http://192.168.1.100:8000', // Optional: your ML server
        cacheEnabled: true,
      }}
      storage={storage}
    >
      <YourApp />
    </MLVisionProvider>
  );
}

2. Use the hooks in your components

import { useMultiBarcodeScanner } from '@souscheflabs/ml-vision';
import { Camera } from 'react-native-vision-camera';

function BarcodeScanScreen() {
  const {
    results,
    isScanning,
    startScanning,
    stopScanning,
    frameProcessor,
  } = useMultiBarcodeScanner({
    formats: ['ean-13', 'upc-a', 'qr'],
    maxBarcodes: 20,
    onDetected: (barcodes) => {
      console.log('Found barcodes:', barcodes);
    },
  });

  return (
    <Camera
      device={device}
      isActive={isScanning}
      frameProcessor={frameProcessor}
    />
  );
}

API Reference

MLVisionProvider

The context provider that must wrap your app.

<MLVisionProvider
  config={{
    serverUrl?: string;        // ML server URL for fallback
    serverTimeout?: number;    // Request timeout (default: 5000ms)
    cacheEnabled?: boolean;    // Enable result caching (default: true)
    cacheTTL?: number;         // Cache TTL in ms (default: 24 hours)
    enableGPUDelegate?: boolean; // Use GPU for inference (default: true)
  }}
  storage={mmkvInstance}       // MMKV instance for caching
  onInitialized={() => {}}     // Called when ready
  onError={(error) => {}}      // Called on init error
>

useMultiBarcodeScanner

Scan multiple barcodes from camera frames or photos.

const {
  // State
  isReady: boolean;
  isScanning: boolean;
  results: BarcodeDetectionResult[];
  error: Error | null;

  // Actions
  startScanning: () => void;
  stopScanning: () => void;
  scanPhoto: (uri: string) => Promise<BarcodeDetectionResult[]>;
  clearResults: () => void;

  // For VisionCamera
  frameProcessor: FrameProcessor;
} = useMultiBarcodeScanner(options);

useProductDetector

Detect products in images using trained ML models.

const {
  // State
  isModelLoaded: boolean;
  isDetecting: boolean;
  detections: ProductDetectionResult[];
  modelVersion: string;

  // Actions
  detectProducts: (uri: string) => Promise<ProductDetectionResult[]>;
  updateModel: () => Promise<void>;

  // For VisionCamera
  frameProcessor: FrameProcessor;
} = useProductDetector({
  model: 'fast' | 'accurate';
  minConfidence?: number;
  serverFallback?: boolean;
});

useReceiptScanner

Extract items from receipt photos.

const {
  // State
  isProcessing: boolean;
  items: ReceiptItem[];
  confidence: number;

  // Actions
  scanReceipt: (uri: string) => Promise<ReceiptScanResult>;
  confirmItem: (item: ReceiptItem) => void;
  rejectItem: (item: ReceiptItem) => void;
} = useReceiptScanner({
  serverFallback?: boolean;
  minConfidence?: number;
});

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Your React Native App                        │
├─────────────────────────────────────────────────────────────────┤
│  @souscheflabs/ml-vision                                            │
│  ├── Hooks (useMultiBarcodeScanner, useProductDetector, etc.)  │
│  ├── Frame Processors (barcode, OCR, TFLite detection)         │
│  └── CacheManager (MMKV-based caching)                         │
├─────────────────────────────────────────────────────────────────┤
│  On-Device Processing (fast, offline)                           │
│  ├── MLKit (barcodes, text recognition)                        │
│  ├── react-native-fast-tflite (custom models)                  │
│  └── CoreML/NNAPI delegates (GPU acceleration)                 │
├─────────────────────────────────────────────────────────────────┤
│  Server Fallback (accurate, requires network)                   │
│  ├── FastAPI inference server                                   │
│  ├── YOLOv8 full models                                        │
│  └── PaddleOCR for complex receipts                            │
└─────────────────────────────────────────────────────────────────┘

Training Your Own Models

See the Training Guide for instructions on:

  • Setting up the Docker training environment
  • Preparing your dataset
  • Training YOLOv8 models
  • Exporting to TFLite for mobile

Project Structure

packages/ml-vision/
├── src/
│   ├── index.ts              # Main exports
│   ├── types/                # TypeScript definitions
│   ├── hooks/                # React hooks
│   ├── core/                 # Provider, cache, server client
│   ├── processors/           # Frame processors
│   └── utils/                # Utilities
├── models/                   # Bundled TFLite models
├── docs/                     # Documentation
└── dist/                     # Compiled output

Development

# Build the package
npm run build

# Watch for changes
npm run watch

# Type check
npm run typecheck

License

ISC

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Make your changes
  4. Run tests and type checks
  5. Submit a pull request

Troubleshooting

Model Loading Fails on Android

Ensure the model file is in android/app/src/main/assets/. Metro bundler handles this automatically for .tflite files in the models/ directory.

Camera Permission Denied

Add the camera permission to your app and request it at runtime:

import { Camera } from 'react-native-vision-camera';

const permission = await Camera.requestCameraPermission();
if (permission === 'denied') {
  // Handle permission denied
}

Low Detection Accuracy

  1. Ensure good lighting conditions
  2. Try lowering minConfidence threshold
  3. Enable serverFallback for better accuracy on complex scenes

Build Errors with TFLite

If you encounter build errors with react-native-fast-tflite:

# iOS: Clean and rebuild
cd ios && pod deintegrate && pod install && cd ..

# Android: Clean gradle cache
cd android && ./gradlew clean && cd ..

Support