BinSprout Classifier
An image classifier that recognises common kitchen ingredients. It is part of BinSprout, an AI for Social Good project that helps students reduce food waste by identifying the ingredients they have and suggesting recipes.
Project code: https://github.com/imannajihahyuzli-stack/BinSprout.git
Model details
- Deployed model: built with Google Teachable Machine (image project)
- Base model: MobileNet, pre-trained on ImageNet, fine-tuned with transfer learning
- Format: TensorFlow.js (
model.json,metadata.json,weights.bin) - Input: a 224x224 RGB image (resized automatically by the
tmImagelibrary) - Output: a probability for each class
Classes (8)
Banana, Bread, Egg, Lettuce, Non-food, Onion, Potato, Tomato
The "Non-food" class contains backgrounds and other objects. It stops the model from guessing an ingredient when there isn't one.
Training data
- Photos taken by our team with phones, in different places, angles, and lighting, while also get from public datasets and stock photos from the internet
- About 515 photos in total (about 65 per class)
- Split: 80% training, 20% validation
Comparison model (trained in Google Colab)
Before choosing Teachable Machine for deployment, we trained our own model in Python to understand how the training works.
- Architecture: MobileNetV2 (ImageNet weights, frozen) + global average pooling + dropout (0.2) + dense softmax layer with 8 outputs
- Augmentation: random flip, rotation, zoom and brightness
- Training: 12 epochs, batch size 32, Adam optimiser
- Result: 94.1% validation accuracy (96 of 102 validation images correct), with training accuracy around 97.6%
- Why it was not deployed: the TensorFlow.js converter was incompatible with the current Colab TensorFlow and NumPy versions, so we used Teachable Machine for the website model.
Results
| Model | Accuracy | Notes |
|---|---|---|
| Teachable Machine (deployed) | to be tested after training | |
| Colab MobileNetV2 (comparison) | 94.1% | 102 validation images |
Most common mix-ups in the Colab model: non-food photos predicted as bread or egg (4 of 16 non-food images), and one bread/egg confusion each way. Bread and egg were often photographed on similar backgrounds, and the non-food class is very varied, so it is the hardest to learn. Banana, lettuce, onion, potato and tomato were all classified correctly.
Real-world test: we took 60-70 new photos per class with a phone that were not used in training, and the model got 9.4 out of 10 correct (94%).
How to use it
const model = await tmImage.load(
"https://huggingface.co/YOURNAME/binsprout-classifier/resolve/main/model.json",
"https://huggingface.co/YOURNAME/binsprout-classifier/resolve/main/metadata.json"
);
const predictions = await model.predict(imageElement);
Limitations
- Trained on a small dataset. Validation photos came from the same photo sessions as the training photos, so accuracy on new backgrounds and lighting will probably be lower.
- It only knows 8 classes. Anything else will be guessed as one of them.
- It classifies one item per photo.
- It is for awareness and learning, not a food safety check. When in doubt, throw it out.