geowatch.tasks.invariants.predict module

Basline Example:

DVC_DATA_DPATH=$(geowatch_dvc –tags=’phase2_data’ –hardware=auto) DVC_EXPT_DPATH=$(geowatch_dvc –tags=’phase2_expt’ –hardware=auto)

python -m geowatch.tasks.invariants.predict –input_kwcoco=$DVC_DATA_DPATH/Drop4-BAS/data_vali_KR_R001.kwcoco.json –output_kwcoco=$DVC_DATA_DPATH/Drop4-BAS/all_tests/model_thirteen_epoch/data_vali_KR_R001_invariants.kwcoco.json –pretext_package=$DVC_EXPT_DPATH/models/uky/uky_invariants_2022_12_17/TA1_pretext_model/pretext_package.pt –input_space_scale=10GSD –window_space_scale=10GSD –patch_size=256 –do_pca 0 –patch_overlap=0.3 –workers=”2” –write_workers 0 –tasks before_after pretext

# After your model predicts the outputs, you should be able to use the # geowatch visualize tool to inspect your features. python -m geowatch visualize $DVC_DATA_DPATH/Drop4-BAS/all_tests/model_thirteen_epoch/data_vali_invariants.kwcoco.json –channels “invariants.5:8,invariants.8:11,invariants.14:17” –stack=only –workers=avail –animate=True –draw_anns=False

SeeAlso:

~/code/watch/geowatch/cli/queue_cli/prepare_teamfeats.py

class geowatch.tasks.invariants.predict.InvariantPredictConfig(*args, **kwargs)[source]

Bases: DataConfig

Configuration for UKY invariant models

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

default = {'assets_dname': <Value('_assets')>, 'bands': <Value(['shared'])>, 'batch_size': <Value(1)>, 'device': <Value('cuda')>, 'do_pca': <Value(1)>, 'input_kwcoco': <Value(None)>, 'input_resolution': <Value('10GSD')>, 'io_workers': <Value(0)>, 'output_kwcoco': <Value(None)>, 'patch_overlap': <Value(0.25)>, 'patch_size': <Value(256)>, 'pca_projection_path': <Value('')>, 'pretext_ckpt_path': <Value(None)>, 'pretext_package_path': <Value(None)>, 'segmentation_ckpt_path': <Value(None)>, 'segmentation_package_path': <Value(None)>, 'sensor': <Value(['S2', 'L8'])>, 'tasks': <Value(['all'])>, 'track_emissions': <Value(True)>, 'window_resolution': <Value('10GSD')>, 'workers': <Value(4)>}
normalize()
class geowatch.tasks.invariants.predict.Predictor(args)[source]

Bases: object

CommandLine

DVC_DPATH=$(geowatch_dvc)
DVC_DPATH=$DVC_DPATH xdoctest -m geowatch.tasks.invariants.predict Predictor

python -m geowatch visualize $DVC_DPATH/Drop2-Aligned-TA1-2022-02-15/test_uky.kwcoco.json             --channels='invariants.0:3' --animate=True --with_anns=False

Example

>>> # xdoctest: +REQUIRES(env:DVC_DPATH)
>>> from geowatch.tasks.invariants.predict import *  # NOQA
>>> import kwcoco
>>> import geowatch
>>> dvc_dpath = geowatch.find_dvc_dpath()
>>> #  Write out smaller version of the dataset
>>> dset = kwcoco.CocoDataset(dvc_dpath / 'Drop2-Aligned-TA1-2022-02-15/data_nowv_vali.kwcoco.json')
>>> images = dset.videos(names=['KR_R001']).images[0]
>>> sub_images = images.compress([s != 'WV' for s in images.lookup('sensor_coarse')])[::5]
>>> sub_dset = dset.subset(sub_images)
>>> sub_dset.fpath = (dvc_dpath / 'Drop2-Aligned-TA1-2022-02-15/small_test_data_nowv_vali.kwcoco.json')
>>> sub_dset.dump(sub_dset.fpath)
>>> input_kwcoco = sub_dset.fpath
>>> output_kwcoco = dvc_dpath / 'Drop2-Aligned-TA1-2022-02-15/test_uky.kwcoco.json'
>>> pretext_package_path = dvc_dpath / 'models/uky/uky_invariants_2022_03_11/TA1_pretext_model/pretext_package.pt'
>>> pca_projection_path = dvc_dpath / 'models/uky/uky_invariants_2022_03_11/TA1_pretext_model/pca_projection_matrix.pt'
>>> segmentation_package_path = dvc_dpath / 'models/uky/uky_invariants_2022_02_11/TA1_segmentation_model/segmentation_package.pt'
>>> argv = []
>>> argv += ['--input_kwcoco', f'{sub_dset.fpath}']
>>> argv += ['--output_kwcoco', f'{output_kwcoco}']
>>> argv += ['--pca_projection_path', f'{pca_projection_path}']
>>> argv += ['--pretext_package_path', f'{pretext_package_path}']
>>> argv += ['--segmentation_package_path', f'{segmentation_package_path}']
>>> argv += ['--patch_overlap', '0.25']
>>> argv += ['--workers', '2']
>>> argv += ['--tasks', 'all']
>>> argv += ['--do_pca', '1']
>>> args = InvariantPredictConfig.cli(argv=argv)
>>> self = Predictor(args)
>>> self.forward(args)
forward()[source]
geowatch.tasks.invariants.predict.main()[source]