NVIDIA / NVIDIA/DALI

Random parameters for water ops

Open
#2,490 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
5.8k
Forks
678
Avg merge
3d 1h
Merged PRs (30d)
27

Description

Hi,

I am trying to apply water augmentation randomly, but it doesn't work returning error - Tensor value is unexpected for argument.
I tried to randomize freq_x, freq_y,ampl_x,ampl_y
I use same approach as for rotate angle - rotate angle works perfectly fine.

Error when constructing operator: Water encountered:
[/opt/dali/dali/pipeline/operator/op_spec.h:489] Assert on "ws != nullptr" failed: Tensor value is unexpected for argument "freq_x".

Example below - I am trying simply
images = self.water_aug(images, freq_x=self.uniform())
Doesnt' work
I tried many different ways - see some commented out lines. But it doesn't work. Is it unsupported? Rotate angle can be randomized, but water waves can't?

class AugTestPipeline(Pipeline):
def init(self, batch_size, device_id=0, num_threads=4, seed=0):
super(AugTestPipeline, self).init(batch_size, num_threads, device_id)
self.input = ops.TFRecordReader(path = tfrecord,
index_path = tfrecord_idx,
features = {"image/encoded" : tfrec.FixedLenFeature((), tfrec.string, ""),
},
random_shuffle = False)

    self.rotate = ops.Rotate(device="gpu",angle="-90",interp_type=types.INTERP_NN)
    self.rotate_range = ops.Uniform(range = (-2, 2))
    #self.ampl_x_range = ops.Uniform(range = (0.0, 2.0))
    #self.ampl_y_range = ops.Uniform(range = (0.0, 2.0))
    #self.freq_x_range = ops.Uniform(range = (0.0, 0.02))
    #self.freq_y_range = ops.Uniform(range = (0.0, 0.02))
    self.uniform = ops.Uniform(range=(0.0, 1.0)) 
    self.jitter = ops.Jitter(device = "gpu")
    self.water_aug = ops.Water(device = "gpu",fill_value = 255,freq_y=0.02,ampl_x=2.0,ampl_y=2.0)
    self.decode = ops.ImageDecoder(device='mixed', output_type=types.GRAY)
    self.resize = ops.Resize(device = "gpu", size=[1024, 128], mode="not_larger")
    self.pad = ops.Pad(device = "gpu", axis_names="HW", shape=[1024,128], fill_value = 1)
    self.rotate_aug = ops.Rotate(device="gpu", interp_type=types.INTERP_LINEAR, fill_value = 255) 
    self.cmn = ops.CropMirrorNormalize(
        device="gpu",
        dtype=types.FLOAT,
        std=[255.],
        output_layout="HWC")
    
def define_graph(self):
    inputs = self.input()
    images = self.decode(inputs["image/encoded"])
    images = self.rotate(images)
    images = self.jitter(images)
    #ampl_x = self.ampl_x_range()
    #ampl_y = self.ampl_y_range()
    #freq_x = self.freq_x_range()
    #freq_y = self.freq_y_range()
    images = self.water_aug(images, freq_x=self.uniform())
    angle_range = self.rotate_range()
    images = self.rotate_aug(images, angle=angle_range)
    images = self.resize(images)
    images = self.cmn(images)
    images = self.pad(images)
    #labels = inputs["image/class/label"]
    #labels = labels.gpu()
    #return (images, labels)
    return (images)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided AugTestPipeline, focusing on the ops.Water call with freq_x=self.uniform() and compare it with the working Rotate angle input. Start at the reported assertion in /opt/dali/dali/pipeline/operator/op_spec.h:489 and trace how Water handles freq_x. Done means establishing whether randomized Water parameters are supported and documenting or correcting the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
computer-vision, data, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.