gabrielkasmi/deeppvmapper
关于
Automated pipeline for large scale detection of solar arrays in France
人工智能与机器学习实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文DeepPVMapper
Mapping of rooftop photovoltaic installations in France from aerial imagery. This repository holds two things:
- The mapping pipeline — detects PV panels on IGN orthophotos with deep learning and characterizes each installation (surface, tilt, azimuth, installed capacity).
- The data — the resulting nationwide registry, which you can browse on the map, download, or query in natural language through an MCP server.
🗺️ Project page · 📖 Pipeline documentation · Work carried out by Gabriel Kasmi, started during his PhD at Mines Paris-PSL (2020–2024).
Mapping pipeline
How it works
For one department, main.py runs four steps:
| step | what happens |
|---|---|
| Classification | IGN BD ORTHO tiles (20 cm) are decoded on the GPU (nvJPEG2000, a few seconds per tile; OpenJPEG on CPU as fallback), cut into 299×299 patches, and an InceptionV3 classifier flags the patches that contain panels. |
| Segmentation | A DeepLabV3 model segments the positive patches; masks become polygons, and adjacent polygons are merged into arrays, within a tile and across tile borders. |
| Characterization | pypvroof measures tilt and azimuth on the IGN LiDAR HD surface model (Theil-Sen) and splits polygons covering several roof planes: two opposite or two flat planes stay split, the other split polygons are merged back (and flagged for review when the split is ambiguous). Polygons without a LiDAR estimate are measured on the IGN MNS Correl (computed from the BD ORTHO images); the rest is imputed (department median tilt by size class, bounding-box azimuth). Surface follows, and kWp = 0.1319 × surface (kwp_per_m2, slope through the origin on BDAPPV). |
| Post-processing | Installations below 1 kWp are dropped, as are those in a ground-mounted or floating PV plant (BD TOPO) and the polygons split into the maximum number of planes (mostly ground-mounted plants) unless they lie on a BD TOPO building, on a car park or in a BD TOPO rooftop plant. An installation is kept when it lies on a BD TOPO building or on a car park, OpenStreetMap or BD TOPO (solar carports). The carports of a car park are merged into one installation (a MultiPolygon). |
The pipeline input is the BD ORTHO tiles, which run.sh downloads for you, together with the OpenStreetMap extract of the region (car parks, Geofabrik). Everything else is fetched online at run time: model weights from Hugging Face (pinned revision), the LiDAR HD and MNS Correl surface models and BD TOPO from the IGN Géoplateforme. A run can be interrupted and resumed: rerun the same command.
An NVIDIA GPU with 24 GB of VRAM is recommended (tested on an RTX PRO 4000 Blackwell, 24 GB; any CUDA GPU from Turing onwards works with the image). The peak is about 23 GB, reached while the next tile is decoded during the classification of the current one:
| VRAM | |
|---|---|
| JP2 decoding of one 25,000 × 25,000 tile (nvJPEG2000 working buffers + decoded image) | ~14 GB |
Classification model and inference (cls_batch_size: 512, fp16) |
~8 GB |
With less memory, set decoder: cpu (OpenJPEG on the CPU, ~6 min of CPU per tile instead of ~2–4 s) and/or lower cls_batch_size.
Run with Docker (recommended)
The image ships the code and all its dependencies.
docker pull ghcr.io/gabrielkasmi/deeppvmapper:latest
docker run --gpus all -v /path/to/workspace:/workspace \
-e DEPTS="003:2025" ghcr.io/gabrielkasmi/deeppvmapper:latest
With DEPTS set, the container runs the whole chain for each department: download of the tiles, detection, characterization, and deletion of the tiles once the department succeeded. Outputs and pipeline_log.txt are written to /workspace/output. Without DEPTS, the container stays idle so that you can open a shell. On RunPod, use the image as the pod's container image, mount the volume on /workspace and set the variables below in the pod settings. For SSH, expose TCP port 22 and set PUBLIC_KEY (your public key) in the template: sshd is started only when it is set. A step-3-only run outside the image (generic pod) is described in the documentation (Running, "Without the image").
| variable | meaning |
|---|---|
DEPTS |
dept:year pairs, space or comma separated; 3-character codes (003, 069, 02A/02B for Corsica) |
MAX_TILES |
process only the first N tiles of each department (test or profiling run); downloads are then kept |
PROFILE=1 |
also write the per-stage timings (timings_{dpt}_{year}.json); on by default with MAX_TILES |
KEEP_DATA=1 |
never delete the downloaded tiles |
STEPS=3 |
step 3 only (characterization + post-processing) from the arrays_{d}_{yyyy}.geojson already in OUTPUT_DIR: no image download, CPU is enough; departments already characterized are skipped |
TEMP_DIR |
working directory (default /root/dpvm-temp, on the container disk; with decoder: cpu it also holds ~2 GB per tile being decoded) |
OUTPUT_DIR |
outputs directory (default /workspace/output) |
The run settings are those of the repository's config.yml, which run.sh updates for each department (paths only).
Run from source
Tested on Ubuntu 24.04 (same setup as the image). GDAL comes from the system packages, so no Python binding has to be compiled:
sudo apt-get install -y python3-venv python3-gdal python3-numpy gdal-bin libopenjp2-7 wget 7zip
git clone https://github.com/gabrielkasmi/deeppvmapper.git && cd deeppvmapper
python3 -m venv --system-site-packages .venv && source .venv/bin/activate # sees the apt GDAL and numpy
pip install torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu128
pip install -r requirements.txt
pip install "nvidia-nvimgcodec-cu12[all]" # optional, NVIDIA GPU: decodes the JP2 tiles on the GPU
Then either let run.sh download and process whole departments:
DEPTS="003:2025" WORKSPACE="$PWD/workspace" ./run.sh
or, with tiles already on disk, set source_images_dir in config.yml (folder with the JP2 tiles and their dalles.shp index) and call the pipeline directly:
python main.py --dpt 3 # whole department, resumes if interrupted
python main.py --dpt 3 --max-tiles 10 # first 10 tiles only
python main.py --dpt 3 --clean # discard previous progress
python main.py --dpt 3 --profile # also write the per-stage timings
With --profile, the per-stage timings are written to {outputs_dir}/timings_{dpt}_{year}.json, also when the run fails.
Outputs
| file | content |
|---|---|
arrays_{dpt}_{year}.geojson |
every detected polygon (WGS84), before characterization |
characteristics_{dpt}_{year}.csv |
one row per installation (columns below) |
arrays_characteristics_{dpt}_{year}.geojson |
the same installations and columns, with their polygons |
One row is one installation: a continuous set of modules on one roof plane. Several installations on the same roof are separate rows, and a polygon covering several roof planes becomes one row per plane (polygon_id, part, n_parts link them). Exception: the solar carports of a car park are one row, with a MultiPolygon (n_parts = number of canopy rows).
| column | content |
|---|---|
installation_id, polygon_id, part, n_parts |
identifiers; polygon_id = detected polygon, part = roof plane |
surface, tilt, azimuth, kWp |
m², °, ° (0 = north, clockwise; empty on a flat roof), kWp |
lat, lon, tile_name |
centroid (WGS84) and BD ORTHO tile |
tilt_method, azimuth_method |
where the value comes from: lidar, correl, dpt_size_median / dpt_median (tilt), bbox (azimuth) |
lidar_status, correl_status, lidar_date |
status of the LiDAR pass (why there is no LiDAR value, e.g. no_coverage), status of the Correl pass (empty when not queried), date of the LiDAR acquisition |
on_building, on_parking, in_solar_farm |
on a BD TOPO building, on a car park (OSM or BD TOPO), in a BD TOPO ground-mounted / floating PV plant |
is_carport |
solar carport: on a car park and not on a building (empty when the car parks are unknown) |
review |
True for the rows to review first: ambiguous roof-plane splits merged back, and polygons at the plane cap kept on a roof |
Commune codes and building identifiers (RNB) are not attached here; they come from a spatial join on the polygons.
Main settings
All settings live in config.yml, with comments. The ones you are most likely to change:
| parameter | default | description |
|---|---|---|
cls_threshold / seg_threshold |
0.4 / 0.46 | classification and segmentation thresholds |
cls_batch_size / seg_batch_size |
512 / 64 | GPU batch sizes (lower them if out of memory) |
amp |
True | fp16 inference on CUDA |
decoder |
auto |
JP2 decoding: gpu (nvJPEG2000, ~2–4 s per tile), cpu (OpenJPEG, ~6 min of CPU per tile), auto = gpu when available |
decode_workers |
auto |
parallel CPU decoders (decoder: cpu); auto = container CPU quota ÷ 2 |
kwp_min / kwp_max |
1.0 / none | kWp window of the kept installations |
building_filter |
drop |
drop (keep the installations on a building or a car park), flag (keep all, flags only) or off |
solar_farm_filter |
drop |
drop, flag or off for the installations in ground-mounted / floating PV plants |
dsm_fallback_service |
fr-correl |
surface model used where the LiDAR gives no estimate (none to skip) |
tilt_fallback / azimuth_fallback |
dpt_size_median / bbox |
imputation of what neither surface model measured (none to leave empty) |
enable_split |
True | split polygons covering several roof planes (LiDAR) |
split_rules |
True | keep or merge back the split planes by category (False: every plane stays a row) |
dsm_workers |
8 | concurrent LiDAR / Correl queries |
hf_revision |
pinned commit | version of the model weights on Hugging Face (local_model: True + model_dir to use local .pth files instead) |
Data
Browse
- Interactive map — explore the detected installations, and report errors (no coding required).
- Data page — description of the datasets and of their quality.
Download
Query with an MCP client
The registry (1.14M+ detections) is exposed as a public MCP (Model Context Protocol) server over Streamable HTTP. Any MCP-compatible client (Claude, etc.) can query it in natural language: search detections, aggregate installed capacity by department, explore an area, track yearly deployment, check data-quality signals. No install required: add the endpoint as a custom connector.
- Endpoint:
https://zelhliylrlktnasircwp.supabase.co/functions/v1/mcp/mcp - Source:
supabase/functions/mcp - Registry: registry.modelcontextprotocol.io —
io.github.gabrielkasmi/deeppvmapper
Contributing
Contributions are welcome, both code (performance, imagery sources, models) and registry corrections through the interactive map. See CONTRIBUTING.md; issues labelled good first issue are the best entry points.
Citation
If you use the pipeline or the data, please cite:
@phdthesis{kasmi2024enhancing,
title={Enhancing the Reliability of Deep Learning Models to Improve the Observability of French Rooftop Photovoltaic Installations},
author={Kasmi, Gabriel},
year={2024},
school={Universit{\'e} Paris sciences et lettres}
}
For the datasets, please also cite the corresponding Zenodo record (DOIs above).
License
Code: MIT.
Data produced by the pipeline: ODbL. Sources: IGN (BD ORTHO, LiDAR HD, MNS Correl, BD TOPO) and OpenStreetMap (© OpenStreetMap contributors, ODbL).
探索相关项目
加载中…