Giter Site home page Giter Site logo

raster-vision-examples's Introduction

Raster Vision Examples (for RV < 0.12)

This repository contains examples of using Raster Vision on open datasets.

⚠️ For RV >= 0.12, the examples have moved into the main repo.

Note: The master branch of this examples repo should be used in conjunction with the master branch (or latest Docker image tag) of Raster Vision which contains the latest changes. For versions of this examples repo that correspond to stable, released versions of Raster Vision, see:

Table of Contents:

Setup and Requirements

⚠️ PyTorch vs. Tensorflow Backends

We have recently added a set of PyTorch-based backends to Raster Vision. The existing Tensorflow-based backends are still there, but we do not plan on maintaining them, so we suggest starting to use the PyTorch ones. The examples in this repo default to using the PyTorch backends. However, for three of the examples there is a use_tf option which allows running it using a Tensorflow backend: examples.cowc.object_detection, examples.potsdam.semantic_segmentation, and examples.spacenet.rio.chip_classification.

Docker

You'll need docker (preferably version 18 or above) installed. After cloning this repo, to build the Docker images, run the following command:

> docker/build

This will pull down the latest raster-vision:pytorch-latest, raster-vision:tf-cpu-latest, and raster-vision:tf-gpu-latest Docker images and add some of this repo's code to them. If you only want the Tensorflow images, use the --tf flag, and similar for --pytorch. Before running the container, set an environment variable to a local directory in which to store data.

> export RASTER_VISION_DATA_DIR="/path/to/data"

To run a Bash console in the Docker container, invoke:

> docker/run

This will mount the following local directories to directories inside the container:

  • $RASTER_VISION_DATA_DIR -> /opt/data/
  • examples/ -> /opt/src/examples/

This script also has options for forwarding AWS credentials, running Jupyter notebooks, and switching between different images, which can be seen below.

Remember to use the correct image for the backend you are using!

> ./docker/run --help
Usage: run <options> <command>
Run a console in the raster-vision-examples-cpu Docker image locally.

Environment variables:
RASTER_VISION_DATA_DIR (directory for storing data; mounted to /opt/data)
AWS_PROFILE (optional AWS profile)
RASTER_VISION_REPO (optional path to main RV repo; mounted to /opt/src)

Options:
--aws forwards AWS credentials (sets AWS_PROFILE env var and mounts ~/.aws to /root/.aws)
--tensorboard maps port 6006
--gpu use the NVIDIA runtime and GPU image
--name sets the name of the running container
--jupyter forwards port 8888, mounts ./notebooks to /opt/notebooks, and runs Jupyter
--debug maps port 3007 on localhost to 3000 inside container
--tf-gpu use raster-vision-examples-tf-gpu image and nvidia runtime
--tf-cpu use raster-vision-examples-tf-cpu image
--pytorch-gpu use raster-vision-examples-pytorch image and nvidia runtime

Note: raster-vision-examples-pytorch image is used by default
All arguments after above options are passed to 'docker run'.

Debug Mode

For debugging, it can be helpful to use a local copy of the Raster Vision source code rather than the version baked into the default Docker image. To do this, you can set the RASTER_VISION_REPO environment variable to the location of the main repo on your local filesystem. If this is set, docker/build will set the base image to raster-vision-{cpu,gpu}, and docker/run will mount $RASTER_VISION_REPO/rastervision to /opt/src/rastervision inside the container. You can then set breakpoints in your local copy of Raster Vision in order to debug experiments running inside the container.

How to Run an Example

There is a common structure across all of the examples which represents a best practice for defining experiments. Running an example involves the following steps.

  • Acquire raw dataset.
  • (Optional) Get processed dataset which is derived from the raw dataset, either using a Jupyter notebook, or by downloading the processed dataset.
  • (Optional) Do an abbreviated test run of the experiment on a small subset of data locally.
  • Run full experiment on GPU.
  • Inspect output
  • (Optional) Make predictions on new imagery

Each of the experiments has several arguments that can be set on the command line:

  • The input data for each experiment is divided into two directories: the raw data which is publicly distributed, and the processed data which is derived from the raw data. These two directories are set using the raw_uri and processed_uri arguments.
  • The output generated by the experiment is stored in the directory set by the root_uri argument.
  • The raw_uri, processed_uri, and root_uri can each be local or remote (on S3), and don't need to agree on whether they are local or remote.
  • Experiments have a test argument which runs an abbreviated experiment for testing/debugging purposes.

In the next section, we describe in detail how to run one of the examples, SpaceNet Rio Chip Classification. For other examples, we only note example-specific details.

SpaceNet Rio Building Chip Classification

This example performs chip classification to detect buildings on the Rio AOI of the SpaceNet dataset.

Step 1: Acquire Raw Dataset

The dataset is stored on AWS S3 at s3://spacenet-dataset. You will need an AWS account to access this dataset, but it will not be charged for accessing it. (To forward you AWS credentials into the container, use docker/run --aws).

Optional: to run this example with the data stored locally, first copy the data using something like the following inside the container.

aws s3 sync s3://spacenet-dataset/AOIs/AOI_1_Rio/ /opt/data/spacenet-dataset/AOIs/AOI_1_Rio/

Step 2: Run the Jupyter Notebook

You'll need to do some data preprocessing, which we can do in the Jupyter notebook supplied.

> docker/run --jupyter [--aws]

The --aws option is only needed if pulling data from S3. In Jupyter inside the browser, navigate to the spacenet/spacenet_rio_chip_classification_data_prep.ipynb notebook. Set the URIs in the first cell and then run the rest of the notebook. Set the processed_uri to a local or S3 URI depending on where you want to run the experiment.

Jupyter Notebook

Step 3: Do a test run locally

The experiment we want to run is in examples/spacenet/rio/chip_classification.py. To run this, first get to the Docker console using:

> docker/run [--aws] [--gpu] [--tensorboard]

The --aws option is only needed if running experiments on AWS or using data stored on S3. The --gpu option should only be used if running on a local GPU. The --tensorboard option should be used if running locally and you would like to view Tensorboard. The test run can be executed using something like:

