NVIDIA / NVIDIA/DALI

crop and resize are both executed in fn.decoders.image_random_crop fn.resize and fn.crop_mirror_normalize, what is the difference

Open
#4,640 1 comment 0 reactions 1 assignee View on GitHub

@JanuszL is already working on this.

Since Feb 7, 2023.

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

Description

When I run code in main.py, I have the following questions. Many thanks in advance for your help!

In the following code, both of image_random_crop, resize, and crop_mirror_normalize resize and crop the image, but what is the different, and whether the resize_x and random_aspect_ratio affects the final output

images = fn.decoders.image_random_crop(images,
                                               device=decoder_device, output_type=types.RGB,
                                               device_memory_padding=device_memory_padding,
                                               host_memory_padding=host_memory_padding,
                                               preallocate_width_hint=preallocate_width_hint,
                                               preallocate_height_hint=preallocate_height_hint,
                                               random_aspect_ratio=[0.8, 1.25],
                                               random_area=[0.1, 1.0],
                                               num_attempts=100)
  images = fn.resize(images,
                     device=dali_device,
                     resize_x=crop,
                     resize_y=crop,
                     interp_type=types.INTERP_TRIANGULAR)
 mirror = fn.random.coin_flip(probability=0.5)
 images = fn.crop_mirror_normalize(images.gpu(),
                                  dtype=types.FLOAT,
                                  output_layout="CHW",
                                  crop=(crop, crop),
                                  mean=[0.485 * 255,0.456 * 255,0.406 * 255],
                                  std=[0.229 * 255,0.224 * 255,0.225 * 255],
                                  mirror=mirror)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.