Waste Classifier AI
Dataset Structure
Place your dataset in a directory like:
waste_dataset/
βββ biodegradable/
β βββ img1.jpg
β βββ ...
βββ non_biodegradable/
βββ img2.jpg
βββ ...
Training the Model
- Install dependencies:
pip install -r requirements.txt - Run the training script:
This will save the model and processor topython train_waste_classifier.pymodels/waste_classifier_model/.
Running the API
- Start the Flask API:
python waste_classification_api.py - The API will be available at
http://localhost:5000/classify.
API Usage
- Endpoint:
/classify(POST) - Payload: Multipart form with one or more images (field name:
images) - Response:
{ "results": [ { "label": "biodegradable", "confidence": 0.94, "description": "Easily breaks down naturally. Good for composting.", "recyclable": false, "disposal": "Use compost or organic bin", "example_items": ["banana peel", "food waste", "paper"] }, ... ] }
Frontend Integration
- The React Native frontend can POST images to
/classifyand display the results using the modal. - No changes are needed to the modal if it expects the above JSON structure.
Notes
- If your dataset folders are named differently (e.g.,
RandO), update the LABEL2INFO mapping and class names in the training script. - The model is based on
google/vit-base-patch16-224and fine-tuned for binary classification.