geococo.coco_processing
Functions
|
Move across a given geotiff, converting all intersecting labels to COCO |
Module Contents
- geococo.coco_processing.append_dataset(dataset, images_dir, src, window_bounds, labels, id_attribute=None, name_attribute=None, super_attribute=None)[source]
Move across a given geotiff, converting all intersecting labels to COCO annotations and appending them to a COCODataset model. This is done through rasterio.Window objects, the bounds of which you can set with window_bounds (also determines the size of the output images associated with the Annotation instances). The degree of overlap between these windows is determined by the dimensions of the given labels to maximize representation in the resulting dataset.
The “iscrowd” attribute (see https://cocodataset.org/#format-data) is determined by whether the respective labels are Polygon or MultiPolygon instances. The attribute arguments are column names of the GeoDataFrame and are used to supply (super)category names, category ids, or both. If only names are given, ids are autogenerated (and vice versa). Lastly, each call to this method will increment the dataset version: patch if using the same image_path, minor if using a new image_path, and major if using a new output_dir.
- Parameters:
dataset (geococo.coco_models.CocoDataset) – CocoDataset model to append images and annotations to
images_dir (pathlib.Path) – output directory for all label images
src (rasterio.io.DatasetReader) – open rasterio reader for input raster
labels (geopandas.GeoDataFrame) – GeoDataFrame containing labels and class_info (‘category_id’)
window_bounds (List[Tuple[int, int]]) – a list of window_bounds to attempt to use ()
id_attribute (Optional[str]) – Column containing category_id values
name_attribute (Optional[str]) – Column containing category_name values
super_attribute (Optional[str]) – Column containing supercategory values
- Returns:
CocoDataset with n appended Image, Category and Annotation instances
- Return type: