Pipeline Overview
TheTrashClassificator class in processor.py:7 orchestrates the entire classification workflow through its frame_processing() method.
Processing Steps
Initialize Components
The classifier initializes two main components:
- SegmentationModel: Handles trash detection and tracking
- Drawing: Manages visualization of detections
Trash Segmentation
The input image is copied and passed to the segmentation model:Returns:
trash_track: Detection results with boxes, masks, and tracking IDstrash_classes: Dictionary mapping class IDs to namesdevice: PyTorch device used for inference
Detection Validation
The pipeline checks if any tracked objects were detected:If no boxes have tracking IDs, the original unmodified image is returned.
Input/Output Specifications
Processing Flow Diagram
Error Handling
The pipeline implements graceful degradation:No Detection HandlingWhen
trash.boxes.id is None, the pipeline returns the original image unchanged with status 'No trash detected'. This prevents visualization errors when no objects are tracked.Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Empty tracking IDs | No objects meet confidence threshold | Lower conf parameter in segmentation |
| Processing lag | High resolution input | Reduce imgsz parameter or input size |
| Memory errors | Large batch of frames | Process frames individually |
Performance Considerations
- Image Copying
- Device Optimization
- Streaming Mode
The pipeline creates multiple image copies to preserve the original:This adds memory overhead but ensures the input remains unchanged.
Configuration Parameters
The segmentation inference insegmentation/main.py:24 accepts these parameters:
Parameter Tuning
- conf: Lower values detect more objects but increase false positives
- imgsz: Larger sizes improve accuracy but reduce speed
- persist: Must be
Truefor consistent object tracking
Next Steps
Video Processing
Learn how to process video streams in real-time
Drawing Detections
Customize visualization of detected trash