export RAW_URI="s3://spacenet-dataset/"
export PROCESSED_URI="/opt/data/examples/spacenet/rio/processed-data"
export ROOT_URI="/opt/data/examples/spacenet/rio/local-output"
rastervision run local -e examples.spacenet.rio.chip_classification \
    -a raw_uri $RAW_URI -a processed_uri $PROCESSED_URI -a root_uri $ROOT_URI \
    -a test True --splits 2

The sample above assumes that the raw data is on S3, and the processed data and output are stored locally. The raw_uri directory is assumed to contain an AOI_1_Rio subdirectory. This runs two parallel jobs for the chip and predict commands via --splits 2. See rastervision --help and rastervision run --help for more usage information.

Note that when running with -a test True, some crops of the test scenes are created and stored in processed_uri/crops/. All of the examples that use big image files use this trick to make the experiment run faster in test mode.

After running this, the main thing to check is that it didn't crash, and that the debug chips look correct. The debug chips can be found in the debug zip files in $ROOT_URI/chip/spacenet-rio-chip-classification/.

Step 4: Run full experiment

To run the full experiment on GPUs using AWS Batch, use something like the following. Note that all the URIs are on S3 since remote instances will not have access to your local file system.

export RAW_URI="s3://spacenet-dataset/"
export PROCESSED_URI="s3://mybucket/examples/spacenet/rio/processed-data"
export ROOT_URI="s3://mybucket/examples/spacenet/rio/remote-output"
rastervision run aws_batch -e examples.spacenet.rio.chip_classification \
    -a raw_uri $RAW_URI -a processed_uri $PROCESSED_URI -a root_uri $ROOT_URI \
    -a test False --splits 8

For instructions on setting up AWS Batch resources and configuring Raster Vision to use them, see AWS Batch Setup. To monitor the training process using Tensorboard, visit <public dns>:6006 for the EC2 instance running the training job.

If you would like to run on a local GPU, replace aws_batch with local, and use local URIs. To monitor the training process using Tensorboard, visit localhost:6006, assuming you used docker/run --tensorboard.

Step 5: Inspect results

After everything completes, which should take about 1.5 hours if you're running on AWS using a p3.2xlarge instance for training and 8 splits, you should be able to find the predictions over the validation scenes in $root_uri/predict/spacenet-rio-chip-classification/. The evaluation metrics can be found in $root_uri/eval/spacenet-rio-chip-classification/eval.json. This is an example of the scores from a run, which show an F1 score of 0.96 for detecting chips with buildings.

[
    {
        "gt_count": 1460.0,
        "count_error": 0.0,
        "f1": 0.962031922725018,
        "class_name": "building",
        "recall": 0.9527397260273971,
        "precision": 0.9716098420590342,
        "class_id": 1
    },
    {
        "gt_count": 2314.0,
        "count_error": 0.0,
        "f1": 0.9763865660344931,
        "class_name": "no_building",
        "recall": 0.9822817631806394,
        "precision": 0.9706292067263268,
        "class_id": 2
    },
    {
        "gt_count": 3774.0,
        "count_error": 0.0,
        "f1": 0.970833365390128,
        "class_name": "average",
        "recall": 0.9708532061473236,
        "precision": 0.9710085728062825,
        "class_id": -1
    }
]

Step 6: Predict on new imagery

After running an experiment, a predict package is saved into $root_uri/bundle/spacenet-rio-chip-classification/. This can be used to make predictions on new images. See the Model Zoo section for more details.

Visualization using QGIS

To visualize a Raster Vision experiment, you can use QGIS to display the imagery, ground truth, and predictions associated with each scene. Although it's possible to just drag and drop files into QGIS, it's often more convenient to write a script to do this. Here is an example of a script to visualize the results for SpaceNet Vegas Semantic Segmentation.

Other Examples

SpaceNet Rio Building Semantic Segmentation

This experiment trains a semantic segmentation model to find buildings using the SpaceNet Rio dataset. A prerequisite is running the Rio Chip Classification Jupyter notebook, and all other details are the same as in that example.

Below are sample predictions and eval metrics.

SpaceNet Rio Building Semantic Segmentation

Eval Metrics
"overall": [
    {
        "recall": 0.6933642097495366,
        "precision": 0.7181072275154092,
        "class_name": "Building",
        "gt_count": 11480607,
        "count_error": 119679.64457523893,
        "f1": 0.7023217656506746,
        "class_id": 1
    },
    {
        "recall": 0.978149141560173,
        "precision": 0.9763586125303796,
        "class_name": "Background",
        "gt_count": 147757124,
        "count_error": 31820.188126279452,
        "f1": 0.9771849696422493,
        "class_id": 2
    },
    {
        "recall": 0.9576169230896666,
        "precision": 0.9577393905661922,
        "class_name": "average",
        "gt_count": 159237731,
        "count_error": 38154.615804881076,
        "f1": 0.9573680807430468,
        "class_id": null
    }
]

SpaceNet Vegas

This is a collection of examples using the SpaceNet Vegas dataset.

SpaceNet Vegas Simple Semantic Segmentation

This experiment is a simple example of doing semantic segmentation: the code is simple, there is no need to pre-process any data, and you don't need permission to use the data.

Arguments:

  • raw_uri should be set to the root of the SpaceNet data repository, which is at s3://spacenet-dataset, or a local copy of it. A copy only needs to contain the SpaceNet_Buildings_Dataset_Round2/spacenetV2_Train/AOI_2_Vegas subdirectory.
  • processed_uri should not be set because there is no processed data in this example.

Below are sample predictions and eval metrics.

SpaceNet Vegas Buildings in QGIS

Eval Metrics
[
    {
        "class_id": 1,
        "precision": 0.9166443308607926,
        "recall": 0.7788752910479124,
        "gt_count": 62924777,
        "count_error": 31524.39656560088,
        "class_name": "Building",
        "f1": 0.8387483150445183
    },
    {
        "class_id": 2,
        "precision": 0.9480938442744736,
        "recall": 0.9648479452702291,
        "gt_count": 262400223,
        "count_error": 29476.379317139523,
        "class_name": "Background",
        "f1": 0.9527945047747147
    },
    {
        "class_id": null,
        "precision": 0.942010839223173,
        "recall": 0.9288768769691843,
        "gt_count": 325325000,
        "count_error": 29872.509429032507,
        "class_name": "average",
        "f1": 0.930735545099091
    }
]

SpaceNet Vegas Roads and Buildings: All Tasks

This experiment can be configured to do any of the three tasks on either roads or buildings. It is an example of how to structure experiment code to support a variety of options. It also demonstrates how to utilize line strings as labels for roads using buffering, and generating polygon output for semantic segmentation on buildings.

Arguments:

  • raw_uri should be set to the root of the SpaceNet data repository, which is at s3://spacenet-dataset, or a local copy of it. For buildings, a copy only needs to contain the SpaceNet_Buildings_Dataset_Round2/spacenetV2_Train/AOI_2_Vegas subdirectory. For roads, SpaceNet_Roads_Competition/Train/AOI_2_Vegas_Roads_Train.
  • processed_uri should not be set because there is no processed data in this example.
  • task_type can be set to chip_classification, object_detection, or semantic_segmentation.
  • target can be buildings or roads

Note that for semantic segmentation on buildings, polygon output in the form of GeoJSON files will be saved to the predict directory alongside the GeoTIFF files. In addition, a vector evaluation file using SpaceNet metrics will be saved to the eval directory. Running semantic segmentation on roads trains a Mobilenet for 100k steps which takes about 6hrs on a P3 instance.

Sample predictions and eval metrics can be seen below.

Spacenet Vegas Roads in QGIS

Eval Metrics
[
    {
        "count_error": 131320.3497452814,
        "precision": 0.79827727905979,
        "f1": 0.7733719736453241,
        "class_name": "Road",
        "class_id": 1,
        "recall": 0.7574370618553649,
        "gt_count": 47364639
    },
    {
        "count_error": 213788.03361026093,
        "precision": 0.9557015578601281,
        "f1": 0.909516065847437,
        "class_name": "Background",
        "class_id": 2,
        "recall": 0.8988113906793058,
        "gt_count": 283875361
    },
    {
        "count_error": 201995.82229692052,
        "precision": 0.9331911601569118,
        "f1": 0.8900485625895702,
        "class_name": "average",
        "class_id": null,
        "recall": 0.8785960059171598,
        "gt_count": 331240000
    }
]
Variant: Use vector tiles to get labels

It is possible to use vector tiles as a source of labels, either in z/x/y or .mbtiles format. To use vector tiles instead of GeoJSON, run the experiment with the following argument: -a vector_tile_options "<uri>,<zoom>,<id_field>". See the vector tile docs for a description of these arguments.

To run this example using OSM tiles in .mbtiles format, first create an extract around Las Vegas using:

cd /opt/data
wget https://s3.amazonaws.com/mapbox/osm-qa-tiles-production/latest.country/united_states_of_america.mbtiles.gz
# unzipping takes a few minutes
gunzip united_states_of_america.mbtiles.gz
npm install tilelive-copy
tilelive-copy \
    --minzoom=0 --maxzoom=14 \
    --bounds="-115.43472290039062,35.98689628443789,-114.91836547851562,36.361586786517776" \    united_states_of_america.mbtiles vegas.mbtiles

Using the entire USA file would be very slow. Then run the roads example using something like -a vector_tile_options "/opt/data/vegas.mbtiles,12,@id".

If you are not using OSM tiles, you might need to change the class_id_to_filter values in the experiment configuration. Each class_id_to_filter is a mapping from class_id to a Mapbox GL filter which is to used to assign class ids to features based on their properties field.

SpaceNet Vegas Hyperparameter Search

This experiment set runs several related experiments in which the base learning rate varies over them. These experiments are all related, in that they all work over the same dataset (SpaceNet Vegas buildings), and in fact the analyze and chip stages are shared between all of the experiments. That sharing of early stages is achieving by making sure that the chip_key and analyze_key are the same for all of the experiments so that Raster Vision can detect the redundancy.

Arguments:

  • raw_uri should be set to the root of the SpaceNet data repository, which is at s3://spacenet-dataset, or a local copy of it. A copy only needs to contain the SpaceNet_Buildings_Dataset_Round2/spacenetV2_Train/AOI_2_Vegas subdirectory.
  • processed_uri should not be set because there is no processed data in this example.
  • learning_rates is a comma-delimited list of learning rates to use for the experiments. Example: -a learning_rates '0.0001,0.001,0.002,0.003,0.004,0.005,0.10'

The number of steps is 10,000 for all experiments. Because this is for demonstration purposes only, the training dataset has been reduced to only 128 scenes.

The F1 scores for buildings as a function of base learning rate are shown below.

Base Learning Rate Building F1 Score
0.0001 0.7337961752864327
0.001 0.7616993477580662
0.002 0.7889177881341606
0.003 0.7864549469541627
0.004 0.4194065664072375
0.005 0.5070458576486434
0.1 0.5046626369613472

Disclaimer: We are not claiming that the numbers above are useful or interesting, the sole intent here is demonstrate how to vary hyperparameters using Raster Vision.

ISPRS Potsdam Semantic Segmentation

This experiment performs semantic segmentation on the ISPRS Potsdam dataset. The dataset consists of 5cm aerial imagery over Potsdam, Germany, segmented into six classes including building, tree, low vegetation, impervious, car, and clutter. For more info see our blog post.

Data:

  • The dataset can only be downloaded after filling in this request form. After your request is granted, follow the link to 'POTSDAM 2D LABELING' and download and unzip 4_Ortho_RGBIR.zip, and 5_Labels_for_participants.zip into a directory, and then upload to S3 if desired.

