未验证 提交 bbf14230 编写于 作者: W wangguanzhong 提交者: GitHub

fix gridmask (#2695)

上级 9eb9cd13
......@@ -45,8 +45,7 @@ class Gridmask(object):
self.prob = self.st_prob * min(1, 1.0 * curr_iter / self.upper_iter)
if np.random.rand() > self.prob:
return x
# image should be C, H, W format
_, h, w = x.shape
h, w, _ = x.shape
hh = int(1.5 * h)
ww = int(1.5 * w)
d = np.random.randint(2, h)
......@@ -74,7 +73,7 @@ class Gridmask(object):
if self.mode == 1:
mask = 1 - mask
mask = np.expand_dims(mask, axis=0)
mask = np.expand_dims(mask, axis=-1)
if self.offset:
offset = (2 * (np.random.rand(h, w) - 0.5)).astype(np.float32)
x = (x * mask + offset * (1 - mask)).astype(x.dtype)
......
......@@ -46,7 +46,7 @@ class GridMask(object):
if np.random.rand() > self.prob:
return x
# image should be C, H, W format
_, h, w = x.shape
h, w, _ = x.shape
hh = int(1.5 * h)
ww = int(1.5 * w)
d = np.random.randint(2, h)
......@@ -74,7 +74,7 @@ class GridMask(object):
if self.mode == 1:
mask = 1 - mask
mask = np.expand_dims(mask, axis=0)
mask = np.expand_dims(mask, axis=-1)
if self.offset:
offset = (2 * (np.random.rand(h, w) - 0.5)).astype(np.float32)
x = (x * mask + offset * (1 - mask)).astype(x.dtype)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册