조현아

resolved PIL image error

......@@ -13,7 +13,7 @@ class BaseTransform(ABC):
self.mag = mag
def __call__(self, img):
return transforms.RandomApply([self.transform], self.prob)(img)
return transforms.RandomApply([self.transform], self.prob)(img) ##
def __repr__(self):
return '%s(prob=%.2f, magnitude=%.2f)' % \
......@@ -154,8 +154,19 @@ class CutoutOp(object):
mask[y1: y2, x1: x2, :] = 0.
img = mask*np.asarray(img).astype(np.uint8)
img = Image.fromarray(mask*np.asarray(img))
# img = mask*np.asarray(img).astype(np.uint8)
# print("\nmask max:\n", np.amax(mask), mask.shape) #(32, 32, 1)
# print("\nnp.asarray(img) max: \n", np.amax(np.asarray(img)), np.asarray(img).shape) #(32, 32, 32)
# img = Image.fromarray(mask*np.asarray(img)) #(32, 32, 32)
mask = np.reshape(mask, (32,32))
#print("\n(img) max: \n", np.amax(np.asarray(img)), np.asarray(img).shape) #[0, 255] (32, 32)
# print("\nmask: ", mask.shape) #(32, 32)
# print("\img: ", np.asarray(img).shape) #(32, 32)
# print("mask*img:\n", (mask*np.asarray(img).astype(np.uint8)).shape)
#ㄴ[0, 255], (32, 32)
img = Image.fromarray(mask*np.asarray(img).astype(np.uint8)) #
return img
......