chaofengc/Face-SPARNet

Getting Some Errrors

FlowDownTheRiver opened this issue · 8 comments

Hi there.Using the same environment as Psfrgan for Face-Sparnet.
I am on Windows 10 64 bit.
I used this command line to test for a single image : python test_enhance_single_unalign.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --Gnorm 'in' --pretrain_model_path ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth --test_img_path ./test_images/test_hzgg.jpg --results_dir test_hzgg_results

and I am getting this in anaconda prompt line : (psfrgan) C:\Face-SPARNet>python test_enhance_single_unalign.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --Gnorm 'in' --pretrain_model_path ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth --test_img_path ./test_images/test_hzgg.jpg --results_dir test_hzgg_results
----------------- Options ---------------
Dnorm: none
Gnorm: 'in' [default: bn]
att_name: spar
batch_size: 32
bottleneck_size: 4
checkpoints_dir: ./check_points
data_device: cuda:0 [default: None]
dataroot: None
dataset_name: celeba
debug: False
device: cuda:0 [default: None]
epoch: latest
eval: False
gpu_ids: [0] [default: None]
gpus: 1
init_gain: 0.02
init_type: normal
input_nc: 3
isTrain: False [default: None]
load_iter: 0 [default: 0]
load_size: None
max_dataset_size: inf
model: sparnethd [default: test]
n_layers_D: 4
name: SPARNetHD_V4_Attn2D [default: experiment_name]
ndf: 64
ngf: 64
ntest: inf
num_D: 3
num_test: 50
num_threads: 8
output_nc: 3
phase: test
preprocess: none
pretrain_model_path: ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth [default: ]
res_depth: 10
results_dir: test_hzgg_results [default: ./results/]
save_as_dir:
seed: 123
serial_batches: False
suffix:
test_img_path: ./test_images/test_hzgg.jpg [default: ]
test_upscale: 1
verbose: False
----------------- End -------------------
======> Loading images, crop and align faces.
======> Saving aligned LQ faces to test_hzgg_results\LQ_faces
Traceback (most recent call last):
File "test_enhance_single_unalign.py", line 105, in
enhance_model = def_models(opt)
File "test_enhance_single_unalign.py", line 50, in def_models
model = create_model(opt)
File "C:\Face-SPARNet\models_init_.py", line 65, in create_model
instance = model(opt)
File "C:\Face-SPARNet\models\sparnethd_model.py", line 26, in init
res_depth=opt.res_depth, norm_type=opt.Gnorm, att_name=opt.att_name, bottleneck_size=opt.bottleneck_size)
File "C:\Face-SPARNet\models\sparnet.py", line 44, in init
self.encoder.append(ResidualBlock(cin, cout, scale='down', hg_depth=hg_depth, att_name=att_name, **nrargs))
File "C:\Face-SPARNet\models\blocks.py", line 119, in init
NormLayer(c_in, norm_type=self.norm_type),
File "C:\Face-SPARNet\models\blocks.py", line 30, in init
assert 1==0, 'Norm type {} not support.'.format(norm_type)
AssertionError: Norm type 'in' not support.

I am not sure what is wrong. I used git clone Face-Sparnet but I also tried the same thing in PSFRGAN folder as well.All pre-trained models are in place as your description.

The command looks fine. Possibly because the shell in windows parse the command in a different way. You may try to set the default Gnorm to 'in' in base_options.py and try again.

I have set it from bg to in. Tried it. Still getting errors. I also tried deleting the --Gnorm from command line or the arguments related to it.Some lines are still complaining.

command line after changing Gnorm to in : python test_enhance_single_unalign.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --Gnorm 'in' --pretrain_model_path .\check_points\SPARNetHD_V4_Attn2D\latest_net_H.pth --test_img_path .\test_images\test_hzgg.jpg --results_dir test_hzgg_results

This is what I get as error : ----------------- End -------------------
======> Loading images, crop and align faces.
======> Saving aligned LQ faces to test_hzgg_results\LQ_faces
Traceback (most recent call last):
File "test_enhance_single_unalign.py", line 105, in
enhance_model = def_models(opt)
File "test_enhance_single_unalign.py", line 50, in def_models
model = create_model(opt)
File "C:\Face-SPARNet\models_init_.py", line 65, in create_model
instance = model(opt)
File "C:\Face-SPARNet\models\sparnethd_model.py", line 26, in init
res_depth=opt.res_depth, norm_type=opt.Gnorm, att_name=opt.att_name, bottleneck_size=opt.bottleneck_size)
File "C:\Face-SPARNet\models\sparnet.py", line 44, in init
self.encoder.append(ResidualBlock(cin, cout, scale='down', hg_depth=hg_depth, att_name=att_name, **nrargs))
File "C:\Face-SPARNet\models\blocks.py", line 119, in init
NormLayer(c_in, norm_type=self.norm_type),
File "C:\Face-SPARNet\models\blocks.py", line 30, in init
assert 1==0, 'Norm type {} not support.'.format(norm_type)
AssertionError: Norm type 'in' not support.

