PerceptualSimilarity
PerceptualSimilarity copied to clipboard
AttributeError: module 'lpips' has no attribute 'LPIPS'
I have done a pip install lpips as instructed in the repo's README and copied an pasted the example code given:
import lpips
loss_fn_alex = lpips.LPIPS(net='alex') # best forward scores
loss_fn_vgg = lpips.LPIPS(net='vgg') # closer to "traditional" perceptual loss, when used for optimization
import torch
img0 = torch.zeros(1,3,64,64) # image should be RGB, IMPORTANT: normalized to [-1,1]
img1 = torch.zeros(1,3,64,64)
d = loss_fn_alex(img0, img1)
but I keep getting the following error:
Traceback (most recent call last):
File "home/xyz.py", line 2, in <module>
loss_fn_alex = lpips.LPIPS(net='alex') # best forward scores
AttributeError: module 'lpips' has no attribute 'LPIPS'
I know that it is installed, because I can right click on LPIPS in my IDE and it takes me to the source code, so I am confused as to why I am getting that attribute error.
I can see someone else had the same issue before me, but the issue is closed without any explanation as to how it may have been solved.
I have same problem.
I don't know if you have the same cause, but my problem is solved.
I had named the file lpips.py to test lpips, so import lpips imported lpips.py itself, causing a circular reference.
After changing the file name to lpips_test.py, it worked.
I don't know if you have the same cause, but my problem is solved. I had named the file
lpips.pyto test lpips, soimport lpipsimportedlpips.pyitself, causing a circular reference. After changing the file name tolpips_test.py, it worked.
Genius! :) I had a same problem and this helped. Thank you. @outfielder May be you can check the current folder whether a 'lpips.py' file exists here?
Check & Rename the existing lpips.py files.
I don't know if you have the same cause, but my problem is solved. I had named the file
lpips.pyto test lpips, soimport lpipsimportedlpips.pyitself, causing a circular reference. After changing the file name tolpips_test.py, it worked.
That's why,Thank you
这是来自QQ邮箱的假期自动回复邮件。您好!您的来信我已收到,我将认真阅读邮件并及时予以您答复!谢谢!