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

plant-health-lib

v1.0.1

Published

A comprehensive React Native library for plant disease detection using TensorFlow Lite

Readme

🌿 plant-health-lib

A comprehensive React Native library for on-device plant disease detection. Point the camera at a leaf (or upload a photo) and a quantized TFLite model classifies 38+ crop diseases — fully offline, no backend.

Installation

npm install plant-health-lib
# or
yarn add plant-health-lib

Quick Start

Complete UI (One-liner setup)

import { UI } from 'plant-health-lib';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { SafeAreaProvider } from 'react-native-safe-area-context';

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <SafeAreaProvider>
        <UI.HistoryProvider>
          <UI.RootNavigator />
        </UI.HistoryProvider>
      </SafeAreaProvider>
    </GestureHandlerRootView>
  );
}

Building Custom UI

import { useFrameClassifier, useHistory } from 'plant-health-lib/hooks';
import { getDiseaseInfo } from 'plant-health-lib/services';
import { classifyImage } from 'plant-health-lib/utils';

Features

  • 38+ Disease Classes – Comprehensive crop disease database
  • TensorFlow Lite Integration – Fast GPU-accelerated inference
  • Live Camera Detection – Real-time classification from camera frames
  • Offline Operation – No backend required, fully on-device
  • TypeScript Support – Full type safety included
  • History Tracking – AsyncStorage-backed scan history

Stack

| Concern | Library | |---|---| | AI inference | react-native-fast-tflite (GPU/CoreML delegates) | | Camera + live frames | react-native-vision-camera + vision-camera-resize-plugin | | Frame-processor threading | react-native-worklets-core, react-native-reanimated | | Navigation | @react-navigation/native-stack | | Persistence | @react-native-async-storage/async-storage | | Gallery upload | react-native-image-picker |

Architecture

App.tsx                      warms up the model on launch
src/
  navigation/RootNavigator   Home → Scan → Result, + History
  screens/
    HomeScreen               dashboard, recent scans, entry points
    ScanScreen               live camera w/ throttled frame classification + capture/upload
    ResultScreen             diagnosis, confidence, treatment, prevention, top-K
    HistoryScreen            saved scans
  services/
    classifier.ts            loads .tflite, normalizes input, runs inference, softmax + top-K
    diseaseData.ts           38-class label map + remedy/prevention knowledge base
  hooks/
    useFrameClassifier.ts    vision-camera frame processor → resize (GPU) → TFLite on worklet
    useHistory.ts            AsyncStorage-backed scan history
  utils/imageToTensor.ts     still-image decode + resize to 224×224×3
  components/ui.tsx          Card, Button, SeverityBadge, ConfidenceBar
  theme/                     design tokens

Two inference paths: live camera frames run through the GPU resize plugin inside a worklet (fast, ~1 fps throttled); still captures/uploads go through imageToTensor. Both feed the same classifier.classify().

Usage

Using the Complete UI (Recommended)

The library exports complete screens ready to use. Just wrap your app with the providers:

import { UI } from 'plant-health-lib';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { SafeAreaProvider } from 'react-native-safe-area-context';

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <SafeAreaProvider>
        <UI.HistoryProvider>
          <UI.RootNavigator />
        </UI.HistoryProvider>
      </SafeAreaProvider>
    </GestureHandlerRootView>
  );
}

Using Individual Screens

import { 
  HomeScreen, 
  ScanScreen, 
  ResultScreen, 
  HistoryScreen, 
  RootNavigator,
  HistoryProvider 
} from 'plant-health-lib/screens';

Using the Frame Classifier Hook (Live Camera)

import { useFrameClassifier } from 'plant-health-lib/hooks';
import { getDiseaseInfo } from 'plant-health-lib/services';

export function ScanComponent() {
  const { classify, isLoading, lastResult } = useFrameClassifier();

  useEffect(() => {
    if (lastResult) {
      const disease = getDiseaseInfo(lastResult.label);
      console.log(`Detected: ${disease.name} (${lastResult.confidence}%)`);
    }
  }, [lastResult]);

  return (
    <CameraView
      onFrame={(frame) => classify(frame)}
      // ... camera props
    />
  );
}

Using the History Hook

import { useHistory } from 'plant-health-lib/hooks';

const { scans, addScan, clearHistory } = useHistory();

Classifying Images

import { classifyImage } from 'plant-health-lib/utils';
import { classifier } from 'plant-health-lib/services';

const result = await classifyImage(imagePath);
// result: { label: string; confidence: number; }

API Reference

Hooks

  • useFrameClassifier() – Real-time frame classification from camera

    • Returns: { classify(frame), isLoading, lastResult }
  • useHistory() – Manage scan history with AsyncStorage

    • Returns: { scans, addScan(result), clearHistory() }

Services

  • classifier.classify(tensor) – Classify a TensorFlow tensor
  • getDiseaseInfo(label) – Get remedy/prevention data for a disease

Utils

  • classifyImage(path) – Load and classify a still image from file path

Components

  • <Card /> – Styled card component
  • <Button /> – Button component
  • <SeverityBadge /> – Disease severity indicator
  • <ConfidenceBar /> – Confidence visualization

UI Screens (from plant-health-lib/screens or plant-health-lib/UI)

  • RootNavigator – Complete navigation stack (Home → Scan → Result → History)
  • HomeScreen – Dashboard with scan entry points and recent scans
  • ScanScreen – Live camera detection UI
  • ResultScreen – Diagnosis, treatment, and prevention display
  • HistoryScreen – Saved scans list

UI Convenience Module

import { UI } from 'plant-health-lib';

// UI.HistoryProvider - Context provider for history management
// UI.RootNavigator - Full app navigator
// UI.HomeScreen, UI.ScanScreen, UI.ResultScreen, UI.HistoryScreen
// UI.useHistory, UI.useFrameClassifier, UI.classifier, UI.getDiseaseInfo

Setting Up the Model

The library expects src/assets/plant_disease_model.tflite:

  • Input: [1, 224, 224, 3] float32
  • Output: [1, 38] (logits or probabilities)
  • Labels: Must match LABELS in src/services/diseaseData.ts

Train on PlantVillage dataset using MobileNetV2 or EfficientNet-Lite, then convert with TFLite converter. See src/assets/README.md for details.

Building from Source

npm install
npm run build

The compiled library will be in lib/.

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT

Notes / Production Hardening

  • The remedy text is general guidance — maintain an on-screen disclaimer; it's not a substitute for professional agricultural advice.
  • For production, replace the JS image resampler with a native bitmap decoder for better performance.
  • Tune MEAN/STD in classifier.ts to match your training normalization.