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

Resulting Images Size #5

Closed
sadbhawnathakur opened this issue Dec 28, 2019 · 1 comment
Closed

Resulting Images Size #5

sadbhawnathakur opened this issue Dec 28, 2019 · 1 comment

Comments

@sadbhawnathakur
Copy link

Is it possible to set the final inpainted image size same as the input images?

I tried the same and got this error:

Using cpu.
Model model/model_places2.pth loaded.

Inpainting...

Input size: (500, 333)
Traceback (most recent call last):
File "test.py", line 263, in
tester.inpaint(args.output, args.img, args.mask, merge_result=args.merge)
File "test.py", line 221, in inpaint
self.process_batch(batch, output)
File "test.py", line 172, in process_batch
result, alpha, raw = self.model(imgs_miss, masks)
File "/home/sadbhawna/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/sadbhawna/torch/DFNet/model.py", line 260, in forward
out = decode(out, out_en[-i-2])
File "/home/sadbhawna/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/sadbhawna/torch/DFNet/model.py", line 147, in forward
out = torch.cat([out, concat], dim=1)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 2 and 3 in dimension 3 at /opt/conda/conda-bld/pytorch_1574150980135/work/aten/src/TH/generic/THTensor.cpp:612

@hughplay
Copy link
Owner

hughplay commented Jan 7, 2020

Actually U-Net like networks do have this limitation. The height and width must be divided by 2^n (n depends on the times of downsample). Because images will be downsampled and then upsampled.

You could hack it by:

  1. resize the input image to make the height and width satisfied the condition mentioned above
  2. resize the output image back to the original size

Hope this will help you.

@hughplay hughplay closed this as completed Jan 7, 2020
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