Arguments:

  • raw_uri should contain 4_Ortho_RGBIR and 5_Labels_for_participants subdirectories.
  • processed_uri should be set to a directory which will be used to store test crops.

Below are sample predictions and eval metrics.

Potsdam segmentation predictions

Eval Metrics
[
        {
            "precision": 0.9003686311706696,
            "recall": 0.8951149482868683,
            "f1": 0.8973353554371246,
            "count_error": 129486.40233074076,
            "gt_count": 1746655.0,
            "conf_mat": [
                0.0,
                1563457.0,
                7796.0,
                5679.0,
                10811.0,
                126943.0,
                31969.0
            ],
            "class_id": 1,
            "class_name": "Car"
        },
        {
            "precision": 0.9630047813515502,
            "recall": 0.9427071079228886,
            "f1": 0.9525027991356272,
            "count_error": 1000118.8466519706,
            "gt_count": 28166583.0,
            "conf_mat": [
                0.0,
                6976.0,
                26552838.0,
                743241.0,
                71031.0,
                556772.0,
                235725.0
            ],
            "class_id": 2,
            "class_name": "Building"
        },
        {
            "precision": 0.8466609755403327,
            "recall": 0.8983221897241067,
            "f1": 0.8715991836041085,
            "count_error": 3027173.8852443425,
            "gt_count": 30140893.0,
            "conf_mat": [
                0.0,
                4306.0,
                257258.0,
                27076233.0,
                1405095.0,
                1110647.0,
                287354.0
            ],
            "class_id": 3,
            "class_name": "Low Vegetation"
        },
        {
            "precision": 0.883517319858661,
            "recall": 0.8089167109558072,
            "f1": 0.8439042868078945,
            "count_error": 1882745.6869677808,
            "gt_count": 16928529.0,
            "conf_mat": [
                0.0,
                34522.0,
                157012.0,
                2484523.0,
                13693770.0,
                485790.0,
                72912.0
            ],
            "class_id": 4,
            "class_name": "Tree"
        },
        {
            "precision": 0.9123212945945467,
            "recall": 0.9110533473255575,
            "f1": 0.9115789047144218,
            "count_error": 1785561.1048684688,
            "gt_count": 29352493.0,
            "conf_mat": [
                0.0,
                99015.0,
                451628.0,
                1307686.0,
                262292.0,
                26741687.0,
                490185.0
            ],
            "class_id": 5,
            "class_name": "Impervious"
        },
        {
            "precision": 0.42014399072332975,
            "recall": 0.47418711749488085,
            "f1": 0.44406088467218563,
            "count_error": 787395.6814824425,
            "gt_count": 1664847.0,
            "conf_mat": [
                0.0,
                28642.0,
                157364.0,
                340012.0,
                59034.0,
                290346.0,
                789449.0
            ],
            "class_id": 6,
            "class_name": "Clutter"
        },
        {
            "precision": 0.8949197573420392,
            "recall": 0.8927540185185187,
            "f1": 0.8930493260224918,
            "count_error": 1900291.674768574,
            "gt_count": 108000000.0,
            "conf_mat": [
                [
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0
                ],
                [
                    0.0,
                    1563457.0,
                    7796.0,
                    5679.0,
                    10811.0,
                    126943.0,
                    31969.0
                ],
                [
                    0.0,
                    6976.0,
                    26552838.0,
                    743241.0,
                    71031.0,
                    556772.0,
                    235725.0
                ],
                [
                    0.0,
                    4306.0,
                    257258.0,
                    27076233.0,
                    1405095.0,
                    1110647.0,
                    287354.0
                ],
                [
                    0.0,
                    34522.0,
                    157012.0,
                    2484523.0,
                    13693770.0,
                    485790.0,
                    72912.0
                ],
                [
                    0.0,
                    99015.0,
                    451628.0,
                    1307686.0,
                    262292.0,
                    26741687.0,
                    490185.0
                ],
                [
                    0.0,
                    28642.0,
                    157364.0,
                    340012.0,
                    59034.0,
                    290346.0,
                    789449.0
                ]
            ],
            "class_id": null,
            "class_name": "average"
        }
]

COWC Potsdam Car Object Detection

This experiment performs object detection on cars with the Cars Overhead With Context dataset over Potsdam, Germany.

Data:

  • The imagery can only be downloaded after filling in this request form. After your request is granted, follow the link to 'POTSDAM 2D LABELING' and download and unzip 4_Ortho_RGBIR.zip into a directory, and then upload to S3 if desired. (This step uses the same imagery as ISPRS Potsdam Semantic Segmentation)
  • Download the processed labels and unzip. These files were generated from the COWC car detection dataset using scripts in cowc.data. TODO: make a Jupyter notebook showing how to process the raw labels from scratch.

Arguments:

  • raw_uri should point to the imagery directory created above, and should contain the 4_Ortho_RGBIR subdirectory.
  • processed_uri should point to the labels directory created above. It should contain the labels/all subdirectory.

Below are sample predictions and eval metrics.

COWC Potsdam predictions

Eval Metrics
    {
        "precision": 0.9390652367984924,
        "recall": 0.9524752475247524,
        "f1": 0.945173902480464,
        "count_error": 0.015841584158415842,
        "gt_count": 505.0,
        "class_id": 1,
        "class_name": "vehicle"
    },
    {
        "precision": 0.9390652367984924,
        "recall": 0.9524752475247524,
        "f1": 0.945173902480464,
        "count_error": 0.015841584158415842,
        "gt_count": 505.0,
        "class_id": null,
        "class_name": "average"
    }

xView Vehicle Object Detection

This experiment performs object detection to find vehicles using the DIUx xView Detection Challenge dataset.

Data:

Arguments:

  • The raw_uri should point to the directory created above, and contain a labels GeoJSON file named xView_train.geojson, and a directory named train_images.
  • The processed_uri should point to the processed data generated by the notebook.

Below are sample predictions and eval metrics.

xView predictions

