chaofengc / PSFRGAN

PyTorch codes for "Progressive Semantic-Aware Style Transformation for Blind Face Restoration", CVPR2021
Other
370 stars 68 forks source link

Getting some path errors for Windows 10 for training.Need Help. #28

Closed FlowDownTheRiver closed 3 years ago

FlowDownTheRiver commented 3 years ago

I used this code : python train.py --gpus 1 --model enhance --name PSFRGAN_v001 --g_lr 0.0001 --d_lr 0.0004 --beta1 0.5 --lambda_pix 10 --lambda_fm 10 --lambda_ss 1000 --Dinput_nc 22 --D_num 3 --n_layers_D 4 --batch_size 2 --dataset ffhq --dataroot C:\PSFRGAN\datasets\FFHQ --visual_freq 100 --print_freq 10

Note that I removed the --gan argument from commandline cos it was saying that gan model is not implemented,I tried the other gan options but it was again saying it is not implemented so instead I went into the train_options.py and set the gan from there. Like so: parser.add_argument('--gan_mode', type=str, default='wgangp', help='the type of GAN objective. [vanilla| lsgan | wgangp]. vanilla GAN loss is the cross-entropy objective used in the original GAN paper.')

Anyway here is where I got stuck :

C:\PSFRGAN>call C:\Users\Break\anaconda3\Scripts\activate.bat

(base) C:\PSFRGAN>call conda activate PSFRGAN

(PSFRGAN) C:\PSFRGAN>python train.py --gpus 1 --model enhance --name PSFRGAN_v001 --g_lr 0.0001 --d_lr 0.0004 --beta1 0.5 --lambda_pix 10 --lambda_fm 10 --lambda_ss 1000 --Dinput_nc 22 --D_num 3 --n_layers_D 4 --batch_size 2 --dataset ffhq --dataroot C:\PSFRGAN\datasets\FFHQ --visual_freq 100 --print_freq 10 ----------------- Options --------------- D_num: 3 Dinput_nc: 22 [default: 3] Dnorm: in Gin_size: 512 [default: 512] Gnorm: spade Gout_size: 512 [default: 512] Pimg_size: 512 [default: 512] Pnorm: bn batch_size: 2 [default: 16] beta1: 0.5 checkpoints_dir: ./check_points continue_train: False crop_size: 256 d_lr: 0.0004 data_device: cuda:0 [default: None] dataroot: C:\PSFRGAN\datasets\FFHQ [default: None] dataset_name: ffhq [default: single] debug: False device: cuda:0 [default: None] epoch: latest epoch_count: 1 g_lr: 0.0001 gan_mode: wgangp gpu_ids: [0] [default: None] gpus: 1 init_gain: 0.02 init_type: normal input_nc: 3 isTrain: True [default: None] lambda_fm: 10.0 lambda_g: 1.0 lambda_pcp: 0.0 lambda_pix: 10.0 lambda_ss: 1000.0 load_iter: 0 [default: 0] load_size: 512 lr: 0.0002 lr_decay_gamma: 1 lr_decay_iters: 50 lr_policy: step max_dataset_size: inf model: enhance n_epochs: 100 n_epochs_decay: 100 n_layers_D: 4 name: PSFRGAN_v001 [default: experiment_name] ndf: 64 ngf: 64 niter_decay: 100 no_flip: False no_strict_load: False num_threads: 8 output_nc: 3 parse_net_weight: ./pretrain_models/parse_multi_iter_90000.pth phase: train preprocess: none print_freq: 10 [default: 100] resume_epoch: 0 resume_iter: 0 save_by_iter: False save_epoch_freq: 5 save_iter_freq: 5000 save_latest_freq: 500 seed: 123 serial_batches: False suffix: total_epochs: 50 verbose: False visual_freq: 100 [default: 400] ----------------- End ------------------- dataset [FFHQDataset] was created The number of training images = 1000 initialize network with normal model [EnhanceModel] was created ---------- Networks initialized ------------- [Network G] Total number of parameters : 45.957 M [Network D] Total number of parameters : 18.872 M

Traceback (most recent call last): File "train.py", line 78, in train(opt) File "train.py", line 22, in train logger = Logger(opt) File "C:\PSFRGAN\utils\logger.py", line 30, in init self.mk_log_file() File "C:\PSFRGAN\utils\logger.py", line 35, in mk_log_file mkdirs(self.log_dir) File "C:\PSFRGAN\utils\utils.py", line 133, in mkdirs os.makedirs(paths) File "C:\Users\Break\anaconda3\envs\PSFRGAN\lib\os.py", line 220, in makedirs mkdir(name, mode) NotADirectoryError: [WinError 267] Dizin adı geçersiz: './check_points\log_dir\PSFRGAN_v001_2021-04-23_06:18'


