• Stars
    star
    203
  • Rank 189,058 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 8 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Training and test the SegNet neural network on satellite imagery

SegNet training and testing scripts

These scripts are for use in training and testing the SegNet neural network, particularly with OpenStreetMap + Satellite Imagery training data generated by skynet-data.

Contributions are very welcome!

Quick start

The quickest and easiest way to use these scripts is via the developmentseed/skynet-train docker image, but note that to make this work with a GPU--necessary for reasonable training times---you will need a machine set up to use nvidia-docker. (The start_instance script uses docker-machine to spin up an AWS EC2 g2 instance and set it up with nvidia-docker. The start_spot_instance script does the same thing but creates a spot instance instead of an on demand one.)

  1. Create a training dataset with skynet-data.
  2. Run:
nvidia-docker run \
    -v /path/to/training/dataset:/data \
    -v /path/to/training/output:/output \
    -e AWS_ACCESS_KEY_ID=... \
    -e AWS_SECRET_ACCESS_KEY=... \
    developmentseed/skynet-train:gpu \
      --sync s3://your-bucket/training/blahbla

This will kick off a training run with the given data. Every 10000 iterations, the model will be snapshotted and run on the test data, the training "loss" will be plotted, and all of this uploaded to s3. (Omit the --sync argument and AWS creds to skip the upload.)

Each batch of test results includes a view.html file that shows a bare-bones viewer allowing you to browse the results on a map and compare model outputs to the ground truth data. Use it like:

Customize the training run with these params:

--model MODEL # segnet or segnet_basic, defaults to segnet
--output OUTPUT # directory in which to output training assets
--data DATA # training dataset
[--fetch-data FETCH_DATA] # s3 uri from which to download training data into DATA
[--snapshot SNAPSHOT] # snapshot frequency
[--cpu] # sets cpu mode
[--gpu [GPU [GPU ...]]] # set gpu devices to use
[--display-frequency DISPLAY_FREQUENCY] # frequency of logging output (affects granularity of plots)
[--iterations ITERATIONS] # total number of iterations to run
[--crop CROP] # crop trianing images to CROPxCROP pixels
[--batch-size BATCH_SIZE] # batch size (adjust this up or down based on GPU size. defaults to 6 for segnet and 16 for segnet_basic)
[--sync SYNC]

Monitoring

On an instance where training is happening, expose a simple monitoring page with:

docker run --rm -it -v /mnt/training:/output -p 80:8080 developmentseed/skynet-monitor

Details

Prerequisites / Dependencies:

  • Node and Python
  • As of now, training SegNet requires building the caffe-segnet fork fork of Caffe.
  • Install node dependencies by running npm install in the root directory of this repo.

Set up model definition

After creating a dataset with the skynet-data scripts, set up the model prototxt definition files by running:

segnet/setup-model --data /path/to/dataset/ --output /path/to/training/workdir

Also copy segnet/templates/solver.prototxt to the training work directory, and edit it to (a) point to the right paths, and (b) set up the learning "hyperparameters".

