Skip to main content

utils

General helpful utilities to be found here.

Module

Submodules

Functions

is_notebook

def is_notebook()> bool:

Checks if code is being executed in a notebook or not.

one_hot_encode_list

def one_hot_encode_list(    targets: Union[np.ndarray, Iterable[np.ndarray], Iterable[int], Iterable[Iterable[int]]],)> numpy.ndarray:

Converts a list of targets into a list of one-hot targets.

seed_all

def seed_all(seed_value: Optional[int] = None)> None:

Sets random seed for numpy, python.random and any other relevant library.

If pytorch is used as the backend, this is just a wrapper around the seed_everything function from pytorch-lightning.

info

PYTHONHASHSEED is not set as an environment variable because this has no effect once the process has been started. If you wish to set this, you should set it yourself in your own environment before running python.

Arguments

  • seed_value: The seed value to use. If None, uses the default seed (42).

Classes

ExampleSegmentationData

class ExampleSegmentationData():

A synthetic segmentation dataset example.

This class is used mainly in Tutorial 10 and testing.

Methods


generate_data

def generate_data(self, height: int, width: int, count: int)> tuple:

Generate random data given height, weight and count.

Arguments

  • height: The height of the images to generate.
  • width: The width of the images to generate.
  • count: The number of images to generate.

masks_to_colorimg

def masks_to_colorimg(self, masks: np.ndarray)> numpy.ndarray:

Adds RGB coloring to masks.

Arguments

  • masks: The masks to which we want to add coloring.

Returns The masks with RGB coloring applied to them.