csjliang / DASR

Official implementation of the paper 'Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution' in ECCV 2022
Apache License 2.0
128 stars 9 forks source link

Nice work! The DASR how to inference single image ? #6

Closed kelisiya closed 2 years ago

kelisiya commented 2 years ago

When I run CUDA_VISIBLE_DEVICES=3 python dasr/test.py -opt options/test/DASR/test_DASR.yml Disable distributed. Traceback (most recent call last): File "dasr/test.py", line 45, in <module> test_pipeline(root_path) File "dasr/test.py", line 35, in test_pipeline model = build_model(opt) File "/opt/conda/lib/python3.8/site-packages/basicsr/models/__init__.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) TypeError: tuple indices must be integers or slices, not str

csjliang commented 2 years ago

When I run CUDA_VISIBLE_DEVICES=3 python dasr/test.py -opt options/test/DASR/test_DASR.yml Disable distributed. Traceback (most recent call last): File "dasr/test.py", line 45, in <module> test_pipeline(root_path) File "dasr/test.py", line 35, in test_pipeline model = build_model(opt) File "/opt/conda/lib/python3.8/site-packages/basicsr/models/__init__.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) TypeError: tuple indices must be integers or slices, not str

Hi,

Thanks for your attention to our work. Please follow our instructions and add PYTHONPATH=":${PYTHONPATH}".

For the inference of single image, you can either simply put the image to a dir and use our provided inference script, or you can implement it by yourself. Thanks.

kelisiya commented 2 years ago

When I run CUDA_VISIBLE_DEVICES=3 python dasr/test.py -opt options/test/DASR/test_DASR.yml Disable distributed. Traceback (most recent call last): File "dasr/test.py", line 45, in <module> test_pipeline(root_path) File "dasr/test.py", line 35, in test_pipeline model = build_model(opt) File "/opt/conda/lib/python3.8/site-packages/basicsr/models/__init__.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) TypeError: tuple indices must be integers or slices, not str

Hi,

Thanks for your attention to our work. Please follow our instructions and add PYTHONPATH=":${PYTHONPATH}".

For the inference of single image, you can either simply put the image to a dir and use our provided inference script, or you can implement it by yourself. Thanks.

Thank you , and I want to train a X2 model , I change the config upscale: 2,the train the model ; The loss is : 2022-04-07 11:33:06,820 INFO: [train..][epoch: 0, iter: 100, lr:(1.000e-04,)] [eta: 10 days, 19:42:07, time (data): 1.811 (0.461)] l_pix: nan l_regression: nan l_percep: nan l_g_gan: nan l_d_real: nan out_d_real: nan l_d_fake: nan out_d_fake: nan But all loss is Nan, shoud I load Degradation_Predictor pretrain to finetune MSRResNetDynamic net ?

kelisiya commented 2 years ago

When I run CUDA_VISIBLE_DEVICES=3 python dasr/test.py -opt options/test/DASR/test_DASR.yml Disable distributed. Traceback (most recent call last): File "dasr/test.py", line 45, in <module> test_pipeline(root_path) File "dasr/test.py", line 35, in test_pipeline model = build_model(opt) File "/opt/conda/lib/python3.8/site-packages/basicsr/models/__init__.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) TypeError: tuple indices must be integers or slices, not str

Hi, Thanks for your attention to our work. Please follow our instructions and add PYTHONPATH=":${PYTHONPATH}". For the inference of single image, you can either simply put the image to a dir and use our provided inference script, or you can implement it by yourself. Thanks.

Thank you , and I want to train a X2 model , I change the config upscale: 2,the train the model ; The loss is : 2022-04-07 11:33:06,820 INFO: [train..][epoch: 0, iter: 100, lr:(1.000e-04,)] [eta: 10 days, 19:42:07, time (data): 1.811 (0.461)] l_pix: nan l_regression: nan l_percep: nan l_g_gan: nan l_d_real: nan out_d_real: nan l_d_fake: nan out_d_fake: nan But all loss is Nan, shoud I load Degradation_Predictor pretrain to finetune MSRResNetDynamic net ?

This looks doesn't work ,can you help me ?

csjliang commented 2 years ago

Have you loaded the pretrained MSRResNetx2 network for initialization? As the training of adversarial loss is unstable, you need to initialize the model from a stable one that is trained with pixel-wise loss only. You can find the pretrained model from the BasicSR project. Thanks.

csjliang commented 2 years ago

Hi,

Please put the model to 'pretrained_models', or modify the code in srgan_dynamic_model.py by using the self.load_network_init_alldynamic to load model. Thanks.

BTW, Why cannot view your recent comments on github?

kelisiya @.***> 于2022年4月8日周五 09:59写道:

Have you loaded the pretrained MSRResNetx2 network for initialization? As the training of adversarial loss is unstable, you need to initialize the model from a stable one that is trained with pixel-wise loss only. You can find the pretrained model from the BasicSR project. Thanks.

I find the checkpoint in https://drive.google.com/drive/folders/1XN4WXKJ53KQ0Cu0Yv-uCt8DZWq6uufaP , and when I load the X2 pretrain , there is a shape error. 2022-04-08 01:47:24,598 INFO: Loading MSRResNetDynamic model from /data/jxie/Real-ESRGAN/DASR/dasr/Inference_model/weight/net_g_1000000.pth. Traceback (most recent call last): File "dasr/train.py", line 11, in

