mapreader.process.context_post_process

Classes

ContextPostProcessor

A class for post-processing predictions on patches using the surrounding context.

Module Contents

class mapreader.process.context_post_process.ContextPostProcessor(patch_df, labels_map, delimiter=',')

A class for post-processing predictions on patches using the surrounding context.

Parameters:
  • patch_df (pd.DataFrame | geopandas.GeoDataFrame | str | pathlib.Path) – the DataFrame containing patches and predictions

  • labels_map (dict) – the dictionary mapping label indices to their labels. e.g. {0: “no”, 1: “railspace”}.

  • delimiter (str, optional) – The delimiter used in the CSV file, by default “,”.

patch_df
labels_map
context
get_context(labels)

Get the context of the patches with the specified labels.

Parameters:

labels (str | list) – The label(s) to get context for.

update_preds(remap, conf=0.7, inplace=False)

Update the predictions of the chosen patches based on their context.

Parameters:
  • remap (dict) – A dictionary mapping the old labels to the new labels.

  • conf (float, optional) – Patches with confidence scores below this value will be relabelled, by default 0.7.

  • inplace (bool, optional) – Whether to relabel inplace or create new dataframe columns, by default False