elvisyjlin / AttGAN-PyTorch

AttGAN PyTorch Arbitrary Facial Attribute Editing: Only Change What You Want
MIT License
248 stars 61 forks source link

hello , i have several questions! 1.what does the parameter 'args.test_int' mean? in line 185 of train.py , when i = 0, we put the raw attributes ,we scale each attribute in [-0.5,0.5], when i>0, the corresonpding attribute is changed to [-1,1] , can you tell me why they have different scales. 2: The decoder of the generator takes a latent space tensor and a conditional attribute as its inputs, but how to combine them?(in fact i can't figure out how you combine them in train.py, in line 154 and 158 the item "2*args.thres_int " really confuses me) #24

Closed Wolfgang723 closed 3 years ago

elvisyjlin commented 3 years ago

Hi @Wolfgang723, if you read my README in the repo home page (https://github.com/elvisyjlin/AttGAN-PyTorch), you will see the teaser images that were generated by train.py and test.py. The left-most image (i=0) has the original attributes, and each following images (i > 0) changes 1 attribute (i-th attribute) at a time. The scripts are mainly from the original AttGAN repo (here).

The celeba dataset labels are 0s and 1s. However, AttGAN is designed to input 0.5 as positive attribute and -0.5 as negative attribute. The model is trained with attributes modified to 0.5 and -0.5. The usage of args.test_int is to enhance the changes we'd like to see when testing. Sometimes 0.5 and -0.5 cannot show a large enough visual changes in generated images. The changed attributes will be enhance with the ratio args.test_int / args.thre_int.

For example, we have a original attribute [1, 0, 1]. The left-most attribute is set as [1, 0, 1] and is changed to [0.5, -0.5, 0.5] in line 183.

The middle image (i=1) is firstly set as [1, 1, 1] at line 125 and changed to [0.5, 0.5, 0.5] in line 183. In line 185, the changed attribute is enhanced to 1.0, so the attributes becomes [0.5, 1, 0.5].

Hope this explanation helps you understand the complicated logic in train.py.

Wolfgang723 commented 3 years ago

Oh, i get it, Thank you very much for your detailed explanation!!!!