Object Detection
ultralytics
vision
yolo
yolo11
waste-classification
recycling
circular-economy
environmental
Instructions to use Ank0805/waste-classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use Ank0805/waste-classification with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("Ank0805/waste-classification", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Ank0805/waste-classification: direct link, hf CLI and curl.
- Browser
- Download file 9.13 kB
-
https://huggingface.co/Ank0805/waste-classification/resolve/main/README.md
- Command line
-
hf download hf://Ank0805/waste-classification/README.md
-
curl -L -o README.md https://huggingface.co/Ank0805/waste-classification/resolve/main/README.md
9.13 kB
| license: mit | |
| tags: | |
| - object-detection | |
| - vision | |
| - yolo | |
| - yolo11 | |
| - ultralytics | |
| - waste-classification | |
| - recycling | |
| - circular-economy | |
| - environmental | |
| library_name: ultralytics | |
| pipeline_tag: object-detection | |
| # YOLO11n Granular Waste Material Classifier (42 Classes) | |
| ## Model Summary | |
| This repository provides an optimized YOLO11 nano-architecture object detection model trained for granular classification and spatial localization of solid municipal refuse across 42 discrete material categories. | |
| The model is specialized in distinguishing subtle visual differences among polymers, cellulosic fibers, ferrous and non-ferrous metals, mineral glass, and composite packaging. Operating at a native resolution of 640x640 with 2.59 million parameters and 6.5 GFLOPs, it is designed for edge and embedded robotic sorting applications, municipal collection analysis, and high-throughput conveyor inspection. | |
| ## Model Details | |
| * **Architecture**: Ultralytics YOLO11n (Decoupled anchor-free detection head, C3k2, SPPF, C2PSA) | |
| * **Task**: 2D Bounding Box Object Detection and Multi-Class Material Categorization | |
| * **Input Dimensions**: 640 x 640 x 3 (RGB) | |
| * **Parameters**: 2,590,425 | |
| * **GFLOPs**: 6.5 | |
| * **Framework**: PyTorch / Ultralytics | |
| ## Granular Material Taxonomy (42 Classes) | |
| The model discriminates among the following 42 material classifications: | |
| | Class ID | Class Name | Material Category | | |
| |:---|:---|:---| | |
| | `0` | `Aerosols` | Pressurized metallic spray canisters | | |
| | `1` | `Aluminum can` | Non-ferrous aluminum beverage containers | | |
| | `2` | `Aluminum caps` | Stamped aluminum closures and twist tops | | |
| | `3` | `Cardboard` | Corrugated and rigid fiberboard packaging | | |
| | `4` | `Cellulose` | Pure cellulosic fiber and cellulose-derived packaging | | |
| | `5` | `Ceramic` | Vitrified ceramics, porcelain, and clay fragments | | |
| | `6` | `Combined plastic` | Multi-layer or composite polymer structures | | |
| | `7` | `Container for household chemicals` | High-Density Polyethylene (HDPE) detergent/chemical bottles | | |
| | `8` | `Disposable tableware` | Single-use plastic and paper cutlery, plates, and trays | | |
| | `9` | `Electronics` | Circuit boards, e-waste, wiring, small electronic appliances | | |
| | `10` | `Foil` | Thin aluminum foil and metallic wrapping sheets | | |
| | `11` | `Furniture` | Discarded domestic and industrial composite furniture | | |
| | `12` | `Glass bottle` | Molded soda-lime glass bottles and jars | | |
| | `13` | `Iron utensils` | Ferrous cookware, cutlery, and kitchen implements | | |
| | `14` | `Liquid` | Visible fluid pools, spilled viscous liquids | | |
| | `15` | `Metal shavings` | Industrial turnings, swarf, and metal particulate waste | | |
| | `16` | `Milk bottle` | Translucent HDPE or PET dairy containers | | |
| | `17` | `Organic` | Food scraps, agricultural biomass, decomposed matter | | |
| | `18` | `Paper bag` | Kraft and bleached cellulosic carrier bags | | |
| | `19` | `Paper cups` | Polyethylene-coated cellulosic beverage cups | | |
| | `20` | `Paper shavings` | Shredded paper and industrial cellulosic off-cuts | | |
| | `21` | `Paper` | Standard printed, bleached, or packaging paper sheets | | |
| | `22` | `Papier mache` | Molded pulp packaging (egg cartons, protective cushions) | | |
| | `23` | `Plastic bag` | Low-Density Polyethylene (LDPE) flexible shopping bags | | |
| | `24` | `Plastic bottle` | Polyethylene Terephthalate (PET) beverage bottles | | |
| | `25` | `Plastic can` | Rigid molded polymer cans and cylindrical packaging | | |
| | `26` | `Plastic canister` | Heavy-duty HDPE industrial storage canisters | | |
| | `27` | `Plastic caps` | Polypropylene (PP) and HDPE bottle closures | | |
| | `28` | `Plastic cup` | Polypropylene (PP) and Polystyrene (PS) drink cups | | |
| | `29` | `Plastic shaker` | Molded polymer cosmetic and beverage dispensers | | |
| | `30` | `Plastic shavings` | Shredded plastic flake and micro-particulate waste | | |
| | `31` | `Plastic toys` | Injection-molded ABS, PVC, and PE structural toys | | |
| | `32` | `Postal packaging` | Padded mailers, bubble wrap, poly mailer bags | | |
| | `33` | `Printing industry` | Coated card stock, offset printed material | | |
| | `34` | `Scrap metal` | Structural ferrous and non-ferrous construction scrap | | |
| | `35` | `Stretch film` | Linear Low-Density Polyethylene (LLDPE) pallet wrap | | |
| | `36` | `Tetra pack` | Aseptic liquid cartons (paperboard/foil/polyethylene laminate) | | |
| | `37` | `Textile` | Woven and non-woven fabrics, clothing, industrial rags | | |
| | `38` | `Tin` | Tinplate food cans and preserve containers | | |
| | `39` | `Unknown plastic` | Unspecified or degraded structural polymer fragments | | |
| | `40` | `Wood` | Lumber, pallets, dimensional timber fragments | | |
| | `41` | `Zip plastic bag` | Reusable LDPE slide and press-to-close storage bags | | |
| ## Quickstart and Usage | |
| ### Prerequisites | |
| ```bash | |
| pip install ultralytics opencv-python huggingface_hub torch torchvision | |
| ``` | |
| ### Method 1: Automated Hugging Face Hub Execution (For Evaluators) | |
| Evaluators can run inference directly by pulling weights from the Hugging Face repository without manual file downloads: | |
| ```python | |
| from huggingface_hub import hf_hub_download | |
| from ultralytics import YOLO | |
| import cv2 | |
| # Pull model weights directly from repository | |
| model_path = hf_hub_download( | |
| repo_id="Ank0805/waste-classification", # Replace with exact repo path if different | |
| filename="waste classification modle.pt" | |
| ) | |
| # Initialize model | |
| model = YOLO(model_path) | |
| # Execute inference | |
| results = model.predict( | |
| source="path/to/test_image.jpg", | |
| conf=0.25, | |
| iou=0.45, | |
| imgsz=640, | |
| device=0 # Set to 'cpu' if no NVIDIA GPU is available | |
| ) | |
| # Parse output detections | |
| for result in results: | |
| for box in result.boxes: | |
| cls_id = int(box.cls[0].item()) | |
| confidence = float(box.conf[0].item()) | |
| bbox = box.xyxy[0].tolist() | |
| label = model.names[cls_id] | |
| print(f"Material: {label:<30} | Confidence: {confidence:.3f} | BBox: {bbox}") | |
| # Save visual rendering | |
| annotated_frame = result.plot() | |
| cv2.imwrite("classification_output.jpg", annotated_frame) | |
| ``` | |
| ### Method 2: Local Python API | |
| ```python | |
| import cv2 | |
| from ultralytics import YOLO | |
| # Load local weights | |
| model = YOLO("waste classification modle.pt") | |
| # Execute inference | |
| results = model.predict( | |
| source="path/to/image.jpg", | |
| conf=0.25, | |
| iou=0.45, | |
| imgsz=640, | |
| device=0 | |
| ) | |
| # Parse output detections | |
| for result in results: | |
| for box in result.boxes: | |
| cls_id = int(box.cls[0].item()) | |
| label = model.names[cls_id] | |
| conf = float(box.conf[0].item()) | |
| print(f"Detected: {label} ({conf:.2f})") | |
| annotated_frame = result.plot() | |
| cv2.imwrite("output.jpg", annotated_frame) | |
| ``` | |
| ### Method 3: Video Stream and Conveyor Inspection | |
| ```python | |
| from ultralytics import YOLO | |
| model = YOLO("waste classification modle.pt") | |
| # Stream inference from video file, USB webcam (0), or industrial RTSP stream | |
| results = model.predict( | |
| source="conveyor_stream.mp4", | |
| conf=0.25, | |
| iou=0.45, | |
| save=True, | |
| stream=True | |
| ) | |
| for frame_result in results: | |
| pass # Generator executes per-frame inference | |
| ``` | |
| ### Method 4: Command-Line Interface (CLI) | |
| ```bash | |
| # Execute prediction on an image | |
| yolo task=detect mode=predict model="waste classification modle.pt" source="image.jpg" conf=0.25 save=True | |
| # Execute prediction on a video directory using GPU | |
| yolo task=detect mode=predict model="waste classification modle.pt" source="video_dir/" device=0 conf=0.25 save=True | |
| ``` | |
| ### Method 5: Compilation and Edge Engine Export | |
| ```python | |
| from ultralytics import YOLO | |
| model = YOLO("waste classification modle.pt") | |
| # Export to ONNX for cross-platform CPU/GPU deployment | |
| model.export(format="onnx", imgsz=640, simplify=True) | |
| # Export to NVIDIA TensorRT for ultra-low latency FP16 inference | |
| model.export(format="engine", imgsz=640, half=True, device=0) | |
| # Export to Intel OpenVINO | |
| model.export(format="openvino", imgsz=640, half=True) | |
| # Export to Tencent NCNN for embedded ARM hardware (Raspberry Pi, Jetson) | |
| model.export(format="ncnn", imgsz=640) | |
| ``` | |
| ## Datasets and Data Sources | |
| * **ProjectVerba / YoloTrash Benchmark**: [Roboflow Universe Repository](https://universe.roboflow.com/projectverba/yolo-waste-detection) | |
| *Annotated ground-level and close-range multi-class refuse corpus spanning 42 discrete material categories.* | |
| ## Training Specifications | |
| * **Optimization Algorithm**: AdamW ($\beta_1 = 0.937, \beta_2 = 0.999$, weight decay = $5 \times 10^{-4}$) | |
| * **Epochs**: 120 | |
| * **Learning Rate Schedule**: Initial $\eta_0 = 1\times 10^{-3}$, final factor $\text{lrf} = 0.01$ via Cosine Annealing | |
| * **Terminal Augmentation Deactivation**: Mosaic augmentation active for epochs 1 to 100, fully deactivated (`close_mosaic=20`) during epochs 101 to 120 to enable convergence on natural, unmanipulated object silhouettes. | |
| ## Operational Recommendations | |
| 1. **Recycling Facility / High-Recall Mode**: For initial sorting passes where omitting recyclable material carries a high cost, operate at `conf=0.20` to `conf=0.25`. | |
| 2. **Robotic Pick-and-Place Mode**: For automated robotic arms requiring strict material certainty before physical grasping, set `conf >= 0.45` to prevent picking errors on visually degraded items. | |