DALI icon indicating copy to clipboard operation
DALI copied to clipboard

help, how to decode png byte numpy array that with shape [batch, length, image_byte]

Open Sino-Huang opened this issue 3 years ago • 2 comments

Hello, I am currently try to use external source method to read videos that are stored as a sequence of image frames (fixed length). However, it looks like the fn.decoders.image function only allows to decode data with shape [batch, image_byte]. Is there any way that I can modify the shape from [batch, length, image_byte] to [batch * length, image_byte] in define_graph section? Currently I cannot modify the ExternalSourceIterator class so I can only obtain png byte numpy array that with shape [batch, length, image_byte] and then I cannot find way to reshape data in nvidia.dali.pipeline.DataNode in define_graph function

Sino-Huang avatar Jun 28 '22 14:06 Sino-Huang

@Sino-Huang ,

fn.decoders.image operator decodes images. It unfortunately cannot maintain the order. Should you like to read sequences or videos, please use either fn.readers.sequence (for reading videos stored in a image files) or fn.readers.video (for loading files in video format). Please also refer to the video processing section in our tutorials to see examples of using those operators.

Note, that both SequenceReader and VideoReader are special cases of Readers, which are fused with the decoder, so you don't have to decode the images manually.

szalpal avatar Jun 28 '22 15:06 szalpal

Hi @Sino-Huang,

I think this example shows how to read a sequence of images using the external source operator and decode them to form a sequence.

JanuszL avatar Jun 28 '22 16:06 JanuszL