Easy-to-use library for extending Sri Lankan food recognition models
Project description
🍛 Sri Lankan Food Trainer
Easy-to-use Python library for extending the Sri Lankan Food Recognition model with your own vegetable classes!
Installation
pip install srilankan-food-trainer
Quick Start
from srilankan_food_trainer import FoodModelExtender
# 1. Create extender (downloads pre-trained model automatically)
extender = FoodModelExtender(verbose=True)
# 2. Add your class (ZIP filename = class name)
# e.g. potato_tempered.zip → class name becomes "potato_tempered"
extender.add_class("potato_tempered", "potato_tempered.zip", auto_extract=True)
# 3. Train (preserves original 8 classes + adds your new one)
extender.train(epochs=50)
# 4. Save
extender.save("extended_model.pth")
The saved model will contain all 9 classes (original 8 + your new one).
How It Works
This library uses transfer learning on top of the pre-trained prototypical network published at ranasinghehashini/srilankan-food-recognition.
- The pre-trained model already knows how to recognise 8 vegetable-state combinations from Sri Lankan cuisine
- When you add a new class, the model reuses its existing transformation-invariant features
- Training only learns to distinguish the new class — the original 8 classes are preserved
Image Requirements
| Requirement | Details |
|---|---|
| Minimum images | 20 per class |
| Recommended | 30–50 per class |
| Format | JPG or PNG |
| Resolution | Minimum 224×224 |
| Packaging | All images inside a folder, zipped |
| ZIP naming | ZIP filename = class name (e.g. potato_tempered.zip) |
Pre-trained Model — Original 8 Classes
The model this library extends was trained on:
| # | Class |
|---|---|
| 1 | carrot_raw |
| 2 | carrot_white_curry |
| 3 | greenbeans_raw |
| 4 | greenbeans_tempered |
| 5 | greenbeans_white_curry |
| 6 | pumpkin_raw |
| 7 | pumpkin_red_curry |
| 8 | pumpkin_white_curry |
Base model accuracy: 90.25% validation / 84.91% full test / 87.75% few-shot test
Full Example (Google Colab)
The complete step-by-step tutorial is available as a Colab notebook:
📓 Sri_Lankan_Food_Trainer_Tutorial_Enhanced.ipynb
Steps covered:
- Install the library
- Initialise the model extender
- Upload your images (ZIP file via Colab file upload)
- Add your class and validate images
- Train the extended model
- Save and download the extended model
Requirements
- Python 3.8+
- PyTorch 2.0+
- GPU recommended (CPU works but training will be slower)
- Internet connection for first run (downloads pre-trained model from Hugging Face)
License
MIT License — see LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file srilankan_food_trainer-0.2.0.tar.gz.
File metadata
- Download URL: srilankan_food_trainer-0.2.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61ddd705c143c0493671c74af4c8249e7809a88e11c1b04ea5eaf2c8dae6f9bf
|
|
| MD5 |
cbc8ac782221ca48e7bb3b99a910ebb7
|
|
| BLAKE2b-256 |
e5a81d7aa678af0f0f1c081a1bc31d8294c2cf1b03e25ec4791be5165c41f583
|
File details
Details for the file srilankan_food_trainer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: srilankan_food_trainer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94c95ee4ac964f0abf9ee36bb0037cd635d786e90e87a13c74b3968195af47d5
|
|
| MD5 |
6269a641d76deb53bc3f374c47e0f50d
|
|
| BLAKE2b-256 |
49a51417ded230812f8089184e064c1bc6e5153d940f50bd6db7de18b6dca7d4
|