NVIDIA / NVIDIA/DALI

The shape of tensor obtained by nvidia.dali reads the image is rotated

Open
#2,660 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The shape of tensor obtained by nvidia.dali reads the image is rotated, because the rotated jpeg file has orientation info, dali considers the rotation head information of the jpeg file, but opencv does not consider it。
code:
dali:

class ImageDecoderPipeline(Pipeline):
    def __init__(self, image_dir, batch_size, num_threads, device_id):
        super(ImageDecoderPipeline, self).__init__(batch_size, num_threads, device_id, seed = seed)
        self.input = ops.FileReader(file_root = image_dir)
        if torch.cuda.is_available():
            self.decode = ops.ImageDecoder(device = 'mixed', output_type = types.RGB)  #mixed
            # self.rotate = ops.Rotate(device="gpu", angle = 0.0)
        else:
            self.decode = ops.ImageDecoder(device='cpu', output_type=types.RGB)  # mixed

    def define_graph(self):
        jpegs, labels = self.input()
        images = self.decode(jpegs)
        return (images, labels)

opencv:
input = cv2.imread(file_path)

the jpeg file:
5b214adc0fa1b96ad61322f8e0e72ea0

the head info:
{"size":2534018,"format":"jpeg","width":3000,"height":4000,"colorModel":"ycbcr","orientation":"Right-top"}

obtain by dali and opencv:
dali: image
opencv: image

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

Start with the provided ImageDecoderPipeline and ops.ImageDecoder example, then reproduce the report with the linked JPEG and compare its tensor shape with cv2.imread. Trace how JPEG orientation metadata is handled and verify the resulting behavior against the reported DALI and OpenCV outputs; done means the discrepancy is resolved or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, opencv, python
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.