iany-waste-v1
An on-device waste-material classifier β point a camera at an item and get its material. A MobileNetV2 trained from open waste datasets, exported to ONNX to run in the browser via onnxruntime-web. Built for iAny, the offline, on-device Khmer AI platform.
Live now: try it at iany.app/waste-scan β fully on-device, nothing uploaded. Help improve it by contributing photos at iany.app/waste.
What it does
Classifies a single item's material into 7 types, for recycling education, correct sorting, and knowing what a waste-buyer will take.
Labels (output order β this order matters)
0 can
1 glass
2 organic
3 other
4 paper
5 plastic_bottle
6 plastic_other
labels.txt in this repo has the same order. Output is a softmax over these 7 classes.
Input / preprocessing (important)
- Input:
float32, shape[1, 224, 224, 3](NHWC). - Normalization: MobileNetV2 β scale pixels
[0,255] β [-1,1](i.e.x/127.5 - 1). - Center-crop the frame to a square before resizing to 224Γ224 for best results.
Usage
Python (onnxruntime)
import onnxruntime as ort, numpy as np
from PIL import Image
labels = ["can","glass","organic","other","paper","plastic_bottle","plastic_other"]
img = Image.open("item.jpg").convert("RGB").resize((224, 224))
x = (np.asarray(img, np.float32) / 127.5 - 1.0)[None] # [1,224,224,3], [-1,1]
sess = ort.InferenceSession("model.onnx")
probs = sess.run(None, {sess.get_inputs()[0].name: x})[0][0]
print(labels[int(probs.argmax())], float(probs.max()))
Browser (onnxruntime-web) β see src/lib/wasteOnnx.ts in iAny for a live-camera implementation.
Training data
Bootstrapped from open datasets:
- TrashNet (MIT)
- Drinking Waste Classification (Kaggle) β bottle / can / glass / HDPE
- techsash/waste-classification-data (Kaggle) β Organic images only
Base: MobileNetV2 (ImageNet weights). Trained with transfer learning (see the recipe below).
Limitations
- v1 / beta. Trained mostly on Western datasets β accuracy on Cambodian items, brands, and messy real litter is rougher. This improves as
/wastephotos are folded in and the model is retrained. - No
ewasteclass yet (not enough e-waste training images) β 7 of iAny's 8 material types. - Best on one item filling the frame, decent light. It's a suggestion, not an authoritative sorting decision.
Intended use
Recycling education and sorting guidance; the /waste-scan experiment; and pre-filling labels in the /waste data collector. Not a certified sorting or compliance system.
License & attribution
Released under CC-BY-4.0 β please credit the source datasets (TrashNet β MIT; others per their Kaggle terms) and iAny. Verify each source dataset's terms before commercial redistribution.
Credit & recipe
Trained and released by iAny (E-KHMER Technology). Full training + deploy recipe: github.com/sengtha/iAny Β· docs/WASTE-MODEL.md.