geowatch.tasks.cold.transfer_features module¶
Transfering cold features
CommandLine
DATA_DVC_DPATH=$(geowatch_dvc --tags=phase2_data --hardware="auto")
EXPT_DVC_DPATH=$(geowatch_dvc --tags=phase2_expt --hardware="auto")
python -m geowatch.tasks.cold.transfer_features \
--coco_fpath="$DATA_DVC_DPATH/Drop6/imgonly_KR_R001_cold-HTR.kwcoco.zip" \
--combine_fpath="$DATA_DVC_DPATH/Drop6-MeanYear10GSD-V2/imgonly-KR_R001.kwcoco.zip" \
--new_coco_fpath="$DATA_DVC_DPATH/Drop6-MeanYear10GSD-V2/imganns-KR_R001_uconn_cold.kwcoco.zip"
- class geowatch.tasks.cold.transfer_features.TransferCocoConfig(*args, **kwargs)[source]¶
Bases:
DataConfig
Transfer channels to one kwcoco file to the nearest image in the future.
Valid options: []
- Parameters:
*args – positional arguments for this data config
**kwargs – keyword arguments for this data config
- default = {'allow_affine_approx': <Value(False)>, 'channels_to_transfer': <Value(None)>, 'copy_assets': <Value(False)>, 'dst_kwcoco': <Value(None)>, 'io_workers': <Value(0)>, 'max_propogate': <Value(1)>, 'new_coco_fpath': <Value(None)>, 'respect_sensors': <Value(True)>, 'src_kwcoco': <Value(None)>}¶
- geowatch.tasks.cold.transfer_features.transfer_features_main(cmdline=1, **kwargs)[source]¶
- Parameters:
cmdline (int, optional) – _description_. Defaults to 1.
Example
>>> from geowatch.tasks.cold.transfer_features import transfer_features_main >>> from geowatch.tasks.cold.transfer_features import * >>> import geowatch >>> dset1 = geowatch.coerce_kwcoco('geowatch-msi', geodata=True, heatmap=True, dates=True) >>> dset2 = dset1.copy() >>> # Remove saliency assets from dset2 >>> for img in dset2.images().coco_images: >>> asset = img.find_asset_obj('salient') >>> img['auxiliary'].remove(asset) >>> dset2_orig = dset2.copy() >>> # Transfer the saliency from dset1 onto dset2 >>> kwargs = TransferCocoConfig(**{ >>> 'src_kwcoco': dset1, >>> 'dst_kwcoco': dset2, >>> 'new_coco_fpath': 'return', >>> 'channels_to_transfer': 'salient', >>> 'copy_assets': False, >>> }) >>> cmdline = False >>> new_dset = transfer_features_main(cmdline, **kwargs) >>> assert new_dset is dset2, 'modifies combine_fpath inplace' >>> from geowatch.utils import kwcoco_extensions >>> stats1 = kwcoco_extensions.coco_channel_stats(dset1) >>> stats2 = kwcoco_extensions.coco_channel_stats(dset2) >>> stats2_orig = kwcoco_extensions.coco_channel_stats(dset2_orig) >>> assert stats2['single_chan_hist']['salient'] == stats1['single_chan_hist']['salient'], 'all assets should transfer' >>> assert stats2['single_chan_hist']['salient'] == dset2.n_images, 'all dst images should get saliency here' >>> assert stats2_orig['single_chan_hist']['salient'] == 0