geowatch.demo.smart_kwcoco_demodata module¶
Extends kwcoco demodata to be more smart-like
- geowatch.demo.smart_kwcoco_demodata.coerce_kwcoco(data='geowatch-msi', **kwargs)[source]¶
coerce with geowatch special datasets
Calls kwcoco.CocoDataset.coerce unless the code is geowatch-msi, and then we construct a special dataset with extra variables expected by the watch project.
- Parameters:
data (str | Coercible[kwcoco.CocoDataset]) – the special code to coerce
**kwargs – modify how the demodata is created. For geowatch-msi, see
demo_kwcoco_multisensor()
, a selection of useful args are:dates: bool - add random dates to images geodata: bool | dict - assign images to random geo locations.
Can be a dict with extra options. See: func:hack_seed_geometadata_in_dset. valid keys are: enabled, region_geom
heatmap: bool - add noisy heatmaps as channels image_size: Tuple[int, int] - control size of images num_videos: int - control number of videos num_frames: int - control length of videos num_tracks: int - control number of objects multispectral: bool - control dummy channels multisensor: bool - control dummy sensors bad_nodata: bool - control if nodata values exist max_speed: float - control speed of demo objects anchors - bounding box templates for objects, see kwcoco demo docs..
Example
>>> import geowatch >>> dates=True >>> geodata=True >>> heatmap=True >>> kwargs = {} >>> coco_dset = geowatch.coerce_kwcoco(data='geowatch-msi', dates=dates, geodata=geodata, heatmap=heatmap) >>> coco_dset2 = geowatch.coerce_kwcoco(data='geowatch-msi-dates-geodata-gsize32') >>> assert 'date_captured' in coco_dset2.images().peek()
- geowatch.demo.smart_kwcoco_demodata.demo_kwcoco_multisensor(num_videos=4, num_frames=10, heatmap=False, dates=False, geodata=False, bad_nodata=False, **kwargs)[source]¶
- Parameters:
num_videos (int) – number of videos in the demo dataset
num_frames (int) – number of frames per video in the demo dataset
heatmap (bool | ChannelSpec) – if True adds dummy saliency heatmaps to the demodata. Can also be given as data coercable to a channel spec, in which case those channels are generated.
geodata (bool | dict) – if True adds dummy geographic referencing to the demodata. If a dictionary can specify extra information. Available keys:
enabled region_geom
bad_nodata (bool) – if True, zeros out some pixels which simulates bad nodata for testing.
dates (bool | dict) – Include time data or not. If a dictionary can specify extra information. Available keys:
start_time end_time
**kwargs – additional arguments passed to
kwcoco.CocoDataset.demo()
.
- Returns:
kwcoco.CocoDataset
Example
>>> from geowatch.demo.smart_kwcoco_demodata import * # NOQA >>> num_frames = 2 >>> num_videos = 1 >>> image_size = (128, 128) >>> dates = True >>> geodata = True >>> heatmap = True >>> bad_nodata = True >>> kwargs = {} >>> coco_dset = demo_kwcoco_multisensor(dates=dates, geodata=geodata, >>> heatmap=heatmap, bad_nodata=True, >>> image_size=image_size)
- geowatch.demo.smart_kwcoco_demodata.demo_kwcoco_with_heatmaps(num_videos=1, num_frames=20, image_size=(512, 512))[source]¶
Return a dummy kwcoco file with special metdata
- DEPRECATED:
Instead use geowatch.coerce_kwcoco(‘geowatch-msi-geodata-dates-heatmap-videos1-frames20-gsize512’) or something similar
Example
>>> from geowatch.demo.smart_kwcoco_demodata import * # NOQA >>> coco_dset = demo_kwcoco_with_heatmaps()
key = ‘salient’ for vidid in coco_dset.videos():
frames = [] for gid in coco_dset.images(video_id=vidid):
delayed = coco_dset.coco_image(gid).imdelay(channels=key, space=’video’) final = delayed.finalize() frames.append(final)
vid_stack = kwimage.stack_images_grid(frames, axis=1, pad=5, bg_value=1)
import kwplot kwplot.imshow(vid_stack)
- geowatch.demo.smart_kwcoco_demodata.hack_in_heatmaps(coco_dset, channels='auto', heatmap_dname='dummy_heatmaps', with_nan=False, rng=None)[source]¶
Adds dummy heatmaps into a coco dataset.
- Parameters:
channels (ChannelSpec) – heatmap channels to generate
CommandLine
xdoctest -m geowatch.demo.smart_kwcoco_demodata hack_in_heatmaps
Example
>>> from geowatch.demo.smart_kwcoco_demodata import * # NOQA >>> with_nan = False >>> rng = None >>> heatmap_dname = 'dummy_heatmaps' >>> num_frames = 34 >>> num_videos = 1 >>> dates=True >>> geodata=True >>> bad_nodata = False >>> kwargs = {} >>> heatmap = channels = 'ac_salient,No Activity|Site Preparation|Active Construction|Post Construction' >>> # heatmap = channels = 'ac_salient' >>> coco_dset = demo_kwcoco_multisensor(dates=dates, geodata=geodata, heatmap=heatmap, bad_nodata=bad_nodata, num_frames=num_frames, num_videos=num_videos, multisensor=0, multispectral=0, max_speed=0) >>> # xdoctest: +SKIP >>> ub.cmd(f'geowatch visualize {coco_dset.fpath} --smart', system=1)
- geowatch.demo.smart_kwcoco_demodata.hack_in_timedata(coco_dset, dates=True, rng=None)[source]¶
Adds date_captured fields to demo toydata
Note
superceded by kwcoco populate_random_timestamps, use that instead
- geowatch.demo.smart_kwcoco_demodata.hack_seed_geometadata_in_dset(coco_dset, force=False, rng=None, region_geom=None)[source]¶
Add random geo coordinates to one asset in each video
Example
>>> from geowatch.demo.smart_kwcoco_demodata import * # NOQA >>> coco_dset = kwcoco.CocoDataset.demo('vidshapes5-multispectral') >>> modified = hack_seed_geometadata_in_dset(coco_dset, force=True) >>> fpath = modified[0] >>> result = ub.cmd('gdalinfo ' + fpath) >>> assert 'Coordinate System' in result['out'], 'should have geoinfo'
Example
>>> # Test with multiple image sizes >>> import kwcoco >>> from geowatch.demo.smart_kwcoco_demodata import * # NOQA >>> coco_dset1 = kwcoco.CocoDataset.demo('vidshapes-multispectral', num_videos=1, image_size=(8, 8), num_frames=3) >>> coco_dset2 = kwcoco.CocoDataset.demo('vidshapes-multispectral', num_videos=1, image_size=(64, 64), num_frames=3) >>> coco_dset = coco_dset1.union(coco_dset2) >>> hack_seed_geometadata_in_dset(coco_dset, force=True, region_geom='random-proportional', rng=0)