Skip to content

Support for GeoTIFF images #6114

@thomas-bouvier

Description

@thomas-bouvier

Is this a new feature, an improvement, or a change to existing functionality?

Improvement

How would you describe the priority of this feature request

Must have (e.g. DALI adoption is impossible due to lack in functionality).

Please provide a clear description of problem this feature solves

I am working on a geospatial application that requires decoding GeoTIFF files. This format does not seem to be supported by DALI. You can see the warnings when decoding such a file with DALI as well as some statistics computed on the result.

original.tif

TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34736 (0x87b0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.                                                                                                                                            
TIFFReadDirectory: Warning, Unknown field with tag 34736 (0x87b0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
[DALI RAW] Shape: torch.Size([874, 1362]) dtype: torch.uint8 min: 1.0000 max: 2.0000 mean: 1.6657
----------Image saved to pipeline_intermediate/dali_raw/image_dali.tif

Result (white border is a result of writing the image with matplotlib): image_dali.tif

For comparison's sake, here is the same image decoded by my original implementation using nvimgcodec:

decoder = nvimgcodec.Decoder(backends=[
    nvimgcodec.Backend(nvimgcodec.BackendKind.GPU_ONLY, load_hint=1.0)
])
decode_params = nvimgcodec.DecodeParams(color_spec=nvimgcodec.ColorSpec.UNCHANGED)
code_stream = nvimgcodec.CodeStream(f'{self.dir_path}/{tif_file}')
out = decoder.decode(code_stream, params=decode_params)
arr = np.array(out.cpu())
print(f"[STANDARD RAW] Shape: {arr.shape} dtype: {arr.dtype} min: {arr.min():.4f} max: {arr.max():.4f} mean: {arr.mean():.4f}")
[STANDARD RAW] Shape: (874, 1362, 1) dtype: uint8 min: 2.0000 max: 2.0000 mean: 2.0000
----------Image saved to pipeline_intermediate/standard_raw/image_standard.tif

image_standard.tif

As you can notice, statistics don't match (even if the result is the same visually).

Feature Description

I would like better support for GeoTIFF files in DALI. The decoder should not be triggering warnings about unknown fields when decoding such files.

Describe your ideal solution

I would like my existing decoder to decode GeoTIFF files too, without any issue.

files = fn.readers.file(files=self.generated_filepaths, random_shuffle=False)
jpegs = fn.decoders.image(
    files,
    device="mixed",
    output_type=types.ANY_DATA,
    bytes_per_sample_hint=50 * 1024 * 1024,
)

Describe any alternatives you have considered

I could probably write an external source, but I would prefer using the DALI decoder directly.

Additional context

  1. Can you please confirm that GeoTIFF files aren't currently supported? original.tif is the file I am trying to decode using DALI.
  2. Could the existing decoder fn.decoders.image() support GeoTIFF files too?

Thank you.

Check for duplicates

  • I have searched the open bugs/issues and have found no duplicates for this bug report

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions