How turoad/clrnet works
Project type and purpose
• CLRNet is a research‐oriented deep-learning framework (PyTorch) for lane detection (computer vision).
• It implements the “Cross Layer Refinement Network” for training, validating, and inferring lane lines on CULane, TuSimple, and LLAMAS datasets.
File structure
• Top level:
• main.py – entry point for training/validation/inference
• configs/ – model‐and‐dataset configuration scripts
• tools/ – auxiliary scripts (e.g., segmentation label generator)
• clrnet/ – core Python package
• setup.py, requirements.txt – packaging and dependencies
• clrnet/ subpackages:
• datasets/ – dataset classes, preprocessing, registry
• models/ – network backbones, necks, heads, losses, registry
• engine/ – training runner, optimizer & scheduler setup, registry
• ops/ – custom C++/CUDA operators (e.g., NMS)
• utils/ – configuration loader, logging, metrics, visualization, registry
README for architecture insights
• Input image → Backbone → Neck → Head → Refinement → Output lanes
• Training pipeline with losses, optimizer, scheduler
• Validation/inference with visualization
Main components
a. Data sources (external datasets)
– CULane, TuSimple, LLAMAS (mounted under data/)
b. Data pipeline
– datasets/ classes & process/transforms.py → PyTorch DataLoader
c. Model pipeline
– Backbone (ResNet, DLA) → Neck (FPN, PAFPN) → CLR Head → Cross-layer refinement
d. Training engine
– Runner (engine/runner.py) orchestrates forward/backward, collects losses
– Optimizer & Scheduler (engine/optimizer.py & scheduler.py)
– Recorder & Logger (utils/recorder.py, utils/logger.py)
e. Custom operators
– NMS in ops/csrc for post-processing
f. Inference & visualization
– Runner’s validate/test mode → outputs → utils/visualization.py
Relationships and data flows
• CLI (main.py)
→ Load config (utils/config.py)
→ Instantiate Runner
→ Runner
• calls Dataset → DataLoader → batch of images
• feeds images to Model
• computes losses via Loss modules
• updates via Optimizer & Scheduler
• logs metrics & checkpoints
• on validate/test: runs model, calls NMS, then visualization
• Tools script (tools/generate_seg_tusimple.py)
→ consumes raw TuSimple JSON → generates segmentation labels
Architectural patterns and design principles
• Modular registry pattern (datasets, models, engines) for plug-and-play
• Separation of concerns: data, model, engine, utils, ops
• Config-driven design: all hyperparameters and paths in configs/
• Extensibility via custom ops and registries
• Notation for file‐based configuration (configs/*.py) feeding into Runner
• Visualizes the end-to-end training/inference flow
• Highlights the modular architecture and registry patterns
• Illustrates how core components interact with data, configs, and custom ops
• Is tailored to the CLRNet project’s structure and cross-layer refinement objective