paidiverpy.utils.formating_html#

HTML output utilities for paidiverpy.

Functions#

metadata_repr(→ str)

Represents metadata as an HTML string.

pipeline_repr(→ str)

Generate HTML representation of the pipeline.

config_repr(→ str)

Generate HTML representation of the config.

images_repr(→ str | IPython.display.HTML)

Generate the HTML representation of the object.

generate_single_image_html(→ str)

Generate HTML for a single image.

numpy_array_to_base64(→ str)

Convert a numpy array to a base64 image.

style_json_yaml(→ str)

Style the value based on its type.

Module Contents#

paidiverpy.utils.formating_html.metadata_repr(metadata: paidiverpy.metadata_parser.MetadataParser) str[source]#

Represents metadata as an HTML string.

Parameters:

metadata (MetadataParser) – The metadata object to represent.

Returns:

String representation of the metadata.

Return type:

str

paidiverpy.utils.formating_html.pipeline_repr(pipeline: paidiverpy.Paidiverpy) str[source]#

Generate HTML representation of the pipeline.

Parameters:

pipeline (Paidiverpy) – The pipeline instance to represent.

Returns:

The HTML representation of the pipeline.

Return type:

str

paidiverpy.utils.formating_html.config_repr(config: paidiverpy.config.configuration.Configuration) str[source]#

Generate HTML representation of the config.

Parameters:

config (Configuration) – The configuration instance to represent.

Returns:

The HTML representation of the config.

Return type:

str

paidiverpy.utils.formating_html.images_repr(images: paidiverpy.images_layer.ImagesLayer, max_images: int = 12, image_number: int | None = None, html: bool = False) str | IPython.display.HTML[source]#

Generate the HTML representation of the object.

Parameters:
  • images (ImagesLayer) – The ImagesLayer object to represent.

  • max_images (int) – The maximum number of images to show. Defaults to 12.

  • image_number (int, optional) – The image number to show. Defaults to None.

  • html (bool) – If True, the output will be in HTML format. Defaults to False.

Returns:

The HTML representation of the object.

Return type:

str | HTML

paidiverpy.utils.formating_html.generate_single_image_html(image_array: numpy.ndarray[Any, Any] | dask.array.core.Array, height: int, width: int, filename: str, step_index: int, image_index: int, size: tuple[int, int] | None, random_id: str) str[source]#

Generate HTML for a single image.

Parameters:
  • image_array (np.ndarray | da.core.Array) – The image array

  • height (int) – The height of the image

  • width (int) – The width of the image

  • filename (str) – The filename of the image

  • step_index (int) – The index of the step

  • image_index (int) – The index of the image

  • size (tuple) – The size of the image

  • random_id (str) – The random id for the image

Returns:

The HTML for the image

Return type:

str

paidiverpy.utils.formating_html.numpy_array_to_base64(image_array: numpy.ndarray[Any, Any] | dask.array.core.Array, size: tuple[int, int] | None) str[source]#

Convert a numpy array to a base64 image.

Parameters:
  • image_array (np.ndarray | da.core.Array) – The image array

  • size (tuple) – The size of the image

Returns:

The base64 image

Return type:

str

paidiverpy.utils.formating_html.style_json_yaml(value: Any) str[source]#

Style the value based on its type.

Parameters:

value (object) – The value to style.

Returns:

The styled value.

Return type:

str