Sign inSign up

ncsa/criticalmaas-pipeline

Sponsored OSS

By University of Illinois at Urbana-Champagin

Updated over 1 year ago

Image
0

10K+

ncsa/criticalmaas-pipeline repository overview

CriticalMAAS Pipeline

This is the internal UIUC git repository for the DARPA CMAAS inference pipeline. The pipeline is designed to be run on hydro.

Quickstart

Installing

To get started with this pipeline you will need to clone the repository and and install requirements.txt. We recommend using python venv here to keep the working environment clean.

# If you are on hydro you will need to load the python and cuda module.
# module load python/3.9.13 cuda/11.7.0 

git clone [email protected]:criticalmaas/pipeline.git
cd pipeline_inference
python3 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt

This repository also makes use of submodules which will need to be initialized.

git submodule init
git submodule update
Understanding Pipeline Inputs

To perform inference with our pipeline, only one data input is required and that is the map that you want to perform inference on. There are other data inputs we can use to speed up and perform optional steps with. Each of these optional inputs needs to be structured so that the name is consistent with the input map. E.g. if you have CA_Sage.tif the legend will need be named CA_Sage.json

This is visualization of what that structure looks like.

data
├── Map_1.tif
├── Map_2.tif
├── ...
└── Map_N.tif

legends # Optional
├── Map_1.json
├── Map_2.json
├── ...
└── Map_N.json

layouts # Optional
├── Map_1.json
├── Map_2.json
├── ...
└── Map_N.json

validation # Optional
├── Map_1_lgd_1_poly.tif
├── Map_1_lgd_2_poly.tif
├── ...
├── Map_1_lgd_N_poly.tif
├── ...
├── Map_N_lgd_1_poly.tif
├── Map_N_lgd_2_poly.tif
├── ...
└── MapN_lgdN_poly.tif

It is also important to note that if you specify --legends and there is no corresponding legend for a map file, that is completely fine. Pipeline will just fallback to generating a legend for that specfic map. The same is true for --layouts and --validation.

Performing Inference

To perform inference with one of our models, we will need to run pipeline.py. Pipeline.py has 3 core required arguments to run:

  • --model : The model to use for inference.
  • --data : Directory containing data to perform inference on.
  • --output : Directory to save the output data of the pipeline to.

The list of available models can be found below with the release-tag being what you want to use for the argument.

Note* You must have a GPU available to run pipeline.py

# Example call to pipeline.py
python pipeline.py --model "golden_muscat" --data mydata/images/ --output mydata/output/

Running this will have "golden-muscat" run inference on every .tif file in the directory specifed by --data. The output rasters of this inference will then be saved as .tifs to the directory specifed by --output along with a geopackage file for each map. The geopackage file contains vector data for each legend item in the map. Output is saved as the pipeline runs so even if the pipeline were to crash in the middle of running, all maps that ran before the crash will have been saved.

By default the pipeline will save logging information to logs/Latest.log this can be useful if you have any problems or want to see a detailed view of what the pipeline is doing. You can also change the log file location with --log.

For the further documentation on all the pipeline options see below.

Running on Hydro

For running the pipeline on hydro there are two options. You can manually run the pipeline with an interactive srun session or we can submit an automatic job using sbatch. You can learn how to manually run with srun in the hydro docs. You will need to make sure to srun with --partition=a100 flag as these are the only nodes with GPUs on hydro.

For running with sbatch we have two scripts submit.sh and start_pipeline.sh. When we run submit.sh that script will automatically start start_pipeline.sh on an a100 node.

First, we will want to set the parameters for pipeline.py in start_pipeline.sh. Then, once we are ready to run, all we have to do is call

sbatch submit.sh

and that will start the job. We can view our pipelines progess by looking at logs/job_%yourjobid%.log. The slurm logs can also be found at logs/slurm/%yourjobid%.e if you have any errors.

*Hint tail -f logs/job_%yourjobid%.log can be very useful for viewing these logs. You can also use nvitop when on the node that is running the job to view GPU statistics in real-time.

*Please note that our job script assumes that you are using venv to setup your environment. If you are using another python environment manager, E.g. Conda or virtualenvwrapper, you will need to adapt the start_pipeline.sh script to your setup.

Understanding Pipeline Outputs

Pipeline can produce quite a few output files so it can be important to understand what each is. The key arguments here ar --output and --feedback as they control what files the pipeline will output and where. --output controls where the results of inference will get saved; A Raster tif for each legend and a geopackage for each map containing the vectorized legend data for every legend. --feedback controls whether the pipeline will output files that are intended for debugging. When feedback is enabled, the pipeline will save any legend data that was generated by the pipeline, save the image of the legend label, create a visualization image for each legend analyzed in the validation step, and save the validation score csv for each individual map. This results in the following output structure.

output
├── full_dataset_scores.csv # If validation was enabled and feedback was not
├── Map1_lgd1.tif
├── ...
├── Map1_lgdN.tif
├── Map1.gpkg
├── ...
├── MapN_lgd1.tif
├── ...
├── MapN_lgdN.tif
└── MapN.gpkg

