Oberon
December 12, 2023, 1:35pm
1
Hi, I’m new to PyTorch. I’m trying to using ImageFolder
to load my own dataset.
When I load the folder, the imgs/samples are:
[
("img0path.ext",0),
("img1path.ext",0),
...
]
For some reasons, I need to group them up by targets, just like:
[
0=[img list of targets 0],
1=[img list of targets 1],
...
]
Is there any convenient way to make this? Or shall I need to implement this on hand?
ptrblck
December 12, 2023, 2:04pm
2
You could create a custom Dataset
and use the ImageFolder
as a template or base class, which would probably the cleanest approach.
Oberon
December 13, 2023, 10:14am
3
I see…Actually, I intended to make a siamese pair/triplet dataset with image folder, so that means I have to implement this by myself?
ptrblck
December 13, 2023, 5:40pm
4
I’m not aware of any dataset implementations for your siamese use case, so I would assume you need to implement a custom Dataset
. However, you can of course check other repositories to see if these would provide the needed classes.