default_collate error while trying to quantize my pytorch model #1921
-
Hi, val_dataset = datasets.ImageFolder(path1)
dataset_loader = torch.utils.data.DataLoader(val_dataset)
def transform_fn(data_item):
images,_=data_item
print(type(images))
return(images)
calibration_dataset = nncf.Dataset(dataset_loader, transform_fn)
quantized_model = nncf.quantize(model, calibration_dataset)
torch.save(model, path2) I keep running in this error: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'PIL.Image.Image'> on line: quantized_model = nncf.quantize(model, calibration_dataset) I'm new to pytorch and I have no idea on how to fix this. Any help? I'm running on pytorch version 2.0.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @CostatoMarco, I guess that images weren’t transformed to Tensors. The same error was discussed here link I would recommend to check that your
|
Beta Was this translation helpful? Give feedback.
This time it seems that the error is unrelated to NNCF. Looks like you have to specify a
transform=...
parameter when instantiating theImageFolder
as specified in the docs to maybe transform the PIL image to atorch.Tensor
or something.