How to get corresponding training labels and validation labels from dataloader?

Hi, I have a question about how to get the training labels and validation labels for each example?

There is an API called dls.valid_ds.items that can get the training data. But how do I get the corresponding training labels related to each training data?

Thank you very much.

each item has 2 elements, the first an Image and the second a TensorCategory or TensorMultiCategory

Hi rsomani95, really thank you for your answer. Actually, the dls.valid_ds.items returns a list which only contains the path of the images, I didn’t find any corresponding label related to it. Is there anything I missed in here?

Thank you.

I can be more helpful if you show me how you’re constructing your DataBlock. It sounds like there’s something missing there and so no labels are being created for the valid_ds.

Are you seeing two elements per item in dls.train_ds.items?

Thank you,

My ‘DataBlock’ looks like below:
DataBlock(blocks=(ImageBlock, CategoryBlock),
splitter=RandomSplitter(valid_pct=0.3, seed=42),
item_tfms=RandomResizedCrop(224, min_scale=0.5),
I use the parent folder’s name as the label and when I called ‘dls.train_ds.items’ , it return a list which contains the path of training example. But I cannot get the corresponding labels.

Thank you.