LoSealL / VideoSuperResolution

A collection of state-of-the-art video or single-image super-resolution architectures, reimplemented in tensorflow.
MIT License
1.61k stars 295 forks source link

Inferring colorspace #99

Closed Dejan1969 closed 4 years ago

Dejan1969 commented 4 years ago

Inferring produce strange colors images (and every time different one ???)

ESRGAN (pytorch):

$python3 eval.py esrgan -t 0012x2.png --cuda 2020-03-07 12:10:23,950 INFO: LICENSE: ESRGAN is implemented by Xintao Wang. @xinntao https://github.com/xinntao/ESRGAN 2020-03-07 12:10:27,679 INFO: Total params: 77223884 2020-03-07 12:10:27,680 WARNING: trying to restore state for optimizer optd, but failed. 2020-03-07 12:10:27,680 WARNING: trying to restore state for optimizer optg, but failed. 2020-03-07 12:10:27,683 INFO: Inferring [dnet][rrdb] at epoch 0 Infer: 100%|######################################| 1/1 [00:06<00:00, 6.94s/it]

esrgan_1_0012x2_id0000_0000 esrgan_2_0012x2_id0000_0000 esrgan_3_0012x2_id0000_0000

SRCNN (tensorflow):

python3 eval.py srcnn -t 0012x2.png --cuda 2020-03-07 12:13:27,926 INFO: Total params: 69251 2020-03-07 12:13:27,926 WARNING: trying to restore state for optimizer opt, but failed. 2020-03-07 12:13:27,928 INFO: Inferring [srcnn] at epoch 0 Infer: 100%|######################################| 1/1 [00:01<00:00, 1.89s/it]

srcnn_1_0012x2_id0000_0000 srcnn_2_0012x2_id0000_0000 srcnn_3_0012x2_id0000_0000

Adding ----output_color=RGB produce following error...

$python3 eval.py esrgan -t 0012x2.png --cuda --output_color=RGB Traceback (most recent call last): File "predict.py", line 120, in main() File "predict.py", line 76, in main suppress_opt_by_args(model_params, *args) File "/home/xxxxxx/VideoSuperResolution/VSR/Util/Utility.py", line 116, in suppress_opt_by_args raise KeyError("Parameter {} doesn't exist in model!".format(key)) KeyError: "Parameter output_color doesn't exist in model!"

My setup

ubuntu18.04, CUDA 10.0 Python 3.6.9

tensorboard 1.15.0
tensorboardX 2.0
tensorflow 1.15.2
tensorflow-estimator 1.15.1
tensorflow-gpu 1.15.2
torch 1.4.0
torchvision 0.5.0
numpy 1.16.2
scikit-image 0.16.2
scipy 1.4.1
matplotlib 3.2.0
Pillow 7.0.0
pypng 0.0.20
pytest 5.3.5
PyYAML 5.3
psutil 5.4.2
tqdm 4.41.1
h5py 2.10.0
easydict 1.9

Any ideas?

LoSealL commented 4 years ago

eval.py is just a calling tool. You will need pre-trained weights to do the actual inferring.

To download weights, you can refer to prepare_data.py or official repos, and using --pretrain to specify the weights

Dejan1969 commented 4 years ago

Thank you for clarifying, however adding

--pretrain=/home/xxxxxx/VideoSuperResolution/Results/RRDB_GAN.pth (from you) or --pretrain=/home/xxxxxx/VideoSuperResolution/Results/RRDB_ESRGAN_x4.pth (from https://github.com/xinntao/ESRGAN/tree/master/models)

produce following error :

$ python3 eval.py esrgan --cuda --auto_rename -t 0012x2.png --pretrain=/home/xxxxxx/VideoSuperResolution/Results/RRDB_GAN.pth 2020-03-13 09:47:46,991 INFO: LICENSE: ESRGAN is implemented by Xintao Wang. @xinntao https://github.com/xinntao/ESRGAN Traceback (most recent call last): File "eval.py", line 117, in main() File "eval.py", line 80, in main model.load(opt.pretrain) File "/home/xxxxxx/VideoSuperResolution/VSR/Backend/Torch/Models/Model.py", line 123, in load model.load_state_dict(torch.load(str(pth), map_location=map_location)) File "/home/xxxxxx/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 830, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DCGAN: Missing key(s) in state_dict: "body.0.body.0.weight", "body.0.body.0.bias", "body.0.body.1.weight", "body.0.body.1.bias", "body.0.body.1.running_mean", "body.0.body.1.running_var", "body.1.body.0.weight", "body.1.body.0.bias", "body.1.body.1.weight", "body.1.body.1.bias", "body.1.body.1.running_mean", "body.1.body.1.running_var", "body.2.body.0.weight" ....................................................... Unexpected key(s) in state_dict: "model.0.weight", "model.0.bias", "model.1.sub.0.RDB1.conv1.0.weight", "model.1.sub.0.RDB1.conv1.0.bias", "model.1.sub.0.RDB1.conv2.0.weight", "model.1.sub.0.RDB1.conv2.0.bias", "model.1.sub.0.RDB1.conv3.0.weight", "model.1.sub.0.RDB1.conv3.0.bias", "model.1.sub.0.RDB1.conv4.0.weight", "model.1.sub.0.RDB1.conv4.0.bias", "model.1.sub.0.RDB1.conv5.0.weight", "model.1.sub.0.RDB1.conv5.0.bias", "model.1.sub.0.RDB2.conv1.0.weight", ..............................................................

Dejan1969 commented 4 years ago

Also trying to load VSR trained model in orginal ESRGAN (https://github.com/xinntao/ESRGAN) produce error:

$ python3 test.py Initializing ESRGAN using model 'rrdb_ep0010.pth' Traceback (most recent call last): File "test.py", line 165, in exit(main()) File "test.py", line 155, in main esrgan = ESRGAN(model_path, device, scale_factor, tile_size, padding_size) File "test.py", line 18, in init model.load_state_dict(torch.load(model_path), strict=True) File "/home/xxxxxx/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 830, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for RRDBNet: Missing key(s) in state_dict: "conv_first.weight", "conv_first.bias", "RRDB_trunk.0.RDB1.conv1.weight", "RRDB_trunk.0.RDB1.conv1.bias", "RRDB_trunk.0.RDB1.conv2.weight", "RRDB_trunk.0.RDB1.conv2.bias", "RRDB_trunk.0.RDB1.conv3.weight", "RRDB_trunk.0.RDB1.conv3.bias", "RRDB_trunk.0.RDB1.conv4.weight", "RRDB_trunk.0.RDB1.conv4.bias", "RRDB_trunk.0.RDB1.conv5.weight", "RRDB_trunk.0.RDB1.conv5.bias", "RRDB_trunk.0.RDB2.conv1.weight", "RRDB_trunk.0.RDB2.conv1.bias", ...........................................................

LoSealL commented 4 years ago

try to rep and get back to you later