Utilities¶
Helper functions in instanseg.utils.utils.
Images and labels¶
- percentile_normalize(img, percentile=0.1, subsampling_factor=1, epsilon=0.001)¶
Normalize an image using percentile-based scaling.
- count_instances(labels)¶
Count the number of distinct non-zero labels (objects) in an input tensor.
- labels_to_features(lab, object_type='annotation', connectivity=4, transform=None, downsample=1.0, include_labels=False, classification=None, offset=None)¶
Create a GeoJSON FeatureCollection from a labeled image.
- Parameters:
- Returns:
A GeoJSON FeatureCollection.
- Return type:
geojson.FeatureCollection
Note
Requires the
rasterioandgeojsonpackages. Install withpip install instanseg-torch[io].
Models¶
- download_model(model_str, version=None, verbose=True, force=False)¶
Download and load an InstanSeg model from the model repository.
- export_to_torchscript(model_str, show_example=False, output_dir='../torchscripts', model_path='../models', torchscript_name=None, use_optimized_params=False)¶
Export an InstanSeg model to TorchScript format.