목록DE (34)
UOMOP
def patch_importance(image, patch_size=2, type='variance', how_many=2, noise_scale=0): if isinstance(image, torch.Tensor): image = image.numpy() H, W = image.shape[-2:] extended_patch_size = patch_size + 2 * how_many value_map = np.zeros((H // patch_size, W // patch_size)) for i in range(0, H, patch_size): for j in range(0, W, patch_size): start_i = max(i ..
import torchimport numpy as npimport matplotlib.pyplot as pltfrom torchvision.datasets import CIFAR10from torchvision.transforms import ToTensor# Load CIFAR-10 datasetcifar10 = CIFAR10(root='.', download=True, transform=ToTensor())image, _ = cifar10[0]images = image.unsqueeze(0) # Add batch dimension# Define the random_mask functiondef random_mask(images, patch_size=2, mask_ratio=0.5): B, C,..
import numpy as npimport cv2import torchimport torch.nn.functional as Fimport torchvision.transforms as transformsimport torchvision.datasets as datasetsfrom torch.utils.data import DataLoaderimport matplotlib.pyplot as pltdef patch_importance(image, patch_size=2, type='variance', how_many=2, noise_scale=0): if isinstance(image, torch.Tensor): image = image.numpy() H, W = image.shap..
import numpy as npimport cv2import torchimport torch.nn.functional as Fimport torchvision.transforms as transformsimport torchvision.datasets as datasetsfrom torch.utils.data import DataLoaderimport matplotlib.pyplot as pltdef patch_importance(image, patch_size=2, type='variance', how_many=2, noise_scale=0): if isinstance(image, torch.Tensor): image = image.numpy() H, W = image.shap..