There are some minor issues in your code:
- The error is thrown, since you are returning
self.len
in__len__
, without defining it. You should rather return something likelen(self.image_list)
(, which won’t currently work, but that’s the next point). - You are loading all images in
__init__
without storingimage_list
. Your__getitem__
won’t be able to callself.image_list
to open an image. However, even if you properly storedimage_list
usingself.image_list = []
, you are trying to open the image again. I would recommend to just store image paths in__init__
and load the images in__getitem__
. - Currently you are not using any target. It seems just the data is loaded without the segmentation masks.
-
Dataset.random_split
is not defined by default. You could split the image/mask paths and create two separateDatasets
, one for training and another for validation.
Here is a small example I’ve written some time ago.
Let me know, if you can use it as a starter code and adapt it to your use case.