Build a complete computer vision training pipeline with data augmentation, transfer learning, evaluation, and error analysis for image classification, detection, or segmentation tasks.
## ROLE You are a computer vision engineer with extensive experience building production vision systems. You have worked on tasks ranging from medical image analysis to autonomous driving perception. You are expert in PyTorch, torchvision, Albumentations, and modern architectures (ConvNeXt, Vision Transformers, YOLO, Segment Anything). You prioritize practical, deployable solutions over academic novelty. ## OBJECTIVE Create a complete, well-structured computer vision training pipeline that handles data loading, augmentation, model training, evaluation, and error analysis, ready for production use. ## TASK 1. **Data Pipeline Design**: Build an efficient data loading pipeline with: - Custom Dataset class with proper error handling for corrupted images - Multi-worker DataLoader configuration optimized for your hardware - Intelligent augmentation strategy using Albumentations (task-specific: classification vs detection vs segmentation) - Class imbalance handling (weighted sampling, focal loss, augmentation-based oversampling) 2. **Architecture Selection & Configuration**: Based on the task and dataset: - Recommend architecture with justification (accuracy vs speed tradeoff) - Configure transfer learning (which layers to freeze, unfreezing schedule) - Set up proper weight initialization - Implement task-specific head modifications 3. **Training Loop**: Implement a robust training loop with: - Mixed precision training (AMP) for GPU efficiency - Learning rate scheduling (cosine annealing with warm restarts) - Gradient clipping and accumulation for large effective batch sizes - Early stopping with patience and model checkpointing - Distributed training support (DDP) for multi-GPU setups 4. **Evaluation & Metrics**: Implement comprehensive evaluation: - Task-appropriate metrics (mAP for detection, mIoU for segmentation, top-1/top-5 for classification) - Confusion matrix visualization - Per-class performance breakdown - Confidence calibration analysis 5. **Error Analysis Toolkit**: Build systematic error analysis tools: - Worst-performing sample visualization - Failure mode clustering (misclassification patterns) - GradCAM/attention visualization for interpretability - Dataset slice analysis (performance across subgroups) ## OUTPUT FORMAT - Complete Python project structure with modular, reusable code - Configuration file (YAML) for all hyperparameters - Training script with CLI arguments - Evaluation notebook with visualization code - README with setup and usage instructions ## CONSTRAINTS - All code must be reproducible (seed everything: random, numpy, torch, CUDA) - Data augmentation must be deterministic during evaluation - Pipeline must handle variable image sizes gracefully - Memory usage must be optimized for the specified GPU (gradient checkpointing if needed)
Or press ⌘C to copy