XPixelGroup / BasicSR

Open Source Image and Video Restoration Toolbox for Super-resolution, Denoise, Deblurring, etc. Currently, it includes EDSR, RCAN, SRResNet, SRGAN, ESRGAN, EDVR, BasicVSR, SwinIR, ECBSR, etc. Also support StyleGAN2, DFDNet.
https://basicsr.readthedocs.io/en/latest/
Apache License 2.0
6.64k stars 1.17k forks source link

ESRGAN Error when start training #84

Open vienduong88 opened 5 years ago

vienduong88 commented 5 years ago

I have this error when I try to train the model

D:\Temp\BasicSR\codes>python train.py -opt options/train/train_esrgan.json

Traceback (most recent call last):

File "train.py", line 173, in

main()

File "train.py", line 23, in main

opt = option.parse(parser.parse_args().opt, is_train=True)

File "D:\Temp\BasicSR\codes\options\options.py", line 15, in parse

opt = json.loads(json_str, object_pairs_hook=OrderedDict)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\json__init__.py", line 367, in loads

return cls(**kw).decode(s)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 339, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 355, in raw_decode

obj, end = self.scan_once(s, idx)

json.decoder.JSONDecodeError: Invalid control character at: line 22 column 27 (char 220)

Do you know what's the problem? Thank you.

xinntao commented 5 years ago

It seems the error from the json file: Invalid control character at: line 22 column 27 (char 220)

Check whether there are some unnecessary characters in the json file.

vienduong88 commented 5 years ago

It seems the error from the json file: Invalid control character at: line 22 column 27 (char 220)

Check whether there are some unnecessary characters in the json file.

It's the original file from python lib so I guess there's no mistake, I try uninstall 3.6 then install 3.7 and still get the same error.

xinntao commented 5 years ago

I mean the xxx.json file you create.

vienduong88 commented 5 years ago

{ "name": "mw_ground" , "use_tb_logger": false , "model":"srragan" , "scale": 4 , "gpu_ids": [0]

, "datasets": { "train": { "name": "DIV2K" , "mode": "LRHR" , "dataroot_HR": "D://Temp//BasicSR//datasets//HR" , "dataroot_LR": "D://Temp//BasicSR//datasets//LR" , "subset_file": null , "use_shuffle": true , "n_workers": 8 , "batch_size": 16 , "HR_size": 128 , "use_flip": true , "use_rot": true } , "val": { "name": "val_set1_part" , "mode": "LRHR" , "dataroot_HR": "D://Temp//BasicSR//datasets//VL_HR" , "dataroot_LR": "D://Temp//BasicSR//datasets//VL_LR" } }

, "path": { "root": "D://Temp//BasicSR" , "pretrain_model_G": "..//experiments//pretrained_models//RRDB_ESRGAN_x4.pth" }

, "network_G": { "which_model_G": "RRDB_net" // RRDB_net | sr_resnet , "norm_type": null , "mode": "CNA" , "nf": 64 , "nb": 23 , "in_nc": 3 , "out_nc": 3 , "gc": 32 , "group": 1 } , "network_D": { "which_model_D": "discriminator_vgg_128" , "norm_type": "batch" , "act_type": "leakyrelu" , "mode": "CNA" , "nf": 64 , "in_nc": 3 }

, "train": { "lr_G": 1e-4 , "weight_decay_G": 0 , "beta1_G": 0.9 , "lr_D": 1e-4 , "weight_decay_D": 0 , "beta1_D": 0.9 , "lr_scheme": "MultiStepLR" , "lr_steps": [50000, 100000, 200000, 300000] , "lr_gamma": 0.5

, "pixel_criterion": "l1"
, "pixel_weight": 1e-2
, "feature_criterion": "l1"
, "feature_weight": 1
, "gan_type": "vanilla"
, "gan_weight": 5e-3

//for wgan-gp
// , "D_update_ratio": 1
// , "D_init_iters": 0
// , "gp_weigth": 10

, "manual_seed": 0
, "niter": 5e3
, "val_freq": 5e3

}

, "logger": { "print_freq": 200 , "save_checkpoint_freq": 5e3 } }

So here is my train_esrgan.json file, I try to find the mistake but don't really find it. I would really appreciate if you can check it out. :)

xinntao commented 5 years ago

It looks OK... 1) not sure whether // is right in Windows 2) may try to use another editor? Maybe there are some invisible characters?

adaxidedakaonang commented 5 years ago

In Windows you should use \\ or / instead of // or \

shiqi1994 commented 5 years ago

You can look up the code named 'options.py', 'line = line.split('//')[0]+'\n' this part seems to remove '//' and every thing after that'//'. So you better change '//' to '/'. It works for me.