Skip to content

utils

ensure_dir

Create directory if it does not exist

ensure_file_dir

Create path if it does not exist

get_device

If Cuda is available, use Cuda device, else use CPU device When choosing from Cuda devices, this function will choose the one with max memory available

validate_xy

Check x_train's type and the shape of x_train, y_train.

read_csv_file

Read the csv file and returns two separate list containing files name and their labels.

Args
  • csv_file_path: Path to the CSV file.
Returns
  • file_names: List containing files names.

  • file_label: List containing their respective labels.

compute_image_resize_params

Compute median height and width of all images in data. These values are used to resize the images at later point. Number of channels do not change from the original images. Currently, only 2-D images are supported.

Args
  • data: 2-D Image data with shape N x H x W x C.
Returns
  • median height: Median height of all images in the data.

  • median width: Median width of all images in the data.

resize_image_data

Resize all images in data to size h x w x c, where h is the height, w is the width and c is the number of channels. The number of channels c does not change from data. The function supports only 2-D image data.

Args
  • data: 2-D Image data with shape N x H x W x C.

  • h: Image resize height.

  • w: Image resize width.

Returns
  • data: Resize data.

get_system

Get the current system environment. If the current system is not supported, raise an exception.

Returns