I also get this :
(psfrgan) C:\Face-SPARNet>python test.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --Gnorm 'in' --load_size 512 --dataset_name single --dataroot test_dirs/CelebA-TestN/ --pretrain_model_path ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth --save_as_dir results_CelebA-TestN/SPARNetHD_V4_Attn2D/
----------------- Options ---------------
Dnorm: none
Gnorm: 'in' [default: in]
att_name: spar
batch_size: 32
bottleneck_size: 4
checkpoints_dir: ./check_points
data_device: cuda:0 [default: None]
dataroot: test_dirs/CelebA-TestN/ [default: None]
dataset_name: single [default: celeba]
debug: False
device: cuda:0 [default: None]
epoch: latest
eval: False
gpu_ids: [0] [default: None]
gpus: 1
init_gain: 0.02
init_type: normal
input_nc: 3
isTrain: False [default: None]
load_iter: 0 [default: 0]
load_size: 512 [default: None]
max_dataset_size: inf
model: sparnethd [default: test]
n_layers_D: 4
name: SPARNetHD_V4_Attn2D [default: experiment_name]
ndf: 64
ngf: 64
ntest: inf
num_D: 3
num_test: 50
num_threads: 8
output_nc: 3
phase: test
preprocess: none
pretrain_model_path: ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth [default: ]
res_depth: 10
results_dir: ./results/
save_as_dir: results_CelebA-TestN/SPARNetHD_V4_Attn2D/ [default: ]
seed: 123
serial_batches: False
suffix:
test_img_path:
test_upscale: 1
verbose: False
----------------- End -------------------
dataset [SingleDataset] was created
Traceback (most recent call last):
File "test.py", line 18, in
model = create_model(opt) # create a model given opt.model and other options
File "C:\Face-SPARNet\models_init_.py", line 65, in create_model
instance = model(opt)
File "C:\Face-SPARNet\models\sparnethd_model.py", line 26, in init
res_depth=opt.res_depth, norm_type=opt.Gnorm, att_name=opt.att_name, bottleneck_size=opt.bottleneck_size)
File "C:\Face-SPARNet\models\sparnet.py", line 44, in init
self.encoder.append(ResidualBlock(cin, cout, scale='down', hg_depth=hg_depth, att_name=att_name, **nrargs))
File "C:\Face-SPARNet\models\blocks.py", line 119, in init
NormLayer(c_in, norm_type=self.norm_type),
File "C:\Face-SPARNet\models\blocks.py", line 30, in init
assert 1==0, 'Norm type {} not support.'.format(norm_type)
AssertionError: Norm type 'in' not support.

If you set default Gnorm to in, you should remove the --Gnorm in the command.

From the error message "Norm type 'in' not support.", I guess the single quotes might be the problem. You may try to remove the quote. If this does not solve the problem, you may try to print the norm_type to debug the NormLayer class in blocks.py and see what happened.

BTW, the path separator may also cause error, because windowns use \ while Ubuntu use /.

ok I finally got it working as you suggested. it is the quotes,I removed the --Gnorm and argument,launched the code and get it working like this :

(worked) python test.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --load_size 512 --dataset_name single --dataroot test_dirs/CelebA-TestN/ --pretrain_model_path ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth --save_as_dir results_CelebA-TestN/SPARNetHD_V4_Attn2D/

(worked) python test_enhance_single_unalign.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --pretrain_model_path .\pretrain_models\SPARNetHD_V4_Attn2D_net_H-epoch10.pth --test_img_path .\test_images\test_hzgg.jpg --results_dir test_hzgg_results

(didn't work) python test.py --gpus 1 --model sparnethd --name SPARNetHD_V4_Attn2D --res_depth 10 --att_name spar --Gnorm 'in' --load_size 512 --dataset_name single --dataroot test_dirs/CelebA-TestN/ --pretrain_model_path ./pretrain_models/SPARNetHD_V4_Attn2D_net_H-epoch10.pth --save_as_dir results_CelebA-TestN/SPARNetHD_V4_Attn2D/

I have another question,is the Face-Sparnet repo also compatible with test_enhance_dir_align.py,test_enhance_dir_unalign.py in PSFRGAN repo,if I use these command lines and the py file together?

You will have to make some necessary modifications, because the inputs and network options of these two are different.

If you set default Gnorm to in, you should remove the --Gnorm in the command.

From the error message "Norm type 'in' not support.", I guess the single quotes might be the problem. You may try to remove the quote. If this does not solve the problem, you may try to print the norm_type to debug the NormLayer class in blocks.py and see what happened.

BTW, the path separator may also cause error, because windowns use \ while Ubuntu use /.

use --Gnorm in [for windows users]