Eval Metrics
{
    "class_name": "vehicle",
    "precision": 0.4789625193065175,
    "class_id": 1,
    "f1": 0.4036499117825103,
    "recall": 0.3597840599059615,
    "count_error": -0.2613920009287745,
    "gt_count": 17227
},
{
    "class_name": "average",
    "precision": 0.4789625193065175,
    "class_id": null,
    "f1": 0.4036499117825103,
    "recall": 0.3597840599059615,
    "count_error": -0.2613920009287745,
    "gt_count": 17227
}

Model Zoo

Using the Model Zoo, you can download prediction packages which contain pre-trained models and configuration, and then run them on sample test images that the model wasn't trained on.

> rastervision predict <predict_package> <infile> <outfile>

Note that the input file is assumed to have the same channel order and statistics as the images the model was trained on. See rastervision predict --help to see options for manually overriding these. It shouldn't take more than a minute on a CPU to make predictions for each sample. For some of the examples, there are also model files that can be used for fine-tuning on another dataset.

Disclaimer: These models are provided for testing and demonstration purposes and aren't particularly accurate. As is usually the case for deep learning models, the accuracy drops greatly when used on input that is outside the training distribution. In other words, a model trained in one city probably won't work well in another city (unless they are very similar) or at a different imagery resolution.

PyTorch Models

For the PyTorch models, the prediction package (when unzipped) contains a model file which can be used for fine-tuning.

Dataset Task Model Prediction Package Sample Image
SpaceNet Rio Buildings Chip Classification Resnet50 link link
SpaceNet Vegas Buildings Semantic Segmentation DeeplabV3/Resnet50 link link
SpaceNet Vegas Roads Semantic Segmentation DeeplabV3/Resnet50 link link
ISPRS Potsdam Semantic Segmentation DeeplabV3/Resnet50 link link
COWC Potsdam (Cars) Object Detection Faster-RCNN/Resnet18 link link

Tensorflow Models

Dataset Task Model Prediction Package Sample Image Model (for fine-tuning)
SpaceNet Rio Buildings Chip Classification Resnet50 link link link
SpaceNet Vegas Buildings Semantic Segmentation Mobilenet link link n/a
SpaceNet Vegas Roads Semantic Segmentation Mobilenet link link link
ISPRS Potsdam Semantic Segmentation Mobilenet link link link
COWC Potsdam (Cars) Object Detection Mobilenet link link n/a
xView Vehicle Object Detection Mobilenet link link n/a

raster-vision-examples's People

Contributors

jamesmcclain avatar lewfish avatar lossyrob avatar simonkassel avatar yoninachmany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raster-vision-examples's Issues

Standardize examples

All examples should have the test option that Vegas has. This is to make it easier to test that all examples run.

Ideally we should also add use_remote_data and provide a tiny subset of the dataset that is compatible with the test option to make running tests faster.

Most of the instructions are outdated

Almost every examples' instructions are outdated.
Docker/Run script also outdated. It cant run proper docker images.
SpaceNet dataset on S3 changed its directory hierarchy but they are not updated here

Question regarding the pretrained models...

These models look like Tensorflow exported object detection models (with scores, classes ... etc tensors)

If I run rastervision predict https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo/xview-vehicle-od/predict_package.zip https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo/xview-vehicle-od/1677.tif s3://mybucket/1047-raster.tiff

The output is a Geojson file containing all of the detected objects. It's quite accurate.

If I take the same model and use it in Tensorflow natively, it detects nothing on that picture.

Why?

ImportError: No module named 'spacenet.semantic_segmentation'

When I run
rastervision run local -e spacenet.semantic_segmentation -a root_uri /opt/src/rastervision True -a /opt/src/spacenet -a target s3://spacenet-dataset/SpaceNet_Roads_Competition/AOI_2_Vegas_Roads_Train.tar.gz

in my exmaples container, I get an "ImportError"...

