Ben-Louis / Deep-Image-Analogy-PyTorch

A python implementation of Deep-Image-Analogy based on pytorch.
MIT License
182 stars 42 forks source link

Vgg19.py giving me this error #4

Closed neelkadia-zz closed 2 years ago

neelkadia-zz commented 6 years ago
/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/VGG19.py:137: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  return loss.data[0], grad
Traceback (most recent call last):
  File "main.py", line 49, in <module>
    img_AP, img_B = analogy(img_A, img_BP, config)
  File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/DeepAnalogy.py", line 85, in analogy
    iters=400, display=False)
  File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/VGG19.py", line 142, in get_deconvoluted_feat
    noise, stat = lbfgs(f, noise, maxIter=iters, gEps=1e-4, histSize=4, lr=lr, display=display)
  File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 60, in lbfgs
    step, stat_ls, args = linesearch(xk.clone(), z, f, fk, gk.clone(), fkm1,gkm1.clone(), 10000, lr)
  File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 131, in linesearch
    strong_wolfe = (np.abs(phi_prime_alpha) <= -c2 * phi_prime_0)
RuntimeError: Expected object of type torch.DoubleTensor but found type torch.cuda.DoubleTensor for argument #2 'other'
Ben-Louis commented 6 years ago

Hi Kadia, I think this issue occurs because of pytorch version inconsistency. I am not familiar with features of pytorch 0.5, which you use in your environment, and I will update the codes to make it work under pytorch 0.4 in this week. You can try it then :D Thank you for your notification!

neelkadia-zz commented 6 years ago

@Ben-Louis Thanks for the prompt response. I'll also try to make it compatible and raise a PR if it works.

But, I want to try it now. Which pytorch version I need to run it as of now?

Ben-Louis commented 6 years ago

The codes have been tested under pytorch 0.3. I see your PR, and does that modification make it work with pytorch 0.5? I found the bug you mentioned in #6 still exists when using pytorch 0.4 I upgrade the code and enable it compatible with pytorch 0.4, you can try it close #6

lsyoujian commented 5 years ago

您在上海吗?能不能加下我qq1012585013

Ben-Louis commented 5 years ago

您在上海吗?能不能加下我qq1012585013

可以邮件联系吗?penglu2097@gmail.com