feedback
├── full_dataset_scores.csv # If validation was enabled
├── Map1
│   ├── Map1.json # If a map legend was generated by pipeline
│   ├── Map1_Scores.csv   # If validation was enabled
│   ├── lgd_map1_lgd1.tif # Legend label image
│   ├── ...               # ''
│   ├── lgd_map1_lgdN.tif # ''
│   ├── val_map1_lgd1.tif # Legend validation image
│   ├── ...               # ''
│   └── val_map1_lgdN.tif # ''
├── ...
└── MapN
    ├── MapN.json # If a map legend was generated by pipeline
    ├── MapN_Scores.csv   # If validation was enabled
    ├── lgd_mapN_lgd1.tif # Legend label image
    ├── ...               # ''
    ├── lgd_mapN_lgdN.tif # ''
    ├── val_mapN_lgd1.tif # Legend validation image
    ├── ...               # ''
    └── val_mapN_lgdN.tif # ''

Note that if feedback is not turned on and validation is, pipeline will still save all the scores in the output directory to #%data%_results.csv

FAQ

Q. Where is data on hydro?

A. /projects/bbym/shared/data

Q. I've updated to the latest pipeline commit and it doesn't work.

A. New requirements could have been added or submodules could have been updated. It's always a good idea to run the following commands if you are having issues after updating to the most recent commit.

pip install -r requirements.txt
git submodule init
git submodule update

Q. I'm having a problem with the pipeline that I couldn't find help for.

A. Use the issues tab underneath the Plan tab to submit an issue describing your problem.

Documentation

Pipeline Parameters
  • --model : required
    The release-tag of the model checkpoint that will be used to perform inference. Available release-tags for models are listed below and can be displayed with --help.
  • --data : required
    Path to file(s) and/or directory(s) containing the data to perform inference on. The program will run inference on any .tif files. Mutually exclusive with --amqp.
  • --amqp : required ## Not Implemented Yet ##
    Url to use to connect to a amqp data stream. Mutually exclusive with --data.
  • --output : required
    Directory to save the outputs of inference to. These output currently include the predicted raster for each legend item of each map and geopackage file for each map which contains all of the layer in vector format. If the directory does not exist, it will be created. *Geopackage saving is disabled as there is currently a bug when saving
  • --legends : optional
    Optional Directory containing precomputed legend data in USGS json format. If option is provided, the pipeline will use the precomputed legend data instead of generating its own. File names are expected to match their corresponding map file name. E.g. a file named data/CA_Sage.tif would have a legends/CA_Sage.json file. This can increase pipeline performance by skipping the legend extraction step.
  • --layouts : optional
    Optional Directory containing precomputed map layout data in Uncharted json format. If option is provided, pipeline will use the layout to assist in legend extraction and inferencing. File names are expected to match their corresponding map file name. E.g. a file named data/CA_Sage.tif would have a layouts/CA_Sage.json file. This can significantly increase the performance of the pipeline.
  • --validation : optional
    Optional Directory containing the true raster segmentations. If option is provided, the pipeline will perform the validation step (Scoring the results of predictions) with this data. File names are expected to match their corresponding map file name and legend. E.g. if there is a legend for map CA_Sage called Mbv_poly, the validation directory would have a validation/CA_Sage_Mbv_poly.tif file.
  • --feedback : optional
    Optional Directory to save feedback on the pipeline. If option is provided, pipeline will save any legend data that was generated by the pipeline, the legend label image, visualization images of the validation step, and validation score csv's for each map. If the directory does not exist, it will be created. This option will incur a slight performance hit on the pipeline.
  • --feature_type : optional
    Option to specify which type of feature the pipeline should run on. Available feature types are Point, Polygon and All. Defaults to polygon
  • --log : optional
    Option to set the file that pipeline logging will write to. Defaults to "logs/Latest.log".
  • --verbose, -v : optional
    Flag to change the default logging level. Changes the file logging level from INFO to DEBUG and the Console level from WARNING to INFO.
Pipeline Config # Not implemented yet

Pipeline config will likely contain model-specific config options. Some planned options are below.

  • Patch_size
  • Patch_overlap
  • Batch_size?
Available Models
Point Models
Flat-Iceberg

Git Repository : https://github.com/Dongjiahua/DARPA_torch
Lead Developer : Git profile image Dong Jiahua
Description :

Release Tags :

  • flat_iceberg
Polygon Models
Primordial-Positron

Git Repository : https://git.ncsa.illinois.edu/nj7/darpa_proj
Lead Developer : Git profile image Nattapon Jaroenchai (Nathan)
Description : Attention U-net model

Release Tags :

  • primordial_positron_3
  • primordial_positron_4
Customer-Backpack

Git Repository : https://git.ncsa.illinois.edu/nj7/darpa_proj
Lead Developer : Git profile image Nattapon Jaroenchai
Description : Attention U-net model

Release Tags :

  • customer_backpack
Golden-Muscat

Git Repository : https://github.com/xiyuez2/Darpa_Unet_Release
Lead Developer : Git profile image xiyuez2
Description : U-net model

Release Tags :

  • golden_muscat
Rigid-Wasabi

Git Repository : https://github.com/xiyuez2/Darpa_Unet_Release
Lead Developer : Git profile image xiyuez2
Description : U-net model

Release Tags :

  • rigid_wasabi
Blaring-Foundry

Git Repository : https://github.com/xiyuez2/Darpa_Unet_Release
Lead Developer : Git profile image ziruiwang409
Description : Superpixel U-net model

Release Tags :

  • blaring_foundry

Tag summary

Content type

Image

Digest

sha256:882c0f380

Size

13.5 GB

Last updated

over 1 year ago

docker pull ncsa/criticalmaas-pipeline

This week's pulls

Pulls:

17

Last week