How wimlds-trojmiasto/detect-waste works
1. This repository is a research codebase for waste detection and classification, not a single application. The top level is organized around four model families: EfficientDet, DETR, Mask R-CNN/Fast R-CNN, and a separate image classifier. Each subproject is largely self-contained with its own training, evaluation, and utility code.
2. The core domain boundary is the dataset/annotation layer under annotations/. The project standardizes multiple public waste datasets into COCO-like JSON files, with variants for multiclass detection, binary litter-vs-background detection, and “mixed” single-class training across datasets. These annotation files are the shared input contract for the model trainers.
3. Data preprocessing is handled by the root scripts annotations_preprocessing.py and annotations_preprocessing_multi.py, plus helper utilities in utils/. Their role is to merge heterogeneous datasets, remap labels, and split train/test sets. This is the main ETL stage that converts raw dataset exports into model-ready annotation files.
4. The detection/segmentation stack is split into multiple implementation paths:
- efficientdet/ for EfficientDet-based object detection,
- detr/ for transformer-based detection,
- MaskRCNN/ and FastRCNN/ for torchvision-style detection/segmentation pipelines.
Each subproject contains its own model definition, engine/training loop, dataset adapter, transforms, and COCO evaluation helpers.
5. efficientdet/ is the most complete detection subsystem. It includes model config, dataset parsers for COCO/Open Images/VOC, augmentation/transforms, anchor/loss logic, training and validation entry points, and distributed-training helpers. This subtree is effectively a mini-framework layered over PyTorch for detection experiments.
6. detr/ follows the official DETR-style architecture more closely: dataset loaders in detr/datasets, model pieces in detr/models, training/evaluation orchestration in detr/engine.py and detr/main.py, and utility code for boxes/metrics/plotting. It is structured as an end-to-end detection pipeline with optional segmentation support.
7. MaskRCNN/ and FastRCNN/ are lighter-weight PyTorch/Torchvision implementations. They rely on COCO-style annotations and include engines, transforms, and COCO evaluation utilities. Their architecture is simpler than the EfficientDet and DETR stacks, reflecting that they are baseline/reference implementations.
8. The classification subsystem lives in classifier/ and is separate from detection. Its job is to crop detected litter objects from images and train an image classifier over those crops. The presence of cut_bbox_litter.py and sort_openlittermap.py makes this a second-stage pipeline: detection first, then classification on extracted regions.
9. sort_openlittermap.py shows an important data-flow boundary: it uses detector predictions to align unlabeled or weakly labeled OpenLitterMap images with original annotations, creating pseudo-labeled training data for classification. This is the repo’s semi-supervised / bootstrapping path.
10. The main inference path is make_predictions.py. It combines a trained detector checkpoint and a trained classifier checkpoint to produce annotated images or videos. For video, the output is frame-by-frame image export, which can then be reassembled with ffmpeg. This script represents the integration point between the detection and classification subsystems.
11. Experiment tracking is externalized to Neptune in the training scripts. The README indicates the project logs experiments to Neptune.ai, so training runs have an observability boundary outside the repo. This affects architecture because model scripts are expected to emit metrics and checkpoints into a remote experiment store.
12. notebooks/ and the various subproject notebooks are analysis and prototyping surfaces, not runtime components. They cover exploratory data analysis, statistics across datasets, and finetuning demos. They help explain data provenance and model behavior but are not part of the production execution graph.
13. The repo is strongly Python/PyTorch-based, with COCO-style dataset handling as the common interoperability format. The main architectural pattern is: heterogeneous public datasets → preprocessing and label normalization → training in one of several model families → optional crop-based classification → inference visualization and evaluation.
Main entry points: annotations Annotations · make_predictions.py Prediction flow · effdet EffDet core · classifier Crop classifier
Components 19
Data prep
Shared annotation, conversion, and split pipeline for waste datasets.
- Annotations · COCO-like JSON annotation sets for multiclass, binary, and mixed training.
annotations - Prep scripts · Root scripts that merge datasets, remap labels, and split train/test sets.
annotations_preprocessing.py - Conversion utils · Shared helpers for dataset conversion, download, and COCO splitting.
utils
EfficientDet
Most complete detector subsystem with its own framework layer.
- Train loop · EfficientDet training orchestration and checkpointing.
efficientdet/train.py - EffDet core · Model, config, loss, anchors, and distributed helpers for detection experiments.
efficientdet/effdet - Data pipeline · Dataset factory, parsers, transforms, loaders, and augmentation for COCO/Open Images/VOC.
efficientdet/effdet/data - Eval stack · Detection metrics and evaluator utilities for validation and benchmarking.
efficientdet/effdet/evaluation
Other detectors
DETR and Torchvision-style detection/segmentation baselines.
- DETR main · End-to-end DETR training and evaluation orchestration.
detr/main.py - DETR models · Backbone, transformer, matcher, segmentation, and DETR model components.
detr/models - DETR data · COCO and panoptic dataset loaders, transforms, and evaluation helpers.
detr/datasets - Mask R-CNN · Torchvision-style training, transforms, and COCO evaluation for detection/segmentation.
MaskRCNN - Fast R-CNN · Lighter Torchvision-style detection baseline with COCO utilities and engine.
FastRCNN
Classifier
Second-stage crop classification and pseudo-labeling flow.
- Crop classifier · Trains image classifiers on cropped litter objects.
classifier - Pseudo-labeling · Aligns OpenLitterMap images with detector predictions to create weakly labeled classification data.
classifier/sort_openlittermap.py - Crop extraction · Cuts detected litter bounding boxes into training crops.
classifier/cut_bbox_litter.py
Inference
Cross-model prediction and visualization entry points.
- Prediction flow · Combines detector and classifier checkpoints to annotate images or exported video frames.
make_predictions.py - EffDet demo · EfficientDet demo and validation utilities for inspecting predictions.
efficientdet/demo.py - DETR demo · DETR demo entry point for running inference on samples.
detr/demo.py
Analysis
Notebooks and exploratory surfaces for data and experiments.
- Notebooks · EDA, statistics, and finetuning notebooks across datasets and model families.
notebooks
Connections 20
- Prep scripts → Annotations: writes · Creates standardized annotation files from heterogeneous datasets.
- Conversion utils → Prep scripts: supports · Provides conversion, download, and split helpers.
- Annotations → Data pipeline: feeds · COCO-like files are the shared input contract for EfficientDet data loaders.
- Annotations → DETR data: feeds · COCO-style annotations drive DETR dataset loading.
- Annotations → Mask R-CNN: feeds · Torchvision baselines consume the same annotations.
- Annotations → Fast R-CNN: feeds · Torchvision baselines consume the same annotations.
- Data pipeline → EffDet core: trains · Supplies batches and augmented inputs to the detector core.
- EffDet core → Train loop: orchestrates · Training script drives the core model and optimization.
- EffDet core → Eval stack: validates · Evaluates detections and reports metrics.
- DETR data → DETR models: trains · Dataset loaders feed the transformer model stack.
- DETR models → DETR main: orchestrates · Main script wires model, matcher, and optimization.
- Mask R-CNN → Prediction flow: optional source · Can provide detector outputs for downstream annotation.
- Fast R-CNN → Prediction flow: optional source · Can provide detector outputs for downstream annotation.
- EffDet core → Prediction flow: detector source · EfficientDet checkpoints are used in the integrated prediction path.
- Crop classifier → Prediction flow: classifier source · Classifier checkpoints refine detector outputs in the integrated flow.
- Crop extraction → Crop classifier: prepares crops · Extracts object crops used for classifier training.
- Pseudo-labeling → Crop classifier: bootstraps data · Generates pseudo-labeled or aligned training examples.
- Prediction flow → Notebooks: analyzed in · Prediction results and dataset behavior are explored in notebooks.
- Train loop → Notebooks: explored in · Training experiments are often prototyped and inspected in notebooks.
- DETR main → Notebooks: explored in · Finetuning and analysis notebooks support DETR experiments.