dvlab-research / GridMask

283 stars 55 forks source link

Gridmask can't be added to the compse step? #16

Open M-Ghorbel opened 4 years ago

M-Ghorbel commented 4 years ago

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 ?

akuxcw commented 4 years ago

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

M-Ghorbel commented 4 years ago

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

"...grid.py", line 70, incall

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

curryandsun commented 4 years ago

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

"...grid.py", line 70, incall

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

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