mapreader.spot_text.rec_runner_base

Classes

RecRunner

Module Contents

class mapreader.spot_text.rec_runner_base.RecRunner

Bases: mapreader.spot_text.runner_base.Runner

get_patch_predictions(outputs, return_dataframe=False, min_ioa=0.7)

Post process the model outputs to get patch predictions.

Parameters:
  • outputs (dict) – The outputs from the model.

  • return_dataframe (bool, optional) – Whether to return the predictions as a pandas DataFrame, by default False

  • min_ioa (float, optional) – The minimum intersection over area to consider two polygons the same, by default 0.7

Returns:

A dictionary containing the patch predictions or a DataFrame if as_dataframe is True.

Return type:

dict or pd.DataFrame

search_preds(search_text, ignore_case=True, return_dataframe=False)

Search the predictions for specific text. Accepts regex.

Parameters:
  • search_text (str) – The text to search for. Can be a regex pattern.

  • ignore_case (bool, optional) – Whether to ignore case when searching, by default True.

  • return_dataframe (bool, optional) – Whether to return the results as a pandas DataFrame, by default False.

Returns:

A dictionary containing the search results or a DataFrame if return_dataframe is True.

Return type:

dict | pd.DataFrame

Raises:

ValueError – If no parent predictions are found.

show_search_results(parent_id, figsize=(10, 10), border_color='r', text_color='b', image_width_resolution=None, return_fig=False)

Show the search results on an image.

Parameters:
  • parent_id (str) – The image ID to show the predictions on (must be parent level).

  • figsize (tuple | None, optional) – The size of the figure, by default (10, 10)

  • border_color (str | None, optional) – The color of the border of the polygons, by default “r”

  • text_color (str | None, optional) – The color of the text, by default “b”

  • image_width_resolution (int | None, optional) – The maximum resolution of the image width, by default None

  • return_fig (bool, optional) – Whether to return the figure, by default False

Returns:

The matplotlib figure if return_fig is True.

Return type:

fig

Raises:

ValueError – If the image ID is not found in the patch or parent predictions.

save_search_results_to_geojson(save_path)

Convert the search results to georeferenced search results and save them to a GeoJSON file.

Parameters:

save_path (str | pathlib.Path) – The path to save the GeoJSON file.

Raises:

ValueError – If no search results are found.

Return type:

None