How zhou13/lcnn works
Project type and purpose
• This is a research‑oriented machine‑learning codebase (L‑CNN) for end‑to‑end wireframe parsing in images.
• The purpose is to train, evaluate, and demo a PyTorch model that detects junctions and line segments (wireframes) on input images.
High‐level architecture (main components)
a. Data layer
• Raw dataset (ShanghaiTech or custom images)
• Pre‑processed dataset (npz files under data/wireframe)
b. Configuration
• YAML config files (config/wireframe.yaml) specifying hyperparameters
c. Core library (lcnn/ )
• models/ (hourglass_pose, line_vectorizer, multitask_learner)
• datasets.py (data loader, preprocessing hooks)
• metric.py (sAP, APH, mAPJ computation)
• trainer.py (training loop, checkpointing, logging)
• postprocess.py (thresholding, line merging)
• utils.py (helpers)
d. Entry‑point scripts
• train.py (launches training)
• process.py (batch inference over dataset)
• demo.py (single‑image inference)
• post.py (post‑processing + optional plotting)
• eval-sAP.py / eval-mAPJ.py / eval-APH.py (evaluation suites)
e. External services & tools
• HuggingFace (model & dataset download)
• MATLAB (for APH evaluation via mex interfaces)
f. Artifacts & outputs
• logs/ (tensorboard, checkpoints, npz outputs)
• post/ (thresholded npz, plots)
• figs/ (qualitative result images)
Relationships & data flow
• Data Preparation:
raw images → dataset/wireframe.py → pre‑processed npz → data/wireframe/
• Training:
config + pre‑processed npz → trainer.py → model checkpoints + logs + npz predictions
• Inference:
process.py (config + checkpoint + dataset) → batch npz predictions
• Post‑processing:
npz predictions → post.py → refined predictions + optional plots
• Evaluation:
sAP/mAPJ: eval-sAP.py / eval-mAPJ.py consume npz + ground truth → metrics + PR curves
APH: post outputs + MATLAB eval_release.m → APH metrics
Architectural patterns & design principles
• Modular Python package (lcnn/) separated from entry scripts
• Clear separation of concerns: data loading, model definition, training, post‑processing, evaluation
• Configuration‑driven via YAML + global config module
• Reusable components: hourglass backbone, line vectorizer, multi‑task heads