Appearance
relai.utils package
Submodules
relai.utils.download module
relai.utils.download.download_relai_resource(name: str)
Download a resource from the RELAI repository. This method downloads the resource (if necessary) to a cache directory which can be set using the environment variable RELAI_CACHE. If unspecified, the cache directory defaults to ~/.cache/relai.
- Parameters:name (str) – Name of the resource to download.
- Returns: Path to the downloaded resource.
- Return type: Path
relai.utils.file_handling module
relai.utils.file_handling.save_imgs_in_dir(dir_path, images, names=None)
relai.utils.file_handling.zip_directory(directory, zip_filename)
relai.utils.image_handling module
relai.utils.image_handling.convert_to_pil(torch_images)
Converts a list of torch tensors to PIL images.
- Parameters:torch_images (list *[*torch.Tensor ] or Dataset) – List of torch tensors or Dataset. Each tensor should have shape (C, H, W) and the pixel values should be in the range [0, 1].
- Returns: List of PIL images.
- Return type: list[PIL.Image.Image]
relai.utils.image_handling.fig2img(fig)
Convert a Matplotlib figure to a PIL Image and return it