blocks.utils.demo

Classes

class blocks.utils.demo.DemoOutputBuilder[source]

Bases: object

Building demo outputs to be displayed in Iterait demo web application.

example usage
output = blocks.utils.DemoOutputBuilder().add_image(im).add_table(['col1', 'col2'], [['lorem ipsum', im2]]).output
# output ~ demo-compatible json-serializable dict
Inheritance diagram of DemoOutputBuilder

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

add_image(image, extension='.jpg')[source]

Add image block to the output.

Return type

DemoOutputBuilder

add_image_transformation(original, transformed, extension='.jpg')[source]

Add image comparison block to the output.

Return type

DemoOutputBuilder

add_table(header, rows)[source]

Add table block to the output.

Parameters
  • header (Sequence[str]) – table header - a sequence of strings

  • rows (Sequence[Sequence[Union[str, ndarray]]]) – a sequence of rows wherein row is a sequence of strings/images

Return type

DemoOutputBuilder

property output

Return demo-compatible json-serializable dict.

@teyras suggests to use this in dataset’s postprocess_batch, shepherd runner or emloop model.

Return type

dict