fieldsoftheworld / ftw-baselines

Code for running baseline models/experiments with the Fields of The World dataset
https://fieldsofthe.world/
MIT License
55 stars 4 forks source link

refactoring CLI as proposed in #21 #25

Closed cholmes closed 1 month ago

cholmes commented 1 month ago

Refactoring CLI commands a bit as proposed in #21

% ftw                                               

Usage: ftw [OPTIONS] COMMAND [ARGS]...

  Fields of The World (FTW) - Command Line Interface

Options:
  --help  Show this message and exit.

Commands:
  data       Downloading, unpacking, and preparing the FTW dataset.
  inference  Running inference on satellite images plus data prep.
  model      Training and testing FTW models.
% ftw data
Usage: ftw data [OPTIONS] COMMAND [ARGS]...

  Downloading, unpacking, and preparing the FTW dataset.

Options:
  --help  Show this message and exit.

Commands:
  download  Download the FTW dataset.
  unpack    Unpack the downloaded FTW dataset.
% ftw inference
Usage: ftw inference [OPTIONS] COMMAND [ARGS]...

  Running inference on satellite images plus data prep.

Options:
  --help  Show this message and exit.

Commands:
  download  Download 2 Sentinel-2 scenes & stack them in a single file...
  run       Run inference on the stacked satellite images
cholmes commented 1 month ago

@calebrob6 - I merged #19 into here and refactored to be its own command. For my initial commit I aimed to keep it faithful to yours (not trying to add anything new). I think the one thing I lost was the 'warning' about it not being over 1 if it's geographic, as I'm not sure how to get that info from reading the file in.

% ftw inference polygonize --help
Usage: ftw inference polygonize [OPTIONS]

  Polygonize the output from inference

Options:
  --input_fn PATH   Input raster file to polygonize.  [required]
  --output_fn TEXT  Output filename for the polygonized data.  [required]
  --simplify FLOAT  Simplification factor to use when polygonizing.
  --overwrite       Overwrite outputs if they exist.
  --help            Show this message and exit.

% ftw inference polygonize --input_fn ~/Downloads/nl_output.tif --output_fn ~/Downloads/nl_inf_20.gpkg --simplify 20 --overwrite
Polygonizing input file: /Users/cholmes/Downloads/nl_output.tif
Processing mask windows: 36it [00:35,  1.01it/s]                                                                    
Finished polygonizing output at /Users/cholmes/Downloads/nl_inf_20.gpkg in 38.12s