domainlab.dsets package

Submodules

domainlab.dsets.a_dset_mnist_color_rgb_solo module

Color MNIST with single color

class domainlab.dsets.a_dset_mnist_color_rgb_solo.ADsetMNISTColorRGBSolo(ind_color, path='zoutput', subset_step=100, color_scheme='both', label_transform=<function mk_fun_label2onehot.<locals>.fun_label2onehot>, list_transforms=None, raw_split='train', flag_rand_color=False)[source]

Bases: Dataset

Color MNIST with single color 1. nominal domains: color palettes/range/spectrum 2. subdomains: color(foreground, background) 3. structure: each subdomain contains a combination of foreground+background color

abstract get_background_color(ind)[source]
abstract get_foreground_color(ind)[source]
abstract get_num_colors()[source]

domainlab.dsets.dset_img_path_list module

class domainlab.dsets.dset_img_path_list.DsetImPathList(root_img, path2filelist, trans_img=None, trans_target=None)[source]

Bases: Dataset

get_list_tuple_img_label()[source]

domainlab.dsets.dset_mnist_color_solo_default module

class domainlab.dsets.dset_mnist_color_solo_default.DsetMNISTColorSoloDefault(ind_color, path='zoutput', subset_step=100, color_scheme='both', label_transform=<function mk_fun_label2onehot.<locals>.fun_label2onehot>, list_transforms=None, raw_split='train', flag_rand_color=False)[source]

Bases: ADsetMNISTColorRGBSolo

get_background_color(ind)[source]
get_foreground_color(ind)[source]
get_num_colors()[source]
property palette

domainlab.dsets.dset_poly_domains_mnist_color_default module

merge several solo-color mnist to form a mixed dataset

class domainlab.dsets.dset_poly_domains_mnist_color_default.DsetMNISTColorMix(n_domains, path, color_scheme='both')[source]

Bases: Dataset

merge several solo-color mnist to form a mixed dataset

class domainlab.dsets.dset_poly_domains_mnist_color_default.DsetMNISTColorMixNoDomainLabel(n_domains, path, color_scheme='both')[source]

Bases: DsetMNISTColorMix

domainlab.dsets.dset_subfolder module

https://github.com/pytorch/vision/blob/bb5af1d77658133af8be8c9b1a13139722315c3a/torchvision/datasets/folder.py#L93 https://pytorch.org/vision/stable/_modules/torchvision/datasets/folder.html#DatasetFolder.fetch_img_paths

class domainlab.dsets.dset_subfolder.DsetSubFolder(root, loader, list_class_dir, extensions=None, transform=None, target_transform=None, is_valid_file=None)[source]

Bases: DatasetFolder

Only use user provided class names, ignore the other subfolders :param list_class_dir: list of class directories to use as classes

domainlab.dsets.dset_subfolder.fetch_img_paths(path_dir, class_to_idx, extensions=None, is_valid_file=None)[source]
Parameters:
  • path_dir – path to fetch images in string format

  • class_to_idx – given list of strings as class names

{classes[i]: i for i in range(len(classes))} :param extensions: file extensions in fstring format :param is_valid_file: user provided function to check if the file is valid or not :return : list_tuple_path_cls_ind: list of tuple, (path of file, class index)

domainlab.dsets.dset_subfolder.has_file_allowed_extension(filename: str, extensions: Tuple[str, ...]) bool[source]

Checks if a file is an allowed extension. Args: filename (string): path to a file extensions (tuple of strings): extensions to consider (lowercase) Returns: bool: True if the filename ends with one of given extensions

domainlab.dsets.utils_color_palette module

domainlab.dsets.utils_data module

Utilities for dataset

class domainlab.dsets.utils_data.DsetInMemDecorator(dset, name=None)[source]

Bases: Dataset

fetch all items of a dataset into memory

domainlab.dsets.utils_data.fun_img_path_loader_default(path)[source]

https://discuss.pytorch.org/t/handling-rgba-images/88428/4

domainlab.dsets.utils_data.mk_fun_label2onehot(dim)[source]

function generator index to onehot

domainlab.dsets.utils_data.plot_ds(dset, f_name, batchsize=32)[source]
Parameters:
  • dset

  • f_name

  • batchsize – batch_size

domainlab.dsets.utils_data.plot_ds_list(ds_list, f_name, batchsize=8, shuffle=False)[source]

plot list of datasets, each datasets in one row :param ds_list: :param fname: :param batchsize: :param shuffle:

domainlab.dsets.utils_wrapdset_patches module

upon a task, if Jigen is chosen as the model, then task’s dataset has to be decorated with image tile permutation note that task’s dataset already include standard image transformations like random croped resized, or flip, and normalization. See also the JiGen paper’s implementation here: https://github.com/fmcarlucci/JigenDG/blob/master/data/JigsawLoader.py

class domainlab.dsets.utils_wrapdset_patches.WrapDsetPatches(dataset, num_perms2classify, prob_no_perm, grid_len, ppath=None, flag_do_not_weave_tiles=False)[source]

Bases: Dataset

given dataset of images, return permuations of tiles of images re-weaved

get_tile(img, ind_tile)[source]

assume a square image?

Module contents