Code Monkey home page Code Monkey logo

parceldelineation's Introduction

ParcelDelineation

Training models

The script contains various parameters you can tweak. You can specify to use a dilated UNet (is_dilated), pretrained UNet (is_imagenet), stacked with 9-images (is_stacked), etc. By default, the model uses a pretrained stacked U-Net model.

python train_unet.py 

Evaluation

Spits out prediction numpy array of model. Also does evaluation of F1 score and accuracy. Expects a csv file that has columns image, mask. 'image' refers to path of the image and 'mask' refers to the path of the binary mask. See more in dataset preparation section.

python predict_model.py [path to saved model] [path to csv containing paths to images (e.g. test/validation dataframe)]

Does evaluation based on the numpy array paths of the model.

python evaluate_model.py [path to array of predictions] [path to test/validation dataframe csv]

Dataset preparation:

  1. Download the French polygons dataset from

https://www.data.gouv.fr/en/datasets/registre-parcellaire-graphique-rpg-contours-des-parcelles-et-ilots-culturaux-et-leur-groupe-de-cultures-majoritaire/

  1. Unzip the dataset under ./data directory

  2. Samples random polygons. The number of polygons can be set in the script. Default is set to 2000.

python utils/sample_shp.py   
  1. Reads the shape file to gets the centroid of each polygon (Used as getting coordinates for getting satellite images such as SENTINEL-2). The centroids are the center of the satellite images.
python utils/get_centroid.py   
  1. (a) From step 5, you can extract your own satellite imagery from a public dataset (such as SENTINEL-2 or Digital Globe) and prepare a csv file containing max lat, max lon, min lat, min lon of the image. For satellite images (which comes in tfrecord format for our dataset), the following script extracts jpegs and also the csv file for the max lat, max lon, min lat, min lon of the image, useful for the next step to overlay the polygons onto image. The max lat, max lon, min lat, min lon will specify how large each satellite image spans in size.
python convert_tfrecords_jpeg.py
  1. (b) Gets only polygons that overlap in bounds of extracted images (Requires a csv-file with a unique parcel identifier, max lat, max lon, min lat, min long of each extracted image).
python utils/shp2geo.py
  1. Creates the masks (boundary and filled) of the extracted polygons and images (File input/output paths are specified in script)
python utils/create_mask.py
  1. Splits data into train/test/val
python utils/split_data.py

Reference Code:

Unet pretrained models: https://github.com/qubvel/segmentation_models

Unet keras model: https://github.com/zhixuhao/unet

Deeplabv3 (beta): https://github.com/tensorflow/models/tree/master/research/deeplab

parceldelineation's People

Contributors

hanlinaung88 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.