I know it may seem a little bit counter-intuitive but you should be using CropMirrorNormalize (minus the crop and mirror options). The DALI and CUDA kernels have compile time mechanisms to reduce the runtime overhead (to none).

how can you use CropMirrorNormalize without crop? not setting any values for any of the crop parameters simply crops to half because of default = 0.5 for both of crop_pos_x and crop_pos_y.

You can actually do it with the Cast operator.

how? i tried to cast prior to resize (because resize expects uint8) but i just … a cast i.e. my images were all black because i got truncation of the floats the came out of the decoder.

I guess you mean Crop after Resize.

sorry yes you’re right.

but performance-wise it is better to first crop first to not apply the interpolation algorithm on a data that will be cropped anyway.

that makes sense but i feel like i should be able to choose to take the penalty. just so we’re concrete: i would like to crop a high resolution image randomly, then resize to half (or quarter scale) in order to produce a low resolution image (i’m working on super resolution networks). right now i do using decodercrop then resize and i have to normalize in just plain pytorch

  
      github.com
  
  
    makslevental/atlas_sr/blob/master/data_utils/dali.py#L96 2

# https://github.com/NVIDIA/DALI/issues/1227
def __init__(self, *args, **kwargs):
    self.dali_iter = DALIGenericIterator(*args, **kwargs)


def __iter__(self):
    return self


def __next__(self):
    n = next(self.dali_iter)
    lr_image, hr_image = n[0]["lr_image"], n[0]["hr_image"]
    hr_image = hr_image.to(torch.float).div(255)
    lr_image = lr_image.to(torch.float).div(255)
    hr_image = hr_image.permute(0, 3, 1, 2)
    lr_image = lr_image.permute(0, 3, 1, 2)
    return lr_image, hr_image


@property
def size(self):
    return self.dali_iter._size


# hack to make lr_finder work



  
  
    
    
  
  


not ideal. i want to compose decoder -> cropmirrornormalize -> resize but i can’t because of data width mismatches (if i recall correctly resize complains about not getting uint8s for this composition).

It is great to see that you are able to use it to accelerate your training.

yes it’s definitely great - i’m able to saturate my gpus (sometimes a little too much and they get hot  .