Dali: How to use random color jitter

Created on 1 Dec 2018  路  2Comments  路  Source: NVIDIA/DALI

the function ops.Brightness takes a fixed parameter brightness, how can I use random brightness during training ?

Most helpful comment

Hi,
thanks for the question. For random color augmentations you could use ColorTwist op with Uniform op for random values. In your pippeline __init__ function do something like:

self.twist = ops.ColorTwist(device="gpu")
self.rng1 = ops.Uniform(range=[0.5, 1.5])
self.rng2 = ops.Uniform(range=[0.875, 1.125])
self.rng3 = ops.Uniform(range=[-0.5, 0.5])

and then in define_graph you can do:

saturation = self.rng1()
contrast = self.rng1()
brightness = self.rng2()
hue = self.rng3()

# Obtain images ...

images = self.twist(
    images, saturation=saturation, contrast=contrast, brightness=brightness, hue=hue)

More detailed documentation of this op you can find in DALI docs here

All 2 comments

Hi,
thanks for the question. For random color augmentations you could use ColorTwist op with Uniform op for random values. In your pippeline __init__ function do something like:

self.twist = ops.ColorTwist(device="gpu")
self.rng1 = ops.Uniform(range=[0.5, 1.5])
self.rng2 = ops.Uniform(range=[0.875, 1.125])
self.rng3 = ops.Uniform(range=[-0.5, 0.5])

and then in define_graph you can do:

saturation = self.rng1()
contrast = self.rng1()
brightness = self.rng2()
hue = self.rng3()

# Obtain images ...

images = self.twist(
    images, saturation=saturation, contrast=contrast, brightness=brightness, hue=hue)

More detailed documentation of this op you can find in DALI docs here

@awolant That works, thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kfhe00 picture kfhe00  路  5Comments

dhkim0225 picture dhkim0225  路  4Comments

bamfpga picture bamfpga  路  3Comments

ZHUANGHP picture ZHUANGHP  路  5Comments

simonJJJ picture simonJJJ  路  3Comments