Unverified Commit 89edfaaa authored by KAI ZHAO's avatar KAI ZHAO Committed by GitHub
Browse files

add __repr__ for transforms.RandomErasing (#3491)

parent 945f3a8b
...@@ -1991,6 +1991,9 @@ class Tester(unittest.TestCase): ...@@ -1991,6 +1991,9 @@ class Tester(unittest.TestCase):
p_value = stats.binom_test(count_bigger_then_ones, trial, p=0.5) p_value = stats.binom_test(count_bigger_then_ones, trial, p=0.5)
self.assertGreater(p_value, 0.0001) self.assertGreater(p_value, 0.0001)
# Checking if RandomErasing can be printed as string
t.__repr__()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -1630,6 +1630,14 @@ class RandomErasing(torch.nn.Module): ...@@ -1630,6 +1630,14 @@ class RandomErasing(torch.nn.Module):
return F.erase(img, x, y, h, w, v, self.inplace) return F.erase(img, x, y, h, w, v, self.inplace)
return img return img
def __repr__(self):
s = '(p={}, '.format(self.p)
s += 'scale={}, '.format(self.scale)
s += 'ratio={}, '.format(self.ratio)
s += 'value={}, '.format(self.value)
s += 'inplace={})'.format(self.inplace)
return self.__class__.__name__ + s
class GaussianBlur(torch.nn.Module): class GaussianBlur(torch.nn.Module):
"""Blurs image with randomly chosen Gaussian blur. """Blurs image with randomly chosen Gaussian blur.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment