royorel / Lifespan_Age_Transformation_Synthesis

Lifespan Age Transformation Synthesis code
Other
582 stars 132 forks source link

why the video my model produces changes from old to young and then becomes old? #31

Open glorioustory opened 2 years ago

glorioustory commented 2 years ago

hi, @royorel I trained a model which cover all age stages,such as 0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120, and train about 160 epochs, then tested it like this: python test.py --name males_model --which_epoch latest --display_id 0 --sort_order 0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120 --traverse --interp_step 0.05 --make_video --in_the_wild --verbose --image_path_file my.png The video produced is that the face changes from old to young and then becomes old, not just from young to old. Why is this? look forward to your reply!

royorel commented 2 years ago

Hi @glorioustory

I have no way of answering that question without knowing exactly what you ran and how you ran it. Can you share the exact commands you ran for training and testing?

glorioustory commented 2 years ago

Hi @glorioustory

I have no way of answering that question without knowing exactly what you ran and how you ran it. Can you share the exact commands you ran for training and testing?

Hi @royorel ,thanks for you reply. I train the model like this: python train.py --gpu_ids 0,1,2,3 --dataroot ./datasets/males --name males_model --batchSize 2 --verbose

The options are basically unchanged,some options are as follows: self.parser.add_argument('--name', type=str,default='males_model',help='name of the experiment. It decides where to store samples and models') self.parser.add_argument('--gpu_ids', type=str, default='0,1,2', help='gpu ids: e.g. 0 0,1,2, 0,2. use -1 for CPU') self.parser.add_argument('--checkpoints_dir', type=str,default='checkpoints/0125', help='models are saved here') self.parser.add_argument('--batchSize', type=int, default=1, help='input batch size') self.parser.add_argument('--loadSize', type=int, default=256, help='scale images to this size') self.parser.add_argument('--fineSize', type=int, default=256, help='then crop to this size') self.parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels') self.parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels') self.parser.add_argument('--dataroot', type=str, default='datasets/males') self.parser.add_argument('--sort_classes', type=bool, default=True, help='a flag that indicates whether to sort the classes') self.parser.add_argument('--sort_order', type=str, default='0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120', help='a specific order to sort the classes, must contain all classes, only works when sort_classes is true')

The datasets folders are as follows: train0-2/ train10-14/ train15-19/ train20-29/ train3-6/ train30-39/ train40-49/ train50-69/ train7-9/ train70-120/

After about 160 epochs and test the model like this to produce the video: python test.py --name males_model --which_epoch latest --display_id 0 --sort_order 0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120 --traverse --interp_step 0.05 --make_video --in_the_wild --verbose --image_path_file my.png

royorel commented 2 years ago

@glorioustory,

The default sort order is designed for training and testing on 6 classes (like we did in the paper). See: https://github.com/royorel/Lifespan_Age_Transformation_Synthesis/blob/29de7bd8e35c33000654af236bdb15269877790c/options/base_options.py#L29

When you call the training function with a different setup for the dataset (e.g. you train on all classes) add the --sort_order flag to the call with the specific class sort order you want. In your case that would be --sort_order 0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120.

This flag should be added both in training and testing.

I hope that helps

glorioustory commented 2 years ago

@royorel, thank you again for your reply I set the sort_order option in training and testing, like this: self.parser.add_argument('--sort_order', type=str, default='0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120', help='a specific order to sort the classes, must contain all classes, only works when sort_classes is true') Maybe I haven't trained enough epochs, about 160, there is still a gap to your training epochs of 400. I will go on training using the options of continue_train and load_pretrain on the basis of 160 epochs.

royorel commented 2 years ago

@glorioustory

You will need to start training from scratch with: --sort_order 0-2,3-6,7-9,10-14,15-19,20-29,30-39,40-49,50-69,70-120

Otherwise the problem will not be resolved