As you can see it is putting extra \ to the path and some extra errors.Can you please help about this one?

Months ago I have reported a similar path issue and you updated the older version of PSRFGAN to run on windows for unaligned images.I guess this is similar.Hoping for some fix for windows users.

Also I have 3 extra questions 1) if we decide to continue training the base model trained by you,which options shall be set in commandline not to break the model? 2) Which gan options is used for the default model and which gan would you recommend to be used for the best results? 3)Can we have any extra info for the base pretrained model?How many pictures it has been trained on from ffhq set etc?The reason I ask cos the model is generating some extra wrinkles around the eyes which should not be there,I really want to train more on the model.

chaofengc commented 3 years ago

Thanks for interest. Here are answers for your questions:

  1. You can specify the --checkpoints_dir to your own path in windows format
  2. If you want to continue train with specific model, you may add some codes after this line to load the model https://github.com/chaofengc/PSFRGAN/blob/c882315c9f1fc91c43d13a709016dd411f73d713/train.py#L20
  3. I did not test all the GAN losses, and therefore cannot give you a definite answer. According to my experience, they perform similarly. The released model is trained from scratch using the public codes with all images from FFHQ. No other tricks and extra training photos. Follow the instructions in README should give you the same results.

Note: this project is supposed to be used for research purpose, and our method is not able to handle all kinds of LQ images in real world. You may need capabilities to modify the codes for better performance on your own test dataset.

FlowDownTheRiver commented 3 years ago

python train.py --gpus 1 --model enhance --name PSFRGAN_v001 --g_lr 0.0001 --d_lr 0.0004 --beta1 0.5 --lambda_pix 10 --lambda_fm 10 --lambda_ss 1000 --Dinput_nc 22 --D_num 3 --n_layers_D 4 --batch_size 2 --dataset ffhq --dataroot C:\PSFRGAN\datasets\FFHQ --visual_freq 100 --print_freq 10 --checkpoints_dir C:/PSFRGAN/check_points/

I got :

Traceback (most recent call last): File "train.py", line 79, in train(opt) File "train.py", line 23, in train logger = Logger(opt) File "C:\PSFRGAN\utils\logger.py", line 30, in init self.mk_log_file() File "C:\PSFRGAN\utils\logger.py", line 35, in mk_log_file mkdirs(self.log_dir) File "C:\PSFRGAN\utils\utils.py", line 133, in mkdirs os.makedirs(paths) File "C:\Users\Break\anaconda3\envs\PSFRGAN\lib\os.py", line 223, in makedirs mkdir(name, mode) NotADirectoryError: [WinError 267] Dizin adı geçersiz: 'C:/PSFRGAN/check_points/log_dir\PSFRGAN_v001_2021-04-23_15:23'


and if I use:

python train.py --gpus 1 --model enhance --name PSFRGAN_v001 --g_lr 0.0001 --d_lr 0.0004 --beta1 0.5 --lambda_pix 10 --lambda_fm 10 --lambda_ss 1000 --Dinput_nc 22 --D_num 3 --n_layers_D 4 --batch_size 1 --dataset ffhq --dataroot C:\PSFRGAN\datasets\FFHQ --visual_freq 100 --print_freq 10 --checkpoints_dir C:\PSFRGAN\check_points\

I got:

Traceback (most recent call last): File "train.py", line 79, in train(opt) File "train.py", line 23, in train logger = Logger(opt) File "C:\PSFRGAN\utils\logger.py", line 30, in init self.mk_log_file() File "C:\PSFRGAN\utils\logger.py", line 35, in mk_log_file mkdirs(self.log_dir) File "C:\PSFRGAN\utils\utils.py", line 133, in mkdirs os.makedirs(paths) File "C:\Users\Break\anaconda3\envs\PSFRGAN\lib\os.py", line 223, in makedirs mkdir(name, mode) NotADirectoryError: [WinError 267] Dizin adı geçersiz: C:"\"PSFRGAN"\"check_points"\"log_dir"\"PSFRGAN_v001_2021-04-23_15:33 Note : I have edited the path "\" to show you because github doesn't show how it is shown on the screen.

the last part of the path is generating double "\" like in C:/PSFRGAN/check_points/log_dir\PSFRGAN_v001_2021-04-23_15:2 so it doesn't proceed futher.

I am sorry to bother you with such an error,but I was unable to fix it.

adding some screenshots:

2021-04-23 15_46_50-Window 2021-04-23 15_47_39-Window