luting-hnu / EGRCNN

Edge-guided Recurrent Convolutional Neural Network for Multi-temporal Remote Sensing Image Building Change Detection
28 stars 0 forks source link

An error occurs when running the test.py file #2

Open iSuerte opened 3 years ago

iSuerte commented 3 years ago

When I run the test.py file,I get an error saying ' RuntimeError : The expanded size of the tensor(256)must match the existing size(1024)at non-singleton dimension 3.Target sizes:[1,16,256,256].Implication of sizes:[16,1024,1024]'have you ever had this problem and how do you solve it? I am looking forward to your reply. Thank you.

LinkaSage commented 2 years ago

Hello,I have the same problem. Have you solved it?

haimeilv commented 2 years ago

I solved this problem, which is caused by the inconsistency between the input image size and the training. You need to find this code:

trf = transforms.Compose([ transforms.ToTensor(),

transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.255])

])

You need to replace the above code with the following code:

trf = transforms.Compose([ transforms.Resize(img_size), transforms.CenterCrop(img_size), transforms.ToTensor(),

transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.255])

])