Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hr_image and hr_edge are in different sizes #4

Open
n0acar opened this issue Nov 10, 2019 · 1 comment
Open

hr_image and hr_edge are in different sizes #4

n0acar opened this issue Nov 10, 2019 · 1 comment

Comments

@n0acar
Copy link

n0acar commented Nov 10, 2019

The shape of hr_image is 3,256,256 however hr_edge is 1,70,70. I couldn't find anything relatable with 70. I made the change with cuda as in issue #1 . What might be the problem here? Where does 70 come. I use edge enhancer and sr model together in mode 3 and super resolution scale is 8.

Traceback (most recent call last):
File "main.py", line 120, in
main()
File "main.py", line 50, in main
model.train()
File "/scratch/users/nacar14/edge-informed-sisr/src/edge_match.py", line 120, in train
hr_images_pred, gen_loss, dis_loss, logs = self.sr_model.process(lr_images, hr_images, lr_edges, hr_edges_pred)
File "/scratch/users/nacar14/edge-informed-sisr/src/models.py", line 214, in process
outputs = self(lr_images, hr_edges)
File "/kuacc/users/nacar14/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/scratch/users/nacar14/edge-informed-sisr/src/models.py", line 269, in forward
inputs = torch.cat((hr_images, hr_edges), dim=1)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 256 and 70 in dimension 2 at /opt/conda/conda-bld/pytorch_1573049306803/work/aten/src/THC/g
eneric/THCTensorMath.cu:71

@pppyykknen
Copy link

This is caused by hard coded stride value in models.py line 262. Replace

hr_images = F.conv_transpose2d(lr_images, self.scale_kernel, padding=0, stride=2, groups=3)
with
hr_images = F.conv_transpose2d(lr_images, self.scale_kernel, padding=0, stride=self.config.SCALE, groups=3)

to fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants