gathierry / FastFlow

Apache License 2.0
124 stars 22 forks source link

RuntimeError: The size of tensor a (9) must match the size of tensor b (3) at non-singleton dimension 0 #15

Closed Six-walnuts-Lu closed 1 year ago

Six-walnuts-Lu commented 1 year ago

Hello, thank you for your reproduction work. I used the grid data set in MVtec to reproduce, and the reproduction was very successful. However, I have a problem when I put my own data set into it. I have studied it for a long time and have not found a solution to the problem. I would like to ask for advice. 1660527826075

gathierry commented 1 year ago

how many channels does your data have? what's the shape of your input tensor

Six-walnuts-Lu commented 1 year ago

train and test data is 3 channels,ground_truth is 1 channels,the shape of my input tensor is [1024,1024]

gathierry commented 1 year ago

I'm not sure what the problem is. But it's pretty obvious that there's something wrong with the transforms.Normalize. My suggestion is to check the dataset, especially the shape of the tensors.

linzengmin commented 1 year ago

I got the problem.My solution is that change those image with something wrong.

founderlin commented 1 year ago

I guess the size of input image does not match the feature extractor, e.g. 256 -> Resnet18

cytotoxicity8 commented 1 year ago

Well, the size of input image won't matter because of Resize() call. (Unless the horizontal length and vertical one are different. However this will call another error.) Well, I guess the reason is in MVTecDataset.image_transform in dataset.py. If you insert some codes as transforms.Lambda(lambda x: x.repeat(3, 1, 1)), the same error will occur.