juspice.utils

Helpers for image files, augmentation and mask generation.

Main functions:

  • save_image_using_plt(), save_frames_using_plt(): save arrays as borderless grayscale images.

  • load_images(): load all images in a folder.

  • load_and_preprocess_images_and_masks(): resize image/mask pairs and save them.

  • standard_augmentations(): randomly flip, scale, rotate and shear an image/mask pair and fill the uncovered background with IOPaint (LaMa).

  • generate_mask_auto(): build a foreground mask from a grayscale image automatically.

  • generate_masks_from_synth_images_for_aug(): create masks for augmented images.

  • remove_noise_from_mask(), postprocess_prob_mask(): clean up masks.

torchvision is optional and only needed by the augmentation and preprocessing functions. IOPaint is an external command installed in its own environment at venvs/.venv_iopaint (uv sync --only-group iopaint), because its dependencies conflict with the [dl] extra.