train_pipeline(root_path) File "/app/DASR/basicsr/train.py", line 128, in train_pipeline model = build_model(opt) File "/app/DASR/basicsr/models/__init__.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) File "/app/DASR/dasr/models/DASR_model.py", line 20, in __init__ super(DASRModel, self).__init__(opt) File "/app/DASR/basicsr/models/srgan_dynamic_model.py", line 43, in __init__ self.load_network(self.net_g, load_path, self.opt['path'].get('strict_load_g', True), load_key) File "/app/DASR/basicsr/models/base_model.py", line 315, in load_network net.load_state_dict(load_net, strict=strict) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for MSRResNetDynamic: size mismatch for conv_first.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 3, 3, 3]). size mismatch for conv_first.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). size mismatch for body.0.conv1.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 64, 3, 3]). size mismatch for body.0.conv1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you commented.Message ID: ***@***.***>
kelisiya commented 2 years ago

Hi, Please put the model to 'pretrained_models', or modify the code in srgan_dynamic_model.py by using the self.load_network_init_alldynamic to load model. Thanks. BTW, Why cannot view your recent comments on github? kelisiya @.> 于2022年4月8日周五 09:59写道: Have you loaded the pretrained MSRResNetx2 network for initialization? As the training of adversarial loss is unstable, you need to initialize the model from a stable one that is trained with pixel-wise loss only. You can find the pretrained model from the BasicSR project. Thanks. I find the checkpoint in https://drive.google.com/drive/folders/1XN4WXKJ53KQ0Cu0Yv-uCt8DZWq6uufaP , and when I load the X2 pretrain , there is a shape error. 2022-04-08 01:47:24,598 INFO: Loading MSRResNetDynamic model from /data/jxie/Real-ESRGAN/DASR/dasr/Inference_model/weight/net_g_1000000.pth. Traceback (most recent call last): File "dasr/train.py", line 11, in train_pipeline(root_path) File "/app/DASR/basicsr/train.py", line 128, in train_pipeline model = build_model(opt) File "/app/DASR/basicsr/models/init.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) File "/app/DASR/dasr/models/DASR_model.py", line 20, in init super(DASRModel, self).init(opt) File "/app/DASR/basicsr/models/srgan_dynamic_model.py", line 43, in init self.load_network(self.net_g, load_path, self.opt['path'].get('strict_load_g', True), load_key) File "/app/DASR/basicsr/models/base_model.py", line 315, in load_network net.load_state_dict(load_net, strict=strict) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for MSRResNetDynamic: size mismatch for conv_first.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 3, 3, 3]). size mismatch for conv_first.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). size mismatch for body.0.conv1.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 64, 3, 3]). size mismatch for body.0.conv1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). — Reply to this email directly, view it on GitHub <#6 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQB3YBD6P5RX6JSTK3RPJDTVD6HHTANCNFSM5SYSYCZA . You are receiving this because you commented.Message ID: @.>

Because I solved these problems so I delete the recent message . If I don't use RealWolrd38 dataset to validation, can I use other dataset instead of it ? Or train the model don't use val code?

csjliang commented 2 years ago

Hi, Please put the model to 'pretrained_models', or modify the code in srgan_dynamic_model.py by using the self.load_network_initalldynamic to load model. Thanks. BTW, Why cannot view your recent comments on github? kelisiya @.> 于2022年4月8日周五 09:59写道: Have you loaded the pretrained MSRResNetx2 network for initialization? As the training of adversarial loss is unstable, you need to initialize the model from a stable one that is trained with pixel-wise loss only. You can find the pretrained model from the BasicSR project. Thanks. I find the checkpoint in https://drive.google.com/drive/folders/1XN4WXKJ53KQ0Cu0Yv-uCt8DZWq6uufaP , and when I load the X2 pretrain , there is a shape error. 2022-04-08 01:47:24,598 INFO: Loading MSRResNetDynamic model from /data/jxie/Real-ESRGAN/DASR/dasr/Inference_model/weight/net_g_1000000.pth. Traceback (most recent call last): File "dasr/train.py", line 11, in train_pipeline(root_path) File "/app/DASR/basicsr/train.py", line 128, in train_pipeline model = build_model(opt) File "/app/DASR/basicsr/models/init.py", line 27, in build_model model = MODEL_REGISTRY.get(opt['model_type'])(opt) File "/app/DASR/dasr/models/DASR_model.py", line 20, in init super(DASRModel, self).init(opt) File "/app/DASR/basicsr/models/srgan_dynamic_model.py", line 43, in init self.load_network(self.net_g, load_path, self.opt['path'].get('strict_load_g', True), load_key) File "/app/DASR/basicsr/models/base_model.py", line 315, in load_network net.load_state_dict(load_net, strict=strict) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for MSRResNetDynamic: size mismatch for conv_first.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 3, 3, 3]). size mismatch for convfirst.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). size mismatch for body.0.conv1.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([5, 64, 64, 3, 3]). size mismatch for body.0.conv1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([5, 64]). — Reply to this email directly, view it on GitHub <#6 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQB3YBD6P5RX6JSTK3RPJDTVD6HHTANCNFSM5SYSYCZA . You are receiving this because you commented.Message ID: @_._>

Because I solved these problems so I delete the recent message . If I don't use RealWolrd38 dataset to validation, can I use other dataset instead of it ? Or train the model don't use val code?

Sure. You can replace the dataroot_lq of Val dataset, or you can just comment the lines of val (val_freq and save_img) in the yml file to train the model without validation.