(NOTE: this is hard to get right at first; when we post links to a couple of pre-trained models, we'll also include a copy of the solver.prototxt we used as a reference / starting point.)

Train

Download the pre-trained VGG weights VGG_ILSVRC_16_layers.caffemodel from http://www.robots.ox.ac.uk/~vgg/research/very_deep/

From your training work directory, run

$CAFFE_ROOT/build/tools/caffe train -gpu 0 -solver solver.txt \
    -weights VGG_ILSVRC_16_layers.caffemodel \
    2>&1 | tee train.log

You can monitor the training with:

segnet/util/plot_training_log.py train.log --watch

This will generate and continually update a plot of the "loss" (i.e., training error) which should gradually decrease as training progresses.

Testing the Trained Network

segnet/run_test --output /path/for/test/results/ --train /path/to/segnet_train.prototxt --weights /path/to/snapshots/segnet_blahblah_iter_XXXXX.caffemodel --classes /path/to/dataset/classes.json

This script essentially carries out the instructions outlined here: http://mi.eng.cam.ac.uk/projects/segnet/tutorial.html

Inference

After you have a trained and tested network, you'll often want to use it to predict over a larger area. We've included scripts for running this process locally or on AWS.

Local Inference

To run predictions locally you'll need:

  • Raster imagery (as either a GeoTIFF or a VRT)
  • A line delimited list of XYZ tile indices to predict on (e.g. 49757-74085-17. These can be made with geodex)
  • A skynet model, trained weights, and class definitions ( .prototxt, .caffemodel, .json)

To run:

docker run -v /path/to/inputs:/inputs -v /path/to/model:/model -v /path/to/output/:/inference \
  developmentseed:/skynet-run:local-gpu /inputs/raster.tif /inputs/tiles.txt \
  --model /model/segnet_deploy.prototxt
  --weights /model/weights.caffemodel
  --classes /model/classes.json
  --output /inference

If you are running on a CPU, use the :local-cpu docker image and add --cpu-only as a final flag to the above command.

The predicted rasters and vectorized geojson outputs will be located in /inference (and the corresponding mounted volume)

AWS Inference

TODO: for now, see command line instructions in segnet/queue.py and segnet/batch_inference.py

GPU

These scripts were originally developed for use on an AWS g2.2xlarge instance. For support on newer GPUs, it may be required to:

  • use a newer NVIDIA driver
  • use a newer version of CUDA. To support CUDA8+, you can use the docker images tagged with :cuda8. They are built off an updated caffe-segnet fork with support for cuDNN5.

More Repositories

1

titiler

Build your own Raster dynamic map tile services
Python
707
star
2

landsat-util

A utility to search, download and process Landsat 8 satellite imagery
Python
688
star
3

jekyll-hook

No Longer Maintained | A server that listens for GitHub webhook posts and renders a Jekyll site
JavaScript
508
star
4

bones

A client/server web application framework built on Express and Backbone
JavaScript
483
star
5

label-maker

Data Preparation for Satellite Machine Learning
Python
445
star
6

lonboard

A Python library for fast, interactive geospatial vector data visualization in Jupyter.
Python
414
star
7

geolambda

Create and deploy Geospatial AWS Lambda functions
Dockerfile
285
star
8

geojson-pydantic

Pydantic data models for the GeoJSON spec
Python
209
star
9

eoAPI

[Active Development] Earth Observation API (Metadata, Raster and Vector services)
Shell
184
star
10

skynet-data

[DEPRECATED] Data pipeline for machine learning with OpenStreetMap
JavaScript
169
star
11

timvt

PostGIS based Vector Tile server.
PLpgSQL
164
star
12

rio-viz

Visualize Cloud Optimized GeoTIFF in browser
HTML
150
star
13

osm-seed

A collection of Dockerfiles to run a containerized version of OpenStreetMap
Shell
140
star
14

tipg

Simple and Fast Geospatial OGC Features and Tiles API for PostGIS.
PLpgSQL
129
star
15

jekyll-ga

A plugin for loading Google Analytics data into Jekyll
Ruby
128
star
16

fastai-serving

A Docker image for serving fast.ai models, mimicking the API of Tensorflow Serving
Python
119
star
17

dirty-reprojectors

Make quick and dirty projections to use in your web maps instead of Web Mercator
JavaScript
115
star
18

segment-anything-services

Running segment-anything image embedding, prompting, and mask generation as torchserve services
Jupyter Notebook
85
star
19

cogeo-mosaic

Create and use COG mosaic based on mosaicJSON
Python
84
star
20

morecantile

Construct and use OGC TileMatrixSets (TMS)
Python
80
star
21

rubik

DEPRECATED. Please see new home on d.o
PHP
79
star
22

observe

Cross-platform, offline, field mapping tool for OpenStreetMap
JavaScript
66
star
23

landsat-api

[DEPRECATED] An API for Landsat Metadata using Elastic Search
JavaScript
64
star
24

openlayers_themes

63
star
25

openlayers_plus

Additional tools and behaviors for OpenLayers.
JavaScript
62
star
26

rio-stac

Create STAC item from raster datasets
Python
61
star
27

mosaicjson-spec

JSON format for describing SpatioTemporal Cloud Optimized Geotiff mosaic.
61
star
28

vt-geojson

Extract GeoJSON from Mapbox vector tiles.
JavaScript
60
star
29

tao

DEPRECATED. Please see new home on d.o
PHP
56
star
30

slingshotSMS

A tiny RESTful modem server
Tcl
55
star
31

pearl-backend

PEARL (Planetary Computer Land Cover Mapping) Platform API and Infrastructure
JavaScript
55
star
32

labs-gpt-stac

Experimental: connect ChatGPT to a STAC API backend
HTML
51
star
33

macrocosm

Macrocosm is a partial port of the Open Street Map Rails API in NodeJS
JavaScript
49
star
34

collecticons-lib

Collecticons svg icons
JavaScript
48
star
35

FeatureServer

A simple feature server for Drupal.
PHP
46
star
36

tifeatures

Simple and Fast Geospatial Feature Server for PostGIS.
PLpgSQL
46
star
37

spacenet-data

Scripts for setting up the SpaceNet dataset for training a SegNet model
Shell
45
star
38

gdal2mb

a version of gdal2tiles with MapBox support
Python
41
star
39

ml-hv-grid-pub

Code for high-voltage grid mapping project with the World Bank; early 2018
Python
41
star
40

geodex

Find all geospatial tile indices contained in an arbitrary boundary at an arbitrary zoom
Python
36
star
41

mapbox

THIS REPOSITORY HAS MOVED. https://github.com/mapbox/osm-bright/
36
star
42

geokit

Python
35
star
43

atrium_features

Core atrium features.
PHP
34
star
44

chip-n-scale-queue-arranger

Chip 'n scale: Queue Arranger helps you run machine learning models over satellite imagery at scale
Python
33
star
45

caffe-fcn

Run Long and Shelhamer's FCN image segmentation network using Caffe
Jupyter Notebook
33
star
46

planet-stream

Stream the planet!
JavaScript
31
star
47

sat-api-pg

A Postgres backed STAC API.
PLpgSQL
30
star
48

ml-enabler

ML Enabler - machine learning interaction tools in the browser
JavaScript
29
star
49

singular

Dead simple Drupal theme with quick rebranding in mind
PHP
28
star
50

titiler-digitaltwin

A demo titiler for Sentinel 2 Digital Twin dataset
HTML
27
star
51

tilebench

Inspect Rasterio/GDAL HEAD/GET/LIST Requests
Python
27
star
52

scoreboard

Encouraging OpenStreetMap mappers with badges, graphs & stats! ✨🕹
JavaScript
27
star
53

thatchertiler

ThatcherTiler: expect some features to be dropped.
Python
26
star
54

vt-grid

Build up a pyramid of mapbox vector tiles by aggregating quantitative data into grids at lower zooms.
JavaScript
26
star
55

twitter-server

A simple node.js program that pulls data from Twitter's 1.1 API and pushes the response to a cloud service.
JavaScript
26
star
56

tensorflow-eo-training

Deep learning with TensorFlow and earth observation data.
Jupyter Notebook
25
star
57

AtriumDesign

Design Components for Open Atrium
25
star
58

mapbox-gl-layers

Layer toggle control for Mapbox GL JS
JavaScript
24
star
59

remote-workstation

A Dockerised work environment hosted on AWS Fargate which can be SSH'd into ☁️🌎📦
Python
24
star
60

sentinel-util

A CLI for downloading, processing, and making a mosaic from Sentinel-1, -2 and -3 data
Python
24
star
61

osm-teams

Teams for OpenStreetMap!
JavaScript
23
star
62

aiopmtiles

[WIP] PMTiles Async reader in python
Python
23
star
63

mrworldwide

Query OSM planet stats with AWS Athena
JavaScript
22
star
64

sat-ml-training

Jupyter Notebook
22
star
65

tf-lambda-proxy-apigw

Terraform Module for API Gateway Proxy + AWS Lambda
HCL
22
star
66

stac-react

React components and hooks for building STAC-API front-ends
TypeScript
21
star
67

ginkgo

Default theme for Open Atrium.
PHP
21
star
68

titiler-xarray

[DEMO] TiTiler extension for xarray
Python
21
star
69

python-seed

Project template for Python projects
Python
21
star
70

gl-director

GL Director, an interface to easily generate terrain flyovers for your app using Mapbox GL JS
JavaScript
21
star
71

supercluster-rs

Rust implementation of Supercluster for fast hierarchical point clustering
Rust
21
star
72

JosmMagicWand

JOSM Plugin allows select areas to label using a range of colors,
Java
20
star
73

project-seed

A basic starting point for projects.
JavaScript
20
star
74

titiler-image

TiTiler extension to work with non-geo images
Python
18
star
75

pearl-frontend

PEARL (Planetary Computer Land Cover Mapping) Frontend
JavaScript
18
star
76

satTS

ML pipeline to classify crop types with multi-spectral and multi-temporal EO data
Jupyter Notebook
18
star
77

bones-auth

Base authentication model, view and middleware
JavaScript
18
star
78

pydantic-ssm-settings

Replace Pydantic's builtin Secret Support with a configuration provider that loads parameters from AWS Systems Manager Parameter Store.
Python
18
star
79

openlayers_slim

A configured and compressed version of OpenLayers, suitable for most common applications.
JavaScript
17
star
80

litecal

A lite clean calendar UI.
PHP
17
star
81

seed

DS templates for everything
JavaScript
17
star
82

sentinel-2-cog

Convert Sentinel-2 JPEG 2000 to COG with AWS Lambda
Python
17
star
83

kenya-bank

Kenya Educational Mapping Site
JavaScript
17
star
84

co2ordinate

Find the most efficient place to gather GHG-wise
TypeScript
16
star
85

skynet-scrub

GUI for editing machine learning outputs
JavaScript
16
star
86

geofield

Defines a six column field for storing lat/lon data and bounding box data.
JavaScript
15
star
87

couch-sqlite

JavaScript
15
star
88

pointcloud-to-cog

Convert Point cloud data to Cloud Optimized GeoTIFF using AWS Lambda
Python
15
star
89

hapi-paginate

A simple pagination for hapijs responses
JavaScript
14
star
90

connectivity-atlas

An interactive map of global infrastructure.
HTML
14
star
91

fastapi_authorization_gateway

Python
14
star
92

jake

Minimal, lightweight theme for Managing News.
PHP
13
star
93

skynet-scrub-server

Backing store for developmentseed/skynet-scrub
JavaScript
13
star
94

titiler-mvt

Create MVT dynamically from COG
Python
13
star
95

simpleshare

Simple sharing of URLs using various methods. Supports Twitter, Facebook and email.
PHP
13
star
96

mapbox-gl-topojson

JavaScript
13
star
97

jekyll-filename

Ruby
13
star
98

our-forests-tomorrow

Visualizing European forests future. Based on the EU-Trees4F study by Mauri et al.
TypeScript
13
star
99

pearl-ml-pipeline

Python
12
star
100

worldpop

Get the population of regions that you draw!
JavaScript
12
star