This monorepo contains two minimal apps that demonstrate TensorFlow.js:
web/— Vite + React (runs @tensorflow-models/mobilenet in browser)mobile/— Expo React Native (runs @tensorflow/tfjs-react-native + mobilenet on-device)
The goal is to show breadth: same ML concept (image classification) implemented in both web and mobile with shared UI ideas.
tfjs-monorepo/
├─ web/ # Vite + React web app
└─ mobile/ # Expo React Native app
Features
- Upload an image, run mobilenet inference in browser (WebGL/CPU)
- Display top-3 predictions
Run
cd web
npm i
npm run devThen open the printed localhost URL.
Features
- Pick image from camera roll
- Load mobilenet via @tensorflow/tfjs + @tensorflow/tfjs-react-native
- Run on-device inference and show top-3 predictions
Run (Expo)
cd mobile
npm i
# Prebuild native code (ensures GL + deps are installed)
npx expo prebuild
# Start the app
npx expo startOpen on iOS/Android via the Expo app or simulator.
Notes:
tfjs-react-nativeuses a custom backend; first load may take a few seconds.- Ensure you accept camera roll permissions when picking an image.
- Swap mobilenet with a custom TFJS graph model
- Add live camera preview classification
- Share preprocessing utils between web and mobile (e.g., as a small local package)
- Add e2e tests (Cypress for web, Detox for mobile)
MIT © 2025