Dataset.py receives different "data" structure for training and inference

Hi there,

I implemented a custom Dataset, which receives a “data” dictionary with two entries (image_files and seg_files) as defined in the dataset.json. This works well when I am training the model:

    data = {
             "image_files":"/home/projects/clara-train-examples/PyTorch/NoteBooks/Data/sampleData/test_data/images/test/", 
             "seg_files":"/home/projects/clara-train-examples/PyTorch/NoteBooks/Data/sampleData/test_data/masks/test/", 
           }

However, when I want to run inference my dataset receives a nested dictionary with “image” as first key, which then holds the correct dictionary with the image_files and seg_files keys as values:

   data = {
           "image": 
                   {
                    "image_files":"/home/projects/clara-train-examples/PyTorch/NoteBooks/Data/sampleData/test_data/images/test/", 
                     "seg_files":"/home/projects/clara-train-examples/PyTorch/NoteBooks/Data/sampleData/test_data/masks/test/", 
                    }
           }

There is no difference within my configurations of the path or within my dataset implementation.
Is this possibly some action performed by medl.apps.evaluate?

Hi LSnyd,

By default we use monai.data.decathlon_datalist — MONAI 0.5.3 documentation

And you can see there the “test” key has different processing logic.

A simple workaround for you is to change the key in dataset.json from “test” to maybe “testing”?

And don’t forget to change corresponding part in config_inference.json (and/or config_validation.json/config_train.json)

Thanks.

1 Like

Thank you, exchanging ‘test’ with ‘testing’ solved the problem!

@yuantingh do you by any chance also know why the SegmentationSaver isn’t working in the Federated Setting (SegmentationSaver not working with FL)?