--- license: agpl-3.0 library_name: ultralytics pipeline_tag: image-classification datasets: - Pramudit/Waste_SIP_Dataset metrics: - accuracy base_model: Ultralytics/YOLOv8 tags: - ultralytics - yolov8 - yolov8-cls - image-classification - waste-classification - waste-sorting - recycling --- # Waste Classifier (Bio vs Non-Bio) — YOLOv8s-cls A lightweight image classifier that sorts waste photos into **biodegradable (`Bio`)** and **non-biodegradable (`Non_Bio`)**. It is [YOLOv8s-cls](https://docs.ultralytics.com/tasks/classify/) fine-tuned from the COCO/ImageNet-pretrained checkpoint on the [Waste_SIP_Dataset](https://huggingface.co/datasets/Pramudit/Waste_SIP_Dataset). - **Task:** binary image classification - **Classes:** `Bio`, `Non_Bio` - **Architecture:** YOLOv8s-cls (~10 MB checkpoint) - **Input size:** 224 × 224 - **Best validation top-1 accuracy:** 0.96 (epoch 19 of 20) ## Quick start ```bash pip install ultralytics huggingface_hub ``` ```python from huggingface_hub import hf_hub_download from ultralytics import YOLO weights = hf_hub_download(repo_id="W4ashabii/waste_classifier", filename="best.pt") model = YOLO(weights) results = model.predict("your_image.jpg", imgsz=224) r = results[0] print(r.names[r.probs.top1], float(r.probs.top1conf)) ``` Batch prediction on a folder: ```python results = model.predict("path/to/images/", imgsz=224) for r in results: print(r.path, r.names[r.probs.top1], round(float(r.probs.top1conf), 3)) ``` ## Results Metrics from the validation split, using the best checkpoint (`best.pt`, epoch 19): | Metric | Value | |---|---| | Top-1 accuracy | **0.960** | | Final-epoch (20) top-1 accuracy | 0.955 | | Final training loss | 0.038 | Per-class recall (from the normalized confusion matrix): | Class | Recall | |---|---| | Bio | 0.97 | | Non_Bio | 0.95 | Top-5 accuracy is always 1.0 because there are only two classes, so it is not informative. Training lasted about 2.3 minutes (140 s for 20 epochs). ![Training curves](results.png) ![Normalized confusion matrix](confusion_matrix_normalized.png) > Note: `best.pt` was chosen by validation accuracy, so the validation numbers above are slightly optimistic. For an unbiased estimate, evaluate on the dataset's held-out `test` split. ## Training details | Setting | Value | |---|---| | Base model | `yolov8s-cls.pt` (pretrained) | | Framework | Ultralytics YOLOv8 | | Epochs | 20 (early-stopping patience 5) | | Image size | 224 | | Batch size | 64 | | Optimizer | AdamW | | Initial learning rate | 1e-3, cosine schedule | | Precision | FP16 mixed precision (AMP) | | Hardware | NVIDIA RTX 4070 (8 GB) | ## Dataset Trained on [Pramudit/Waste_SIP_Dataset](https://huggingface.co/datasets/Pramudit/Waste_SIP_Dataset), an image-folder dataset with `train`, `validation` and `test` splits and two classes (`Bio`, `Non_Bio`). Please refer to the dataset page for its license, collection method and class distribution. ## Intended use - Demos, teaching and prototyping of automated waste sorting - A baseline for waste-classification research - Starting point for further fine-tuning on your own waste images ## Limitations - **Binary only.** The model tells biodegradable from non-biodegradable. It does not identify material types (plastic, glass, metal, paper) and does not detect or locate objects in an image. - **Single-object assumption.** It classifies the whole image, so photos with mixed waste or cluttered scenes may give unreliable results. - **Domain shift.** Accuracy was measured on images from one dataset. Performance can drop with different cameras, lighting, backgrounds, or waste types that are rare in the training data. - **Not safety-critical.** Do not rely on it as the sole decision-maker for real waste handling, hygiene or compliance. ## License The weights are released under **AGPL-3.0**, in line with the Ultralytics YOLOv8 license. The training data has its own license; check the dataset page before commercial use. ## Citation ```bibtex @software{jocher2023ultralytics, author = {Jocher, Glenn and Chaurasia, Ayush and Qiu, Jing}, title = {Ultralytics YOLOv8}, version = {8.0.0}, year = {2023}, url = {https://github.com/ultralytics/ultralytics}, license = {AGPL-3.0} } ```