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

Pretrained model and how to use it #33

Open
simonemelcarne opened this issue May 8, 2023 · 3 comments
Open

Pretrained model and how to use it #33

simonemelcarne opened this issue May 8, 2023 · 3 comments

Comments

@simonemelcarne
Copy link

Hi, I am new to this field and I am using your public git code in order to understand how GANs work.
When I download and import the pretrained model, I see that there is a file called weights.49.pth.
Now I was wondering: when I train my model (which is supposed to be trained for 200 epochs) I have to exploit the pretrained model by starting the training process using the informations stored in the file weights.49.pth? This means that I can resume the training starting from epoch 50? In order to do all of that I had to change a bit your code but I am not sure if what I am saying is theoretically correct and works in practice.
Sorry for the question but I'm a beginner! Thank you.

@elvisyjlin
Copy link
Owner

Hello @simonemelcarne ,
Technically, we can resume the training process from the exported model weights. However, I only dumped the weights of the generator in order to save disk space.

attgan.saveG(os.path.join(

You won't be able to resume training from the pre-trained weights I provided because it lacks the weights of the discriminator.

In addition, to resume training from your own model. You should refine the code above to dump the generator and the discriminator.

@simonemelcarne
Copy link
Author

Thank you so much for answering!
I just want to ask you two other thing: when we use test_multi.py is the order important when we modify the attributes? I mean the operation is order invariant when for example I want to do modify " pale_skin" and "young" attributes?
And regarding test_slide.py how is it handled the magnitude, which mathematical operation is done to obtain different level of changes?
Thank you again.

@elvisyjlin
Copy link
Owner

The order does not matter. The target attributes are specified in a file named list_attr_custom.txt which is passed to the command in the argument --custom_attr.

parser.add_argument('--custom_attr', type=str, default='./data/list_attr_custom.txt')

Please find the example file in https://github.com/elvisyjlin/AttGAN-PyTorch/blob/master/data/list_attr_custom.txt

You can follow the attribute order in the example, or specify your own order in line 2. Then it's followed by the target attributes. Here is an example that transfer a face to pale skin and young.

1
Bald Bangs Black_Hair Blond_Hair Brown_Hair Bushy_Eyebrows Eyeglasses Male Mouth_Slightly_Open Mustache No_Beard Pale_Skin Young
donald_trump.jpg -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1

Note that the magnitude ranges from -1 to 1. -1 means 0% and 1 means 100%.

However, the face will also be transfer to male, no glasses, no bald, etc. because you must specify all attribute when doing the image-to-image translation. To prevent the original attribute like the gender, you need you know its original value and set it in the target attributes correctly.

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

2 participants