This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import torch | |
| import torch.nn as nn | |
| def corrupt_image( | |
| image: torch.Tensor, | |
| patch_size: int = 32, | |
| frac: float = 0.2, | |
| mode: str = "disc", | |
| retrun_proportion: bool = False, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def view_array_patches( | |
| img: np.ndarray, patch_size: tuple, strides: tuple, padding: str = "valid" | |
| ) -> np.ndarray: | |
| """Generates a patched view of an array. | |
| Args: | |
| img (np.ndarray): The input array to be patched. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import cv2 | |
| import numpy as np | |
| from itertools import combinations | |
| __author__ = ['Nico Curti', 'Gianluca Carlini'] | |
| __email__ = ['nico.curti2@unibo.it', 'gianluca.carlini3@unibo.it'] |