neuralchen / SimSwap

An arbitrary face-swapping framework on images and videos with one single trained model!
Other
4.55k stars 895 forks source link

AttributeError: 'SGD' object has no attribute 'defaults' #357

Closed amfapic closed 1 year ago

amfapic commented 1 year ago

Hi, when I try to run simswap in colab, I get this error. Can anybody please guide me on how to fix the error? AttributeError Traceback (most recent call last) in 14 15 torch.nn.Module.dump_patches = True ---> 16 model = create_model(opt) 17 model.eval() 18

5 frames /usr/local/lib/python3.8/dist-packages/torch/optim/optimizer.py in setstate(self, state) 82 self.dict.update(state) 83 self._hook_for_profile() # To support multiprocessing pickle/unpickle. ---> 84 self.defaults.setdefault('differentiable', False) 85 86 def repr(self):

AttributeError: 'SGD' object has no attribute 'defaults'

chenchong23 commented 1 year ago

I also met the same problem, did you solve it?

amfapic commented 1 year ago

I also met the same problem, did you solve it?

hi. yes. You should try previous pytorch versions (< 1.13): pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

amfapic commented 1 year ago

hi. yes You should try previous pytorch versions (< 1.13): pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

On Sun, Dec 11, 2022 at 8:28 PM chenchong23 @.***> wrote:

I also met the same problem, did you solve it?

— Reply to this email directly, view it on GitHub https://github.com/neuralchen/SimSwap/issues/357#issuecomment-1345604289, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4SORJCQHSIOXFID35YI7N3WMYB2NANCNFSM6AAAAAAS2F2VWI . You are receiving this because you authored the thread.Message ID: @.***>

TransAmMan commented 1 year ago

Was also having this issue. This fix works. Thank you amfatic

tubi1 commented 1 year ago

hi. yes You should try previous pytorch versions (< 1.13): pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html On Sun, Dec 11, 2022 at 8:28 PM chenchong23 @.> wrote: I also met the same problem, did you solve it? — Reply to this email directly, view it on GitHub <#357 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4SORJCQHSIOXFID35YI7N3WMYB2NANCNFSM6AAAAAAS2F2VWI . You are receiving this because you authored the thread.Message ID: @.>

Hi, i did this but it doesnt seem to work anymore. Any other solution? Thanks in advanced! :)

rishab-sharma commented 1 year ago

@tubi1 This works,

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

Try restarting your colab after installation

amingomezd commented 1 year ago

@tubi1 This works,

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

Try restarting your colab after installation

Add the pip install and restart the runtime won't work.

orlandomendozagarrido commented 1 year ago

I found that using !pip install torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html works. The previous answers had install torch==1.8.1+cu111 but it was incompatible with torchtext 0.14.0 so I did not need to install,( so by using current torch==1.13.1 it worked fine.) image

qhuy1901 commented 1 year ago

I found that using !pip install torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html works. The previous answers had install torch==1.8.1+cu111 but it was incompatible with torchtext 0.14.0 so I did not need to install,( so by using current torch==1.13.1 it worked fine.) image

Sorry, but it not working :(

souvikg544 commented 1 year ago

All these solutions won't work as of February , 2023. The below installations work -

!pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 torchtext==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html

Hope this helps ... Do not forget to restart your runtime after the installation .. And as always happy coding !

neuralchen commented 1 year ago

We fixed the "AttributeError: 'SGD' object has no attribute 'defaults' now" bug. If you have already downloaded arcface_checkpoint.tar, please download it again. Also, you also need to update the scripts in ./models/.