Yes, it’s pretty common to write your own.
You have a lot of freedom to implement the len and getitem methods to accommodate your use case, folder structure, etc.
len needs to return the size of the dataset
getitem needs to return your image tensor for the image with index ‘idx’. You can also return labels, bounding boxes, etc as required for training.
Transforms can be leveraged, but aren’t required.
The sample code above should work… Just pass in your image folder path when you instantiate the DataSet.
ex:   my_dataset = CustomDataSet(“path/to/root/”, transform=your_transforms)
If you aren’t using transforms, remove the 3 references to transform in your CustomDataSet code.