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

is it possible to fine tune? #80

Open
juanluisrosaramos opened this issue Apr 12, 2022 · 2 comments
Open

is it possible to fine tune? #80

juanluisrosaramos opened this issue Apr 12, 2022 · 2 comments

Comments

@juanluisrosaramos
Copy link

Is it possible to fine tune your e4e_ffhq_encode.pt model and change it to another different domain? I have a dataset of babies with a stylegan2 trained. Can I resume a train from your provided weights?
i can start a training from scratch but if I add the option to resume from checkpoint it returns the error

Loading decoder weights from pretrained!
Traceback (most recent call last):
File "scripts/train.py", line 87, in
main()
File "scripts/train.py", line 27, in main
coach = Coach(opts, previous_train_ckpt)
File "./training/coach.py", line 38, in init
self.net = pSp(self.opts).to(self.device)
File "./models/psp.py", line 28, in init
self.load_weights()
File "./models/psp.py", line 53, in load_weights
ckpt = torch.load(self.opts.stylegan_weights)
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 594, in load
with _open_file_like(f, 'rb') as opened_file:
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: ''

My training config is

python scripts/train.py
--dataset_type babies_encode
--exp_dir new/experiment2/directory
--start_from_latent_avg
--use_w_pool
--w_discriminator_lambda 0.1
--progressive_start 20000
--id_lambda 0.1
--val_interval 10000
--max_steps 200000
--stylegan_size 512
--stylegan_weights ../stylegan2-ada-pytorch_2/network-snapshot-000320.pt
--workers 8
--batch_size 8
--test_batch_size 2
--test_workers 2
--save_interval 2000
--resume_training_from_ckpt pretrained_models/e4e_ffhq_encode.pt

@LLLPS666
Copy link

hello, have you solved this promble?
I can ues it to fine tune. But the model would be worse after training.
My training config is

python scripts/train.py
--dataset_type my_data_encode
--exp_dir my_model/mye4e
--use_w_pool
--w_discriminator_lambda 0.1
--progressive_start 20000
--id_lambda 0.5
--val_interval 10000
--max_steps 200
--stylegan_size 512
--stylegan_weights pretrained_models/stylegan2-ffhq-config-f.pt
--workers 8
--batch_size 16
--test_batch_size 4
--test_workers 4
--checkpoint_path pretrained_models/e4e_ffhq_encode.pt

@omertov
Copy link
Owner

omertov commented May 19, 2022

Hi @juanluisrosaramos,
Sorry for the long response time,

In case it is still relevant, it seems like the file_path you provide for the stylegan_weights leads to a non-existing file, perhaps providing the absolute path to the weights file would help.
Also, just making sure that the StyleGAN checkpoint is compatible with rosinality's stylegan2-pytorch implementation, and not the nvidia's pytorch implementation. Last, I believe that the resume_training_from_ckpt would not yield the desired effect (there is no training information stored in the checkpoints I provided if thats what stored in pretrained_models/e4e_ffhq_encode.pt), you could use the --checkpoint_path flag to initialize the encoder from the pretrained weights.

As for @LLLPS666 's question - Is the error caused by the wrong stylegan_size specified? (512 instead of 1024)?

Best,
Omer

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

3 participants