msamogh/nonechucks

How to handle TypError using nonechucks

simongeek opened this issue · 7 comments

Hi,

How to handle TypeError using nonechucks?

I have 162400 annotations (260 labels per one annotation) in json file. Each annotation contains filename for example aaa.jpg. I load photos based on filename from annotation json file. My image dataset contains 162000 images, so I do not have 400 photos in the collection. If the dataloader comes across the name of the annotation image and is not in the image set, it returns TypeError to me.
Do you know how to catch this error using your library? I tried SafeDataLoader and it does not work.
I also tried try except, but if I print a picture as None, I get a Class TypeNone error.
Best!

Are you using the SafeDataloader in conjunction with the SafeDataset?

Yes, I also tried separately and it does not work.

Can I replace in class SimpleCustomDataset(Dataset) to SimpleCustomDataset(nc.SafeDataset)?

You can do

custom_dataset = SimpleCustomDataset()

safe_custom_dataset = nc.SafeDataset(custom_dataset)

when I try:

mvc_dataset = MVCDataset(json_file="labels.json",
                         root="data", transform=transform, target_transform=None)

save_mvc_dataset = nc.SafeDataset(mvc_dataset)

I got TypeError: TypeError: batch must contain tensors, numbers, dicts or lists; found <class 'NoneType'>

Could you paste your full stack trace?

Closing due to no response.