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

no attribute PerceptualLoss #4

Closed
TouqeerAhmad opened this issue Jan 6, 2020 · 8 comments
Closed

no attribute PerceptualLoss #4

TouqeerAhmad opened this issue Jan 6, 2020 · 8 comments

Comments

@TouqeerAhmad
Copy link

Hi Manuel, I was trying to following your example to train dsgan but I am encountering the following error:

"module 'PerceptualSimilarity' has no attribute 'PerceptualLoss'"

when it tries to initialize the PerceptualLoss in loss.py. I have downloaded the PerceptualSimilarity and placed it in the directory 'real-world-sr/dsgan/'. I was able to successfully run the examples provided with the PerceptualSimilarity author. Can you please advise?

Thanks,
Touqeer

@TouqeerAhmad
Copy link
Author

Are you by any chance using an older version of LPIPS. The following excerpt from LPIPS introduction points there are two versions:

"If you use LPIPS in your publication, please specify which version you are using. The current version is 0.1. You can set version='0.0' for the initial release."

@TouqeerAhmad
Copy link
Author

Never mind about this issue. I was able to get rid of this by importing models and replacing ps with models when initializing the loss network. Specifically, following two lines should address this if anyone else gets the same error:

'from PerceptualSimilarity import models'
'self.loss_network = models.PerceptualLoss(use_gpu=torch.cuda.is_available())'

@hcleung3325
Copy link

Never mind about this issue. I was able to get rid of this by importing models and replacing ps with models when initializing the loss network. Specifically, following two lines should address this if anyone else gets the same error:

'from PerceptualSimilarity import models'
'self.loss_network = models.PerceptualLoss(use_gpu=torch.cuda.is_available())'

Hi Ahmad,
Thanks for your suggestion.
I download the original version, it can import now.
However, there is another problem.

Saving summary into directory runs/save_model/0/
[1/300]: 0%| | 0/50 [00:15<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 186, in
g_loss.backward()
File "/home/root/miniconda/envs/py37/lib/python3.7/site-packages/torch/tensor.py", line 185, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/root/miniconda/envs/py37/lib/python3.7/site-packages/torch/autograd/init.py", line 127, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 256, 1, 1]] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

Have u experienced this before?

@jfun9494
Copy link

@hcleung3325 I remember solving this by using torch==1.1.0

@wxslby
Copy link

wxslby commented May 22, 2022

self.loss_network

Never mind about this issue. I was able to get rid of this by importing models and replacing ps with models when initializing the loss network. Specifically, following two lines should address this if anyone else gets the same error:

'from PerceptualSimilarity import models' 'self.loss_network = models.PerceptualLoss(use_gpu=torch.cuda.is_available())'

Never mind about this issue. I was able to get rid of this by importing models and replacing ps with models when initializing the loss network. Specifically, following two lines should address this if anyone else gets the same error:

'from PerceptualSimilarity import models' 'self.loss_network = models.PerceptualLoss(use_gpu=torch.cuda.is_available())'

Sorry, I can't find "from PerceptualSimilarity import models".Where is the "models"? Can you share the code ?

@mrgreen3325
Copy link

PerceptualSimilarity

You can download the PerceptualSimilarity package.
Or I email you the package, what is your email?

@wxslby
Copy link

wxslby commented May 24, 2022

Thanks for your reply. My email is 896385980@qq.com. Please!

@cgysjy
Copy link

cgysjy commented Mar 30, 2023

The downloaded perceptualsimilarity works, but still reports an error:
AttributeError: module 'PerceptualSimilarity' has no attribute 'PerceptualLoss'.
The current lpips minimum version 1.0 cannot be reduced to 0.0.
I did not find models for the above solution.
Is there any other solution? Thank you!

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

6 participants