basicsr.utils.misc

basicsr.utils.misc.check_resume(opt, resume_iter)[source]

Check resume states and pretrain_network paths.

Parameters:
  • opt (dict) – Options.

  • resume_iter (int) – Resume iteration.

basicsr.utils.misc.get_time_str()[source]
basicsr.utils.misc.make_exp_dirs(opt)[source]

Make dirs for experiments.

basicsr.utils.misc.mkdir_and_rename(path)[source]

mkdirs. If path exists, rename it with timestamp and create a new one.

Parameters:

path (str) – Folder path.

basicsr.utils.misc.scandir(dir_path, suffix=None, recursive=False, full_path=False)[source]

Scan a directory to find the interested files.

Parameters:
  • dir_path (str) – Path of the directory.

  • suffix (str | tuple(str), optional) – File suffix that we are interested in. Default: None.

  • recursive (bool, optional) – If set to True, recursively scan the directory. Default: False.

  • full_path (bool, optional) – If set to True, include the dir_path. Default: False.

Returns:

A generator for all the interested files with relative paths.

basicsr.utils.misc.set_random_seed(seed)[source]

Set random seeds.

basicsr.utils.misc.sizeof_fmt(size, suffix='B')[source]

Get human readable file size.

Parameters:
  • size (int) – File size.

  • suffix (str) – Suffix. Default: ‘B’.

Returns:

Formatted file size.

Return type:

str