How sairam13001/c2fdrone works
Project Type and Purpose
• This is a Python-based deep-learning training and evaluation pipeline for “Drone-to-Drone-Detection” (DDoD).
• It orchestrates data loading, model definition (Deformable DETR + Swin Transformer variants), custom CUDA/CPU ops, training loops, distributed launch scripts, and logging/checkpointing.
High-Level Architectural Breakdown
• Core Components
a. Data Ingestion Layer
• datasets/ + dataset_dets.py + specialized parsers & samplers
• data_prefetcher.py for asynchronous batching
b. Model Definition Layer
• models/ folder including:
– backbone.py, swin_transformer.py, deformable_detr.py, matcher.py, segmentation.py
– models/ops/ – custom CUDA/CPU kernels for MultiScaleDeformableAttention
c. Engine & Orchestration
• engine.py (or engine_single.py) with train_one_epoch, evaluate loops
• main.py entrypoint wiring config ➔ datasets ➔ model ➔ engine
d. Configuration & Launch
• configs/ shell scripts (*_train.sh, *_eval.sh) define hyper-parameters, EXP_DIR, GPUs
• tools/launch.py + tools/run_dist_*.sh for single-/multi-node distributed launch
e. Utilities & Logging
• Logging to disk (EXP_DIR) and checkpoint saving in run.sh or within engine
Relationships & Data Flow
[ Raw Video / COCO Files ]
↓ parsed by coco_video_parser.py / vid_single.py
↓ transforms & samplers
↓ data_prefetcher feeds batches
↓ Model Forward Pass (models/…)
↓ Loss & Matching (matcher.py)
↓ Backprop ↔ Custom Operators (models/ops/)
↓ Optimizer step
↓ Checkpoint & Logs
• Control Flow:
[ run_dist_launch.sh ] → spawns N processes running main.py → each process sets up DDP, executes engine.py
Key Architectural Patterns & Principles
• Layered Design: clear separation between data, model, ops, engine, tools.
• Modularity: interchangeable backbones (Swin variants), dataset flags (temporal fusion).
• Custom Extension Points: C++/CUDA ops under models/ops compiled via setup.py / make.sh.
• Distributed Training Pattern: each GPU process runs a mirror of the same script under PyTorch DDP.
• Config-Driven: shell scripts + environment variables define hyperparams, logging paths.
Technologies & Frameworks
• Python 3.7+, PyTorch (with DDP)
• CUDA/C++ for custom kernels
• Docker & nvidia-docker for environment
• Slurm / custom scripts for cluster launch
• Standard libs: argparse, logging, shell scripting
Final Recommendations
1) Macro-view: Data → Training Service → Checkpoint & Logs → External (Docker/Cluster)
2) Meso-view: inside Training Service show Model, Engine, Distributed Launcher, Ops
• Finally, export in SVG or PDF for clarity and easy updates.