Utils#

This module contains the loss functions used in the project.

Auto Padding#

fusionlab.utils.autopad(kernel_size, padding=None, dilation=1, spatial_dims=2)[source]#

Auto padding for convolutional layers

Make N tuple#

fusionlab.utils.make_ntuple(x, n)[source]#

Make n-tuple from input x. If x is an iterable, then we just convert it to tuple. Otherwise, we will make a tuple of length n, all with value of x. reference: pytorch/vision

Parameters:
  • x (Any) – input value

  • n (int) – length of the resulting tuple

Return type:

Tuple[Any, …]

Show Class Tree#

fusionlab.utils.show_classtree(clss, indent=0)[source]#

Plot channels#

fusionlab.utils.plot_channels(signals, show=True)[source]#

plot signals by channels

Parameters:

signals – numpy array, shape (num_samples, num_channels)

Convert LabelMe json to Mask#

fusionlab.utils.convert_labelme_json2mask(class_names, json_dir, output_dir, single_mask=True)[source]#

Convert labelme json files to mask files(.png)

Parameters:
  • class_names (list) – list of class names, background class must be included at first

  • json_dir (str) – path to json files directory

  • output_dir (str) – path to output directory

  • single_mask (bool) – if True, save single mask file with class index(uint8), otherwise save multiple mask files with class index(uint8)