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)

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

Parameters:
  • patch_df (pd.DataFrame) – the DataFrame containing patches and predictions

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

required_columns = ['parent_id', 'pixel_bounds', 'pred', 'predicted_label', 'conf']
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