{"id":39968473,"url":"https://github.com/gabrieltseng/solar-panel-segmentation","last_synced_at":"2026-01-18T22:04:39.340Z","repository":{"id":93299230,"uuid":"180238084","full_name":"gabrieltseng/solar-panel-segmentation","owner":"gabrieltseng","description":"A U-Net for solar panel identification and segmentation","archived":false,"fork":false,"pushed_at":"2023-08-26T15:24:32.000Z","size":1998,"stargazers_count":47,"open_issues_count":4,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-11T17:40:35.136Z","etag":null,"topics":["computer-vision","deep-learning","machine-learning","remote-sensing","solar-energy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabrieltseng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-04-08T21:48:20.000Z","updated_at":"2024-06-07T10:13:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"493ad1c9-f6ab-48b8-91e3-2d6e531d610d","html_url":"https://github.com/gabrieltseng/solar-panel-segmentation","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"a76afc0de44fafda041e680776d042d07ae57046"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gabrieltseng/solar-panel-segmentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltseng%2Fsolar-panel-segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltseng%2Fsolar-panel-segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltseng%2Fsolar-panel-segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltseng%2Fsolar-panel-segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabrieltseng","download_url":"https://codeload.github.com/gabrieltseng/solar-panel-segmentation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltseng%2Fsolar-panel-segmentation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28552250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T20:59:07.572Z","status":"ssl_error","status_checked_at":"2026-01-18T20:59:02.799Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","deep-learning","machine-learning","remote-sensing","solar-energy"],"created_at":"2026-01-18T22:04:36.509Z","updated_at":"2026-01-18T22:04:39.332Z","avatar_url":"https://github.com/gabrieltseng.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solar segmentation [![Build Status](https://travis-ci.com/gabrieltseng/solar-panel-segmentation.svg?branch=master)](https://travis-ci.com/gabrieltseng/solar-panel-segmentation)\n\nFinding solar panels using USGS satellite imagery.\n\n## 1. Introduction\n\nThis repository leverages the [distributed solar photovoltaic array location and extent dataset for remote sensing object identification](https://www.nature.com/articles/sdata2016106)\nto train a segmentation model which identifies the locations of solar panels from satellite imagery.\n\nTraining happens in two steps:\n\n1. Using an Imagenet-pretrained ResNet34 model, a classifier is trained to identify whether or not solar panels are present\nin a `[224, 224]` image.\n2. The classifier base is then used as the downsampling base for a U-Net, which segments the images to isolate solar panels. \n\n## 2. Results\n\nThe classifier was trained on 80% of the data, with 10% being used for validation and 10% being used as a holdout test set.\nOn this test set, with a threshold of `0.5` differentiating positive and negative examples, the model achieved a **precision\nof 98.8%**, and a **recall of 97.7%**. This is competitive with [DeepSolar](http://web.stanford.edu/group/deepsolar/home) \n(precision of 93.1% - 93.7%, and recall of 88.5% - 90.5%) despite being trained on a smaller, publically available dataset.\n\n\u003cimg src=\"diagrams/test_auc_roc.png\" alt=\"AUC ROC results\" height=\"400px\"/\u003e\n\nThe segmentation model achieved a [Dice coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient)\nof 0.89:\n\n\u003cimg src=\"diagrams/segmentation_predictions.png\" alt=\"segmentation results\" height=\"500px\"/\u003e\n\n## 3. Pipeline\n\nThe main entrypoint into the pipeline is [`run.py`](solarnet/run.py). Note that each component reads files from the \nprevious step, and saves all files that later steps will need, into the [`data`](data) folder.\n\nIn order to run this pipeline, follow the instructions in the [data readme](data/README.md) to download the data.\n\n[Python Fire](https://github.com/google/python-fire) is used to generate command line interfaces.\n\n#### 3.1. Make masks\n\nThis step goes through all the polygons defined in `metadata/polygonVertices_PixelCoordinates.csv`, and constructs masks\nfor each image, where `0` indicates background and `1` indicates the presence of a solar panel.\n\n```bash\npython run.py make_masks\n```\nThis step takes quite a bit of time to run. Using an `AWS t2.2xlarge` instance took the following times for each city:\n\n- Fresno: 14:32:09\n- Modesto: 41:48\n- Oxnard: 1:59:20\n- Stockton: 3:16:08\n\n#### 3.2. Split images\n\nThis step breaks the `[5000, 5000]` images into `[224, 224]` images. To do this, [`polygonDataExceptVertices.csv`](data/metadata/polygonDataExceptVertices.csv)\nis used to identify the centres of solar panels. This ensures the model will see whole solar panels during the segmentation step.\n\nNegative examples are taken by randomly sampling the image, and ensuring no solar panels are present in the randomly sampled example.\n\n```bash\npython run.py split_images\n```\n\nThis yields the following images (examples with panels above, and without below):\n\n\u003cimg src=\"diagrams/positive_splits.png\" alt=\"examples with panels\" height=\"200px\"/\u003e\n\n\u003cimg src=\"diagrams/negative_splits.png\" alt=\"examples without panels\" height=\"200px\"/\u003e\n\n#### 3.3. Train classifier\n\nThis step trains and saves the classifier. In addition, the test set results are stored for future analysis.\n\n```bash\npython run.py train_classifier\n```\n\n#### 3.4. Train segmentation model\n\nThis step trains and saved the segmentation model. In addition, the test set results are stored for future analysis.\nBy default, this step expects the classifier to have been run, and will try to use it as a pretrained base.\n```bash\npython run.py train_segmenter\n```\n\nBoth models can be trained consecutively, with the classifier automatically being used as the base of the segmentation\nmodel, by running\n```bash\npython run.py train_both\n```\n\n## 4. Setup\n\n[Anaconda](https://www.anaconda.com/download/#macos) running python 3.7 is used as the package manager. To get set up\nwith an environment, install Anaconda from the link above, and (from this directory) run\n\n```bash\nconda env create -f environment.{mac, ubuntu.cpu}.yml\n```\nThis will create an environment named `solar` with all the necessary packages to run the code. To \nactivate this environment, run\n\n```bash\nconda activate solar\n```\n\nThis pipeline can be tested by running `pytest`.\n\n[Docker](https://www.docker.com/) can also be used to run this code. To do this, first build the docker image:\n\n```bash\ndocker build -t solar .\n```\n\nThen, use it to run a container, mounting the data folder to the container:\n\n```bash\ndocker run -it \\\n--mount type=bind,source=\u003cPATH_TO_DATA\u003e,target=/solar/data \\\nsolar /bin/bash\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieltseng%2Fsolar-panel-segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrieltseng%2Fsolar-panel-segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieltseng%2Fsolar-panel-segmentation/lists"}