Call Stack:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/src/rastervision/__main__.py", line 17, in <module>
    rv.main()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/opt/src/rastervision/cli/main.py", line 136, in run
    experiments = loader.load_from_module(experiment_module)
  File "/opt/src/rastervision/experiment/experiment_loader.py", line 50, in load_from_module
    module = import_module(name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'spacenet.semantic_segmentation'

Add versioning to this repo

With each minor and major release, we should add a version branch to this repo. Each version branch will use that version of the RV Docker image and the examples should work with that version. The master branch should work with the develop branch of RV. Currently, the master branch uses the 0.8 version of the image which is incorrect.

fail install on windows with python 3.7 64bits

I have next error, when try install rastervision from VisualStudio or command line in Windows 10:

Usuario

/c/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64
$ ./python -m pip install rastervision --user --no-cache-dir
Collecting rastervision
Downloading https://files.pythonhosted.org/packages/08/e7/353df3b3cb7a8caab68702d8d72b2ae4c826b54d5e4a4213212d61fb0d3e/rastervision-0.10.0-py3-none-any.whl (396kB)
ERROR: Could not install packages due to an EnvironmentError: [WinError 267] El nombre del directorio no es v▒lido: 'C:\Users\Usuario\AppData\Local\Temp\pip-install-fpxxp1qz\rastervision\rastervision/command/aux'

I have tried different things but I have not been able to install it on windows. I have also tried version 0.9.0 and neither
I know that it is not a priority for rastervision to offer support on windows, however for me it is important to do small tests locally.
Thanks

training stage error Keras validatation_steps=None

I encountered this error trying to run the rio spacenet example in Google Colab

Ensuring input files exist [####################################] 100%
Checking for existing output [####################################] 100%
Saving command configuration to data/examples/spacenet/rio/remote-output/train/spacenet-rio-chip-classification-test/command-config-0.json...
Saving command configuration to data/examples/spacenet/rio/remote-output/bundle/spacenet-rio-chip-classification-test/command-config-0.json...
Saving command configuration to data/examples/spacenet/rio/remote-output/predict/spacenet-rio-chip-classification-test/command-config-0.json...
Saving command configuration to data/examples/spacenet/rio/remote-output/eval/spacenet-rio-chip-classification-test/command-config-0.json...
python -m rastervision run_command data/examples/spacenet/rio/remote-output/train/spacenet-rio-chip-classification-test/command-config-0.json
Training model...
/usr/local/lib/python3.6/dist-packages/pluginbase.py:439: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
fromlist, level)
Using TensorFlow backend.
2019-06-06 14:27:00:rastervision.utils.files: INFO - Downloading https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5 to /tmp/tmp7n3lkztl/tmpd83op6nh/http/github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
2019-06-06 14:27:03.794498: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200000000 Hz
2019-06-06 14:27:03.794813: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x14cf4a0 executing computations on platform Host. Devices:
2019-06-06 14:27:03.794849: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
2019-06-06 14:27:04.065789: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-06-06 14:27:04.066325: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x14cf080 executing computations on platform CUDA. Devices:
2019-06-06 14:27:04.066371: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): Tesla T4, Compute Capability 7.5
2019-06-06 14:27:04.066753: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59
pciBusID: 0000:00:04.0
totalMemory: 14.73GiB freeMemory: 14.60GiB
2019-06-06 14:27:04.066777: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-06-06 14:27:05.517909: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-06-06 14:27:05.517977: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0
2019-06-06 14:27:05.517990: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N
2019-06-06 14:27:05.518287: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:42] Overriding allow_growth setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2019-06-06 14:27:05.518385: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 14115 MB memory) -> physical GPU (device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5)
Found 0 images belonging to 2 classes.
Found 0 images belonging to 2 classes.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
TensorBoard 1.13.1 at http://fea6b3f9897c:6006 (Press CTRL+C to quit)
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/rastervision/main.py", line 17, in
rv.main()
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/rastervision/cli/main.py", line 292, in run_command
rv.runner.CommandRunner.run(command_config_uri)
File "/usr/local/lib/python3.6/dist-packages/rastervision/runner/command_runner.py", line 11, in run
CommandRunner.run_from_proto(msg)
File "/usr/local/lib/python3.6/dist-packages/rastervision/runner/command_runner.py", line 17, in run_from_proto
command.run()
File "/usr/local/lib/python3.6/dist-packages/rastervision/command/train_command.py", line 21, in run
task.train(tmp_dir)
File "/usr/local/lib/python3.6/dist-packages/rastervision/task/task.py", line 138, in train
self.backend.train(tmp_dir)
File "/usr/local/lib/python3.6/dist-packages/rastervision/backend/keras_classification/backend.py", line 263, in train
_train(backend_config_path, pretrained_model_path, do_monitoring)
File "/usr/local/lib/python3.6/dist-packages/rastervision/backend/keras_classification/commands/train.py", line 15, in _train
trainer.train(do_monitoring)
File "/usr/local/lib/python3.6/dist-packages/rastervision/backend/keras_classification/core/trainer.py", line 150, in train
callbacks=callbacks)
File "/usr/local/lib/python3.6/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training_generator.py", line 68, in fit_generator
raise ValueError('validation_steps=None is only valid for a'
ValueError: validation_steps=None is only valid for a generator based on the keras.utils.Sequence class. Please specify validation_steps or use the keras.utils.Sequence class.
TensorBoard caught SIGTERM; exiting...
/tmp/tmpkna9hjv6/tmpfdeg5814/Makefile:6: recipe for target '2' failed
make: *** [2] Error 1

Investigate using SpaceNet examples with no AWS account set up

A user ran the spacenet example notebook without having an aws cli configuration on their machine. This cause a ProfileNotFound: The config profile (default) could not be found error on the s3 = boto3.client('s3') line.

Modify the example notebook and/or docker container setup to allow users without aws cli set up on the host machine to run the notebook.

AttributeError: module 'rastervision' has no attribute 'RASTERIZED_SOURCE'

When I run

rastervision run local -e spacenet.vegas -a test True -a root_uri /opt/data/spacenet-vegas -a target roads -a task_type semantic_segmentation -a use_remote_data False

I get an error
AttributeError: module 'rastervision' has no attribute 'RASTERIZED_SOURCE'

Am I missing something trivial?

Here's the trace:

root@31c4ef4f2499:/opt/src# rastervision run local -e spacenet.vegas -a test True -a root_uri /opt/data/spacenet-vegas -a target roads -a task_type semantic_segmentation -a use_remote_data False
None
<module 'rastervision' from '/opt/src/rastervision/__init__.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/src/rastervision/__main__.py", line 17, in <module>
    rv.main()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/opt/src/rastervision/cli/main.py", line 136, in run
    experiments = loader.load_from_module(experiment_module)
  File "/opt/src/rastervision/experiment/experiment_loader.py", line 54, in load_from_module
    result += self.load_from_set(experiment_set)
  File "/opt/src/rastervision/experiment/experiment_loader.py", line 58, in load_from_set
    return self.load_from_sets([experiment_set])
  File "/opt/src/rastervision/experiment/experiment_loader.py", line 81, in load_from_sets
    es = self.load_from_experiment(exp_func, full_name)
  File "/opt/src/rastervision/experiment/experiment_loader.py", line 112, in load_from_experiment
    exp = exp_func(**kwargs)
  File "/opt/src/spacenet/vegas.py", line 369, in exp_main
    vector_tile_options=vector_tile_options)
  File "/opt/src/spacenet/vegas.py", line 175, in build_dataset
    for id in train_ids]
  File "/opt/src/spacenet/vegas.py", line 175, in <listcomp>
    for id in train_ids]
  File "/opt/src/spacenet/vegas.py", line 121, in build_scene
    label_raster_source = rv.RasterSourceConfig.builder(rv.RASTERIZED_SOURCE) \
AttributeError: module 'rastervision' has no attribute 'RASTERIZED_SOURCE'

Vegas image 1000 is missing

We should skip this example because the image has been replaced with a folder on S3. We should also contact the contest organizers about this.

screen shot 2019-01-29 at 10 41 57 am

Add support for "developer mode"

This will be instructions (and potentially an alternative set of scripts) to mount local RV into the container and inherit from the local containers. This will make it easier to put print statements in RV and debug examples.

About the Spacenet Vegas Roads model

Hi

Can I ask how the Spacenet Vegas Roads model pretrained? Is it pretrained on COCO, VOC 2012 or other datasets? Also, I see that the network backbone is Mobilenet-v2, what's the depth-multiplier? Does the model employ ASPP and decoder modules?

Thanks

minimum system required to execute the examples

Hello
I face the examples, but I take a long time to execute them .. around 8 hours ..
what would be a resonable time to execute the object detection xview example?
What should be the minimum system required to execute the examples in a reasonable time?
what gpu? how much ram? etc...
Thank you

Add model zoo

There is one for Potsdam seg at s3://azavea-research-public-data/raster-vision/examples/potsdam/semseg-deeplab-mobilenet-predict-package.zip

Use replace_model=False

replace_model=True appears several times in the examples such as here

It seems like the examples should use default settings unless there's a reason not to. The default value of replace_model is False, so I would like to remove lines setting replace_model to True. I think this may have caused a problem for a user who was trying to resume training and had their checkpoint deleted.

predict not showing any output/error

Hi,

I installed rv 0.9 using pip install and everything is in order. However, when I run the predict command on the Potsdam predict package from the model zoo with an image from the same dataset, it runs (takes 2-3 seconds) but shows no error or any output in the desired directory.

The command is run from the same folder the files are located in:

rastervision predict ./predict_package.zip ./sample.tif ./predictions.tif

What can be the issue?

Both roads semantic segmentation and buildings object detection don't work.

Buildings chip classification and semantic segmentation are able to use, but both buildings object detection and roads semantic segmentation don't work.

Buildings object detection task fails immediately:

root@61c432694331:/opt/src# rastervision run local -e spacenet.vegas -a test False -a root_uri spacenet/Local_GPU/ -a target buildings -a task_type object_detection -a use_remote_data False -x
None
Checking for existing output [####################################] 100%
Saving command configuration to spacenet/Local_GPU/analyze/buildings_object_detection/command-config.json...
/opt/tf-models/object_detection/utils/np_box_ops.py:97: RuntimeWarning: invalid value encountered in true_divide
return intersect / areas
/opt/tf-models/object_detection/utils/np_box_list_ops.py:385: RuntimeWarning: invalid value encountered in greater_equal
keep_bool = np.greater_equal(intersection_over_area, np.array(minoverlap))
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/src/rastervision/main.py", line 17, in
rv.main()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/opt/src/rastervision/cli/main.py", line 253, in run_command
rv.runner.CommandRunner.run(command_config_uri)
File "/opt/src/rastervision/runner/command_runner.py", line 11, in run
CommandRunner.run_from_proto(msg)
File "/opt/src/rastervision/runner/command_runner.py", line 17, in run_from_proto
command.run()
File "/opt/src/rastervision/command/analyze_command.py", line 18, in run
map(lambda s: s.create_scene(cc.task, tmp_dir), cc.scenes))
File "/opt/src/rastervision/command/analyze_command.py", line 18, in
map(lambda s: s.create_scene(cc.task, tmp_dir), cc.scenes))
File "/opt/src/rastervision/data/scene_config.py", line 44, in create_scene
task_config, extent, crs_transformer, tmp_dir)
File "/opt/src/rastervision/data/label_source/object_detection_label_source_config.py", line 28, in create_source
task_config.class_map, extent)
File "/opt/src/rastervision/data/label_source/object_detection_label_source.py", line 30, in init
geojson, crs_transformer, extent=extent)
File "/opt/src/rastervision/data/label_source/utils.py", line 68, in geojson_to_object_detection_labels
'Geometries of type {} are not supported in object detection labels.'.format(geom_type))
Exception: Geometries of type Point are not supported in object detection labels.

Roads semantic segmentation task crashes during "Making training chips"

2019-01-03 13:23:45:rastervision.task.task: INFO - Making train chips for scene: 463
2019-01-03 13:23:45:rastervision.backend.tf_deeplab: INFO - Creating TFRecord
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/src/rastervision/main.py", line 17, in
rv.main()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/opt/src/rastervision/cli/main.py", line 253, in run_command
rv.runner.CommandRunner.run(command_config_uri)
File "/opt/src/rastervision/runner/command_runner.py", line 11, in run
CommandRunner.run_from_proto(msg)
File "/opt/src/rastervision/runner/command_runner.py", line 17, in run_from_proto
command.run()
File "/opt/src/rastervision/command/chip_command.py", line 29, in run
task.make_chips(train_scenes, val_scenes, augmentors, tmp_dir)
File "/opt/src/rastervision/task/task.py", line 128, in make_chips
train_scenes, TRAIN, augment=True)
File "/opt/src/rastervision/task/task.py", line 124, in _process_scenes
return [process_scene(scene, type, augment) for scene in scenes]
File "/opt/src/rastervision/task/task.py", line 124, in
return [process_scene(scene, type, augment) for scene in scenes]
File "/opt/src/rastervision/task/task.py", line 103, in _process_scene
with scene.activate():
File "/opt/src/rastervision/data/activate_mixin.py", line 40, in enter
manager.enter()
File "/opt/src/rastervision/data/activate_mixin.py", line 40, in enter
manager.enter()
File "/opt/src/rastervision/data/activate_mixin.py", line 40, in enter
manager.enter()
File "/opt/src/rastervision/data/activate_mixin.py", line 40, in enter
manager.enter()
File "/opt/src/rastervision/data/activate_mixin.py", line 21, in enter
self.activate()
File "/opt/src/rastervision/data/activate_mixin.py", line 54, in do_activate
self._activate()
File "/opt/src/rastervision/data/raster_source/rasterized_source.py", line 110, in _activate
geojson = self.vector_source.get_geojson()
File "/opt/src/rastervision/data/vector_source/vector_source.py", line 27, in get_geojson
self._get_geojson())
File "/opt/src/rastervision/data/vector_source/geojson_vector_source.py", line 19, in _get_geojson
return json.loads(file_to_str(self.uri))
File "/usr/lib/python3.5/json/init.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Help Required on semantic segmentation example of Potsdam

Hi,

I just started out with deep learning and found this to be an excellent source. Thanks a lot . However being an absolute beginner I do have certain doubts. I started with the Potsdam example of Semantic Segmentation. I tried out the set up locally and it is executing; however I do not see any outputs in the folder that I have defined. I have defined the following data folder:

  1. Data_URI = This points to my S3 bucket with the source data files satellite images
  2. Root_URI= This points to a folder in my local machine for output storing

rastervision run local -e potsdam.semantic_segmentation
-a test_run True -a root_uri ${ROOT_URI} -a data_uri ${DATA_URI}

I am trying to figure out if the set up ran as expected and if so why am I not able to see the output in the folder.Attached is the Terminal window. Many thanks for your help!

/usr/local/lib/python3.5/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
TensorBoard 1.10.0 at http://932c17caf67d:6006 (Press CTRL+C to quit)
INFO:tensorflow:Training on train set
INFO:tensorflow:Initializing model from path: /tmp/tmpzyxwc5qv/tmp61jrqise/http/download.tensorflow.org/models/deeplabv3_mnv2_pascal_train_aug/model.ckpt-30000
WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/slim/python/slim/learning.py:737: Supervisor.init (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.MonitoredTrainingSession
2019-03-29 08:57:45.278047: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:tensorflow:Restoring parameters from /tmp/tmpzyxwc5qv/tmp61jrqise/http/download.tensorflow.org/models/deeplabv3_mnv2_pascal_train_aug/model.ckpt-30000
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Starting Session.
INFO:tensorflow:Saving checkpoint to path Users/gunjanthakuria/Desktop/projects/data_project/Satellite/postdam_contest/raster-vision-examples-master/output/train/potsdam-seg/model.ckpt
INFO:tensorflow:Starting Queues.
INFO:tensorflow:global_step/sec: 0
2019-03-29 08:57:58.398151: W tensorflow/core/framework/allocator.cc:108] Allocation of 12582912 exceeds 10% of system memory.
2019-03-29 08:57:59.072704: W tensorflow/core/framework/allocator.cc:108] Allocation of 67108864 exceeds 10% of system memory.
2019-03-29 08:57:59.297481: W tensorflow/core/framework/allocator.cc:108] Allocation of 67108864 exceeds 10% of system memory.
2019-03-29 08:57:59.380239: W tensorflow/core/framework/allocator.cc:108] Allocation of 79691776 exceeds 10% of system memory.
2019-03-29 08:57:59.518586: W tensorflow/core/framework/allocator.cc:108] Allocation of 79691776 exceeds 10% of system memory.
INFO:tensorflow:Recording summary at step 0.
INFO:tensorflow:Stopping Training.
INFO:tensorflow:Finished training! Saving model to disk.
2019-03-29 08:58:16:rastervision.backend.tf_deeplab: INFO - Exporting frozen graph (Users/gunjanthakuria/Desktop/projects/data_project/Satellite/postdam_contest/raster-vision-examples-master/output/train/potsdam-seg/model)
/usr/local/lib/python3.5/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
INFO:tensorflow:Prepare to export model to: Users/gunjanthakuria/Desktop/projects/data_project/Satellite/postdam_contest/raster-vision-examples-master/output/train/potsdam-seg/model
INFO:tensorflow:Exported model performs single-scale inference.
2019-03-29 08:58:33.755165: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

Terminal Saved Output.pdf

Add example for using shapefiles

Problem Statement

The Esri shapefile format is a popular vector data format. As such, I believe it would be worthwhile to construct an example illuminating how shapefile labels can be used in raster-vision.

References

A good example, IMHO, would be importing the datasets used in WaterNet, which consists of TIFF base images and shapefile labels (sometimes multiple shapefiles correspond to the same base image). In WaterNet, the shapefiles are "burnt" into raster images consisting of 0's and 1's for Not Water and Water. This conversion, however, is not memory efficient.

Some Preliminary Work

Ideally, raster-vision should be able to read the shapefile directly, but I am unsure if this yet possible or feasible. A workaround would be to convert shapefiles into a format recognized by raster-vision, such as GeoJSON or vector tiles.

For conversion into GeoJSON, something like the following code snippet can be used (which was designed for the dataset used in WaterNet):

import os.path
from . import ogr2ogr

def create_merge_vrt(sources, vrt_uri):
    '''
    Writes a vrt file for use with ogr2ogr to merge files together.
    '''

    with open(vrt_uri, "w") as vrtfile:
        
        # Create wrapper.
        vrtfile.write("""<OGRVRTDataSource>
    <OGRVRTUnionLayer name="unionLayer">
""")
        
        # Add sources.
        for source in sources:
            
            print('Adding source: {}'.format(source))
            
            vrtfile.write("""            <OGRVRTLayer name="{}">
                <SrcDataSource relativeToVRT="0">{}</SrcDataSource>
            </OGRVRTLayer>
""".format(get_file_name(source), source))
            
        # Conclude file.
        vrtfile.write("""    </OGRVRTUnionLayer>
</OGRVRTDataSource>
""")
        
    print('Created vrt file at {}.'.format(vrt_uri))
    

def convert_to_geojson(sources, save_uri):
    '''
    Convert a list of files to the GeoJSON format.
    '''
    
    print('Converting sources to GeoJSON at {}{}...'.format(save_uri,'.geojson'))
    
    #Create a VRT file that includes information on the included sources.
    vrt_uri = save_uri + '.vrt'
    create_merge_vrt(sources, vrt_uri)
    
    # Convert shapefile to GeoJSON
    ogr2ogr.main(["","-f", "GeoJSON", save_uri+'.geojson', vrt_uri])
    print('Created GeoJSON file ({}).'.format(save_uri+'.geojson'))

Though this code is hacky, it is quite memory efficient (thanks to ogr2ogr).

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.