A neural network trained from scratch that tells cats from dogs live from the camera, inside the browser and with no backend.
- Discipline
- Machine learning
- Year
- 2025
- Stack
- Python
- TensorFlow
- Keras
- OpenCV
- TensorBoard
- TensorFlow.js
- WebRTC
- JavaScript
- Vercel
- ~86%validation accuracy

The problem
Taking a classification model from the notebook to something anyone can use in the browser.
How I solved it
Data
23,000+ imagesI compared a dense model and two CNNs trained from scratch on more than 23,000 images. The final one has 3 convolutional layers, Dropout and data augmentation (rotation, zoom, shifts and flips), with experiments tracked in TensorBoard.
Training
TensorFlow · KerasThe model is exported to TensorFlow.js and runs in the browser itself, with the same preprocessing as in training: crop, 100×100 px, greyscale and normalisation.
Browser
TensorFlow.jsContinuous classification from the camera through WebRTC, about 7 predictions per second, freeing tensor memory as it goes. No server: images never leave the device.
Result
A public demo that tells cats from dogs live with ~86% validation accuracy (the dense model stayed at ~50%), with a confidence meter, an "unsure" state and camera switching.
Need something similar?