jaclearn.visualize package

Submodules

jaclearn.visualize.box module

jaclearn.visualize.box.add_bbox_patches(ax, boxes: numpy.ndarray, class_name: Union[str, List[str]], add_text=True, legends: Union[str, List[str], None] = None, fontsize: Optional[int] = 14)[source]
jaclearn.visualize.box.vis_bboxes(image: PIL.Image.Image, boxes: numpy.ndarray, class_name: Union[str, List[str]], add_text=True, legends: Union[str, List[str], None] = None, title: Optional[str] = None, fontsize: Optional[int] = 14)[source]

jaclearn.visualize.html_table module

class jaclearn.visualize.html_table.HTMLTableColumnDesc[source]

Bases: jaclearn.visualize.html_table._HTMLTableColumnDesc

class jaclearn.visualize.html_table.HTMLTableVisualizer(visdir, title)[source]

Bases: object

A helper class to generate HTML tables.

Example

>>> vis = HTMLTableVisualizer('<some_dir>', 'Visualization')
>>> with vis.html():
>>>     with vis.table('Table Name', [
>>>         HTMLTableColumnDesc('column1', 'Image', 'image', {'width': '120px'}),
>>>         HTMLTableColumnDesc('column2', 'Result', 'figure' {}),
>>>         HTMLTableColumnDesc('column3', 'Supervision', 'text' {}),
>>>         HTMLTableColumnDesc('column4', 'Prediction', 'code' {'font-size': '12px'})
>>>     ]):
>>>         vis.row(...)
FRAMES_JS = '\n<script\n src="https://code.jquery.com/jquery-3.6.0.slim.min.js"\n integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI="\n crossorigin="anonymous"\n></script>\n<script>\nfunction frameMove(elem, offset) {\n elem = $(elem);\n window.elem = elem;\n data = JSON.parse(elem.parent().find(".data").html());\n index = parseInt(elem.parent().find(".index").val());\n\n nextIndex = index + offset;\n if (nextIndex < 0) nextIndex = 0;\n if (nextIndex >= data.length) nextIndex = data.length - 1;\n\n elem.parent().find(".index").val(nextIndex);\n if ("image" in data[nextIndex]) {\n elem.parent().find(".image").attr("src", data[nextIndex]["image"][0]).attr("alt", data[nextIndex]["image"][1]);\n } else {\n elem.parent().find(".text").html(data[nextIndex]["text"]);\n }\n\n if ("info" in data[nextIndex]) {\n elem.parent().find(".info").html("Frame #" + nextIndex.toString() + " :: " + data[nextIndex]["info"]);\n } else {\n elem.parent().find(".info").html("Frame #" + nextIndex.toString());\n }\n}\n</script>\n '
begin_html()[source]
begin_table(name, columns_or_spec_id)[source]
define_table(columns)[source]
end_html()[source]
end_table()[source]
get_asset_filename(row_identifier, col_identifier, ext)[source]
get_index_filename()[source]
html()[source]
row(*args, **kwargs)[source]
save_figure(figure, row_identifier, col_identifier, ext='png')[source]
save_image(image, row_identifier, col_identifier, ext='png')[source]
table(name, columns_or_spec_id)[source]

jaclearn.visualize.imgrid module

jaclearn.visualize.imgrid.image_grid(all_images, grid_desc)[source]

Create a image grid given the description. The description is a list of axis desc, of format: %d[h|v]. If the first number n is a positive number, every n images will be concatenated horizontally or vertically. We allow exactly one axis desc to be only [h|v], meaning the number of images of that axis will be automatically inferred.

Parameters:
  • all_images – A list of images. Should be np.ndarray of shape (h, w, c).
  • grid_desc – The grid description.
Returns:

A single big image created.

jaclearn.visualize.imshow module

jaclearn.visualize.imshow.batch_show(batch, nr_show=16, grid_desc=('4v', '4h'), resize=(600, 800), title='batch_show')[source]

Show a batch of images.

Parameters:
  • batch – The batched data: can be either a ndarray of shape (batch_size, h, w, c) or a list of images.
  • nr_show – Number of images to be displayed. Default set to be 16.
  • grid_desc – Grid description. See tartist.image.image_grid for details.
  • resize – Resize factor, a tuple (min_dim, max_dim).
  • title – The title of the shown window.
jaclearn.visualize.imshow.imshow(img, resize=(600, 800), title='imshow')[source]

Image show with different parameter order.

Parameters:
  • img – Image.
  • resize – Resize factor, a tuple (min_dim, max_dim).
  • title – The title of the shown window.

jaclearn.visualize.plot module

jaclearn.visualize.plot.plot2opencv(fig)[source]

Convert a pyplot instance to image

jaclearn.visualize.plot.plot2pil(fig)[source]
jaclearn.visualize.plot.heatmap2pil(heatmap, normalization='none', minval=0, maxval=1)[source]