geowatch.tasks.dino_detector.predict module¶
- SeeAlso:
~/data/dvc-repos/smart_expt_dvc/models/kitware/xview_dino/package_trained_model.py
Notes
# To test if mmcv is working on your machine:
python -c “from mmcv.ops import multi_scale_deform_attn”
- class geowatch.tasks.dino_detector.predict.BuildingDetectorConfig(*args, **kwargs)[source]¶
Bases:
DataConfig
Valid options: []
- Parameters:
*args – positional arguments for this data config
**kwargs – keyword arguments for this data config
- default = {'batch_size': 1, 'coco_fpath': <Value(None)>, 'data_workers': 2, 'device': <Value(0)>, 'fixed_resolution': '1GSD', 'out_coco_fpath': <Value(None)>, 'package_fpath': <Value(None)>, 'select_images': None, 'track_emissions': True, 'window_dims': (1024, 1024), 'window_overlap': 0.5}¶
- geowatch.tasks.dino_detector.predict.main(cmdline=1, **kwargs)[source]¶
Example
>>> # xdoctest: +SKIP >>> from geowatch.tasks.dino_detector.predict import * # NOQA >>> import ubelt as ub >>> import geowatch >>> import kwcoco >>> dvc_data_dpath = geowatch.find_dvc_dpath(tags='phase2_data', hardware='auto') >>> dvc_expt_dpath = geowatch.find_dvc_dpath(tags='phase2_expt', hardware='auto') >>> coco_fpath = dvc_data_dpath / 'Drop6-MeanYear10GSD-V2/imgonly-KR_R001.kwcoco.zip' >>> package_fpath = dvc_expt_dpath / 'models/kitware/xview_dino.pt' >>> out_coco_fpath = ub.Path.appdir('geowatch/tests/dino/doctest0').ensuredir() / 'pred_boxes.kwcoco.zip' >>> kwargs = { >>> 'coco_fpath': coco_fpath, >>> 'package_fpath': package_fpath, >>> 'out_coco_fpath': out_coco_fpath, >>> 'fixed_resolution': '10GSD', >>> 'window_dims': (256, 256), >>> } >>> cmdline = 0 >>> _ = main(cmdline=cmdline, **kwargs) >>> out_dset = kwcoco.CocoDataset(out_coco_fpath) >>> # xdoctest: +REQUIRES(--show) >>> import kwplot >>> import kwimage >>> kwplot.plt.ion() >>> gid = out_dset.images()[0] >>> annots = out_dset.annots(gid=gid) >>> dets = annots.detections >>> list(map(len, out_dset.images().annots)) >>> config = out_dset.dataset['info'][-1]['properties']['config'] >>> delayed = out_dset.coco_image(gid).imdelay(channels='red|green|blue', resolution=config['fixed_resolution']) >>> rgb = kwimage.normalize_intensity(delayed.finalize()) >>> import kwplot >>> kwplot.plt.ion() >>> kwplot.imshow(rgb, doclf=1) >>> top_dets = dets.compress(dets.scores > 0.2) >>> top_dets.draw()