How riccardocadei/photovoltaic-detection works
Project type and purpose
• This is a data-centric machine-learning pipeline focused on binary semantic segmentation of aerial images (250×250×3) to detect rooftop areas suitable for PV installations.
• Key stages: data ingestion & labeling → preprocessing & augmentation → U-Net training → evaluation & visualization → inference/deployment.
File structure
Top-level components:
• labelling_tool: scripts and notebooks to crop, scan, label, verify, and move raw images and generate binary masks.
• process_data: data_loader, normalize, import_test – handle image normalization, train/val/test splits, and dataset abstractions.
• train: train.py orchestrates the training loop over the U-Net model.
• model: unet.py defines the network architecture.
• loss: loss.py and loss.ipynb compute custom losses and metrics (IoU, accuracy).
• plots: plots.py and subdirectories containing training history arrays and generated figures.
• run.py & main.ipynb: high-level scripts to glue together preprocess → train → plot → evaluate.
• documents & reference: static artifacts (reports, papers) – these are outside the core runtime pipeline but should be shown as documentation inputs.
README for additional insights
• Data format: PNG, RGB, pixel-wise binary masks.
• Training details: real-time augmentation, thresholding, 80/10/10 split.
• Technologies: Python 3.6, NumPy, PyTorch, scikit-learn, OpenCV, Matplotlib.
• External resources: Pre-trained models and data hosted on Google Drive.
1. Raw Data Store (folder of PNG images + blank masks)
2. Labelling Tool (scripts/notebooks – crop.py, label_images.py, etc.)
3. Preprocessing Pipeline (process_data module)
4. Model Definition (U-Net in model/unet.py)
5. Training Engine (train/train.py + run.py)
6. Loss & Metric Calculator (loss/loss.py, IoU, accuracy)
7. Visualization & Reporting (plots/plots.py, main.ipynb)
8. Output Artifacts (trained model checkpoints, plots, evaluation reports)
9. Documentation (documents folder + reference papers)
• Raw Data Store → Labelling Tool
• Labelling Tool → Labeled Dataset
• Labeled Dataset → Preprocessing Pipeline
• Preprocessing Pipeline → DataLoader (PyTorch)
• DataLoader → Training Engine
• Training Engine ↔ Model Definition (builds & updates weights)
• Training Engine → Loss & Metrics → Feedback loop (optimizer)
• After each epoch: Training Engine → Visualization (plots module)
• Final model → Output Artifacts → Optional Deployment/In-ference script
• Documentation & Reference sit aside, feeding context but not in the runtime flow
c. Architectural patterns & principles:
• Pipeline pattern (stages chained: labeling → preprocessing → training → evaluation)
• Modular separation: tooling (labelling), data processing, model, training, loss, visualization
• Configurability: hyperparameters folder / select_param.py controls learning rates, batch sizes
• Reproducibility: notebooks and run.py tie everything together
d. Key technologies & libraries:
• Data I/O: OpenCV, NumPy
• ML Framework: PyTorch (torch.utils.data.DataLoader, model/unet.py)
• Metrics: custom IoU, accuracy code in loss.py
• Visualization: Matplotlib (plots/plots.py, notebooks)
• Scripting & orchestration: Python scripts (run.py, train/train.py), Jupyter notebooks