DeepImageBlending
DeepImageBlending copied to clipboard
Help,Why do I report errors when I run 'python run.py' directly???
I didn't make any changes,but it made a mistake.
Traceback (most recent call last):
File "run.py", line 219, in
Got the same error. Has anyone resolved it?
Download the optimizer source code of LBFGS as a separate python file in your local code from pytorch github instead of importing it as "nn.optim.LBFGS ". Also, import the libraries for this file as
import torch
from functools import reduce
from torch.optim import Optimizer
- In new class file, change the line view = p.grad.view(-1) to view = p.grad.contiguous().view(-1) .
- Also make sure to instantiate the optimizer class of your local code rather than nn.optim in run.py.
Re-run your code and it should work.
@saandeepa93 Your solution works perfectly!
I have trouble while understanding the argument --x
& --y
in the run.py
file. I believe they help me decide the starting point from which the mask needs to be placed (assuming origin is top left corner).
I am observing these coordinates to go below 0 or more than the image shape? why is that so?
Also please provide some ideas to improve the output, I have observed the second stage output to be worse than first stage?
Just change line 63 in run.py
from:
input_img = torch.randn(target_img.shape).to(gpu_id)
to:
input_img = torch.randn(target_img.shape).contiguous().to(gpu_id)
this solution works for me :)
You can just directly change lbfgs.py installed in your site-packages folder. In my case, I've changed one line of lbfgs.py in '..Python\Python37\Lib\site-packages\torch\optim'.
from:
view = p.grad.view(-1)
to:
view = p.grad.contiguous().view(-1)