GridMask icon indicating copy to clipboard operation
GridMask copied to clipboard

Gridmask can't be added to the compse step?

Open M-Ghorbel opened this issue 4 years ago • 3 comments

Hello

I want to remplace Randomerasing by Gridmask in the compse step

def get_transform(resize, phase='train'): if phase == 'train': return transforms.Compose([ transforms.Resize(size=(int(resize[0] / 0.875), int(resize[1] / 0.875))), transforms.RandomHorizontalFlip(0.5), transforms.ColorJitter(brightness=0.126, saturation=0.5), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), GridMask(200, 300, rotate = 1, ratio = 0.8, mode=1, prob=1) ])

but i'm getting this error

n,c,h,w = x.size() ValueError: not enough values to unpack (expected 4, got 3)

i think that it need a batch, so is it possible to use it in compose ?

M-Ghorbel avatar Nov 22 '20 08:11 M-Ghorbel

Of course, you can use it in compose, just use Grid instead of GridMask in grid.py

akuxcw avatar Nov 23 '20 06:11 akuxcw

i remplaced GridMask by Grid but i'm getting this error

"...grid.py", line 70, in__call__

mask = torch.from_numpy(mask).float().cuda() RuntimeError: CUDA error: initialization error

M-Ghorbel avatar Nov 24 '20 13:11 M-Ghorbel

i remplaced GridMask by Grid but i'm getting this error

"...grid.py", line 70, in__call__

mask = torch.from_numpy(mask).float().cuda() RuntimeError: CUDA error: initialization error

you can do like this: mask = torch.from_numpy(np.array(mask))

curryandsun avatar Dec 01 '20 08:12 curryandsun