Skip to main content

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:

  1. Install the library
  2. Initialise the model extender
  3. Upload your images (ZIP file via Colab file upload)
  4. Add your class and validate images
  5. Train the extended model
  6. 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

srilankan_food_trainer-0.2.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

srilankan_food_trainer-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file srilankan_food_trainer-0.2.1.tar.gz.

File metadata

  • Download URL: srilankan_food_trainer-0.2.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for srilankan_food_trainer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 03d1004fb95ee649d8a170245fb9c6390d14cc878acc0a5081ef47f2a5e959ef
MD5 da84869ddaf0a2ab8eeaf9fd3495631c
BLAKE2b-256 95f2297c846b7c3d86f4703aed35dd1d0be847493497fc13ea1c59bf3a158d02

See more details on using hashes here.

File details

Details for the file srilankan_food_trainer-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for srilankan_food_trainer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 254187a239bf7f33ee73bc014b81b8d94996e36ac6f5e86004f3f7b4810ba8ae
MD5 d06d596bf9a726b6910e50d9bc41de07
BLAKE2b-256 aac91eab91b51f5990c96307020465761fe0a75f804778997678cd77a785a54a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page