dali_backend
dali_backend copied to clipboard
How to get list of image paths into dali pipeline?
I'm looking to do something like this:
@pipeline_def(batch_size=1, num_threads=4, device_id=0)
def custom_pipeline():
# Triton will provide the input through "DALI_INPUT_0"
# Here, we expect image paths
image_paths = fn.external_source(device="cpu", name="DALI_INPUT_0")
# Load and decode the images
images = fn.readers.file(file_root="", files=image_paths, device="cpu")
images = fn.decoders.image(images, device="mixed", output_type=types.RGB)
# Resize to 384x384 using bicubic interpolation
images = fn.resize(images, resize_x=384, resize_y=384, interp_type=types.INTERP_CUBIC)
# Normalize
images = fn.crop_mirror_normalize(
images,
dtype=types.FLOAT,
mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],
std=[0.229 * 255, 0.224 * 255, 0.225 * 255],
output_layout="CHW")
return images
However, this code has an error:
The argument files
for operator File
should not be a DataNode
but a str or list of str
This seems to be because fn.readers.file doesn't support a DataNode which is returned by external_source. So in this case, how would I get the underlying list of strings that external_source contains to fn.readers.file so it can read in all those images?