-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Thanks for the great work! I was trying to understand the RandomColorJitter function better and noticed while debugging self.jitter parameters it calculates individual color jitters also for uncorrupted images. This happens because RandomColorJitter is applied for all samples with element type COLOR_IMAGE. Is this wanted behaviour? Uncorrupted images are used at least for calculating smoothness loss and in my opinion they should be calculated for completely original images without any photometric transformations. I could be wrong though.
I tested this effect with following changes to RandomColorJitter
class RandomColorJitter(object):
"""Randomly adjust image hue, saturation, gamma, etc."""
def __init__(self, generator):
self.generator = generator
brightness_scale = 0.5
contrast_scale = 0.5
saturation_scale = 0.5
hue_scale = 0.05
self.jitter = torchvision.transforms.ColorJitter(brightness_scale, contrast_scale, saturation_scale, hue_scale)
def __call__(self, sample):
if self.generator is not None:# and self.generator.random() > 0.5:
for key, element in sample.elements.items():
if element.type == ElementType.COLOR_IMAGE:
print(key)
gamma = random.uniform(0.8, 1.2)
print(gamma)
print(torchvision.transforms.ColorJitter.get_params(self.jitter.brightness, self.jitter.contrast, self.jitter.saturation, self.jitter.hue))
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
new_data = np.array(self.jitter(
torchvision.transforms.functional.adjust_gamma(Image.fromarray(sample.get_data(key)),
gamma=gamma)))
sample.set_data(key, new_data)
return sample
Metadata
Metadata
Assignees
Labels
No labels