colorjam / pams Goto Github PK
View Code? Open in Web Editor NEWPArameterized Max Scale
PArameterized Max Scale
The variable self.epoch
seems to be constant 1, and then the self._ema()
function would not work well.
HI,author,thanks for your excellent work. I set different k_bits(8 and 4),but trained models have same size,I want to know ,when set k_bits=8,gain the trained model(model_best.pth.tar) is quantized model?
Hi,
I try to reproduce your result by following commands:
python main.py --scale 4 --k_bits 8 --refine ./pretrained/8bit_edsr_x4.pt --save_results --data_test Set5+Set14+B100+Urban100 --save edsr_x4/8bit/ --dir_data ../DIV2K --test_only --model EDSR
Load model from ./pretrained/8bit_edsr_x4.pt
edsr_x4/8bit/ start!
Evaluation:
0it [00:00, ?it/s]
[Set5 x4] PSNR: nan (Best: nan @epoch 1)
WARNING:root:NaN or Inf found in input tensor.
0it [00:00, ?it/s]
[Set14 x4] PSNR: nan (Best: nan @epoch 1)
WARNING:root:NaN or Inf found in input tensor.
0it [00:00, ?it/s]
[B100 x4] PSNR: nan (Best: nan @epoch 1)
WARNING:root:NaN or Inf found in input tensor.
0it [00:00, ?it/s]
[Urban100 x4] PSNR: nan (Best: nan @epoch 1)
WARNING:root:NaN or Inf found in input tensor.
Total: 1.12s
But there is nothing in edsr_x4/8bit/, am I missing anything else?
Thx,
Lei
Thank you for sharing your excellent work.
I'm confused about after the quantization aware training process, we obtain the trained weights and alphas, and then how can i convert the quantization aware trained floating point model to quantized integer model to perform the 8bit calculation and obtain the finnal results in the paper.
您好,我按照run.sh中命令进行训练,8bit,patch_size取192,scale取4时,训练30个epoch,在Set14上的PSNR为28.174dB,和您论文里的28.585dB相差很大,请问这是什么原因呢?
Thank you for sharing your excellent work.
I am confusied about the line 78 in quant_ops.py, why the ‘self.epoch’ was always set to 1, shouldn't it change over the course of training?
Another confusion is the line 94 and line 97 in quant_ops.py, ‘’self.training‘’ seemed not be defined?
ckpt = torch.load(f'{args.refine}') cannot load 4bit_rdn_x4.pt
maybe somethine wrong about it
(pytorch110) robert@robert-Z390-GAMING-X:~/DeepLearning/ModelCompression/PAMS-master$ cd /home/robert/DeepLearning/ModelCompression/PAMS-master ; /usr/bin/env /home/robert/anaconda3/envs/pytorch110/bin/python /home/robert/.vscode/extensions/ms-python.python-2020.12.424452561/pythonFiles/lib/python/debugpy/launcher 35723 -- /home/robert/DeepLearning/ModelCompression/PAMS-master/main.py --scale 4 --k_bits 4 --model RDN --data_test Set14 --save output/rdn_x4/8bit --dir_data /home/robert/Datasets/SuperResolutionData --test_only --refine ./pretrained/4bit_rdn_x4.pt --save_results
Traceback (most recent call last):
File "/home/robert/DeepLearning/ModelCompression/PAMS-master/main.py", line 255, in
main()
File "/home/robert/DeepLearning/ModelCompression/PAMS-master/main.py", line 236, in main
ckpt = torch.load("./pretrained/4bit_rdn_x4.pt")
File "/home/robert/anaconda3/envs/pytorch110/lib/python3.7/site-packages/torch/serialization.py", line 387, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "/home/robert/anaconda3/envs/pytorch110/lib/python3.7/site-packages/torch/serialization.py", line 581, in _load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: storage has wrong size: expected 0 got 1
Thanks for your share.
I have some problem about how to calculate the model's ssim.
When I test the model '4bit_edsrx4.pt' released on google drive, the psnr I got match to the paper's result, but the ssim=0.950 on Set5x4( ssim=0.8851 in the paper).
ps. I used the function calc_ssim
provided in utility.py to calculate ssim, but the result doesn't match the paper's.
Hi @colorjam ,
As per the paper, claimed model size is 1.518MB for EDSR, 0.631MB for 8bit EDSR, 0.484MB for 4-bit EDSR model but in you google drive shared models all 3 models are of 6MB size. Can you let me know how you get the above claimed model size.
Thanks for sharing the code.
But unfortunately, the training result from setting in run.sh doesn't meet the results of the paper.
Training for 8bit EDSR x4 only reaches 31.45 for set 5, which is far behind the reported results.
Are there any specific settings to reproduce the pretrained 4bit_EDSR_x4 or 8bit_EDSR_x4?
Hi,
I tried to test the pre-trained model downloaded from google drive and something wrong happened.
I ran the following code in the terminal:
python main.py --scale 4 --model EDSR --k_bits 8 --save_results --test_only --data_test Set5+Set14+B100+Urban100 --refine ./pretrained/8bit_edsr_x4.pt.tar --save "output/edsr_x4/8bit" --dir_data G:\\Computer\\Datasets
which was copied from run.sh
and a RuntimeError happened as follow
Traceback (most recent call last): File "main.py", line 274, in <module> main() File "main.py", line 259, in main s_model.load_state_dict(s_checkpoint) File "E:\Anaconda3\Anaconda\envs\Exp_tor_1_1_0\lib\site-packages\torch\nn\modules\module.py", line 777, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for PAMS_EDSR: Missing key(s) in state_dict: "body.0.quant_act1.alpha", "body.0.quant_act1.max_val", "body.0.quant_act2.alpha", "body.0.quant_act2.max_val", "body.0.quant_act3.alpha", "body.0.quant_act3.max_val", "body.0.body.2.max_val", "body.1.quant_act1 .alpha", "body.1.quant_act1.max_val", "body.1.quant_act2.alpha", "body.1.quant_act2.max_val", "body.1.quant_act3.alpha", "body.1.quant_act3.max_val", "body.1.body.2.max_val", "body.2.quant_act1.alpha", "body.2.quant_act1.max_val", "body.2.quant_act2 .alpha", "body.2.quant_act2.max_val", "body.2.quant_act3.alpha", "body.2.quant_act3.max_val", "body.2.body.2.max_val", "body.3.quant_act1.alpha", "body.3.quant_act1.max_val", "body.3.quant_act2.alpha", "body.3.quant_act2.max_val", "body.3.quant_act3 .alpha", "body.3.quant_act3.max_val", "body.3.body.2.max_val", "body.4.quant_act1.alpha", "body.4.quant_act1.max_val", "body.4.quant_act2.alpha", "body.4.quant_act2.max_val", "body.4.quant_act3.alpha", "body.4.quant_act3.max_val", "body.4.body.2.max _val", "body.5.quant_act1.alpha", "body.5.quant_act1.max_val", "body.5.quant_act2.alpha", "body.5.quant_act2.max_val", "body.5.quant_act3.alpha", "body.5.quant_act3.max_val", "body.5.body.2.max_val", "body.6.quant_act1.alpha", "body.6.quant_act1.max _val", "body.6.quant_act2.alpha", "body.6.quant_act2.max_val", "body.6.quant_act3.alpha", "body.6.quant_act3.max_val", "body.6.body.2.max_val", "body.7.quant_act1.alpha", "body.7.quant_act1.max_val", "body.7.quant_act2.alpha", "body.7.quant_act2.max _val", "body.7.quant_act3.alpha", "body.7.quant_act3.max_val", "body.7.body.2.max_val", "body.8.quant_act1.alpha", "body.8.quant_act1.max_val", "body.8.quant_act2.alpha", "body.8.quant_act2.max_val", "body.8.quant_act3.alpha", "body.8.quant_act3.max _val", "body.8.body.2.max_val", "body.9.quant_act1.alpha", "body.9.quant_act1.max_val", "body.9.quant_act2.alpha", "body.9.quant_act2.max_val", "body.9.quant_act3.alpha", "body.9.quant_act3.max_val", "body.9.body.2.max_val", "body.10.quant_act1.alph a", "body.10.quant_act1.max_val", "body.10.quant_act2.alpha", "body.10.quant_act2.max_val", "body.10.quant_act3.alpha", "body.10.quant_act3.max_val", "body.10.body.2.max_val", "body.11.quant_act1.alpha", "body.11.quant_act1.max_val", "body.11.quant_ act2.alpha", "body.11.quant_act2.max_val", "body.11.quant_act3.alpha", "body.11.quant_act3.max_val", "body.11.body.2.max_val", "body.12.quant_act1.alpha", "body.12.quant_act1.max_val", "body.12.quant_act2.alpha", "body.12.quant_act2.max_val", "body. 12.quant_act3.alpha", "body.12.quant_act3.max_val", "body.12.body.2.max_val", "body.13.quant_act1.alpha", "body.13.quant_act1.max_val", "body.13.quant_act2.alpha", "body.13.quant_act2.max_val", "body.13.quant_act3.alpha", "body.13.quant_act3.max_val ", "body.13.body.2.max_val", "body.14.quant_act1.alpha", "body.14.quant_act1.max_val", "body.14.quant_act2.alpha", "body.14.quant_act2.max_val", "body.14.quant_act3.alpha", "body.14.quant_act3.max_val", "body.14.body.2.max_val", "body.15.quant_act1. alpha", "body.15.quant_act1.max_val", "body.15.quant_act2.alpha", "body.15.quant_act2.max_val", "body.15.quant_act3.alpha", "body.15.quant_act3.max_val", "body.15.body.2.max_val". Unexpected key(s) in state_dict: "body.0.activation1.alpha", "body.0.activation2.alpha", "body.0.activation3.alpha", "body.1.activation1.alpha", "body.1.activation2.alpha", "body.1.activation3.alpha", "body.2.activation1.alpha", "body.2.acti vation2.alpha", "body.2.activation3.alpha", "body.3.activation1.alpha", "body.3.activation2.alpha", "body.3.activation3.alpha", "body.4.activation1.alpha", "body.4.activation2.alpha", "body.4.activation3.alpha", "body.5.activation1.alpha", "body.5.a ctivation2.alpha", "body.5.activation3.alpha", "body.6.activation1.alpha", "body.6.activation2.alpha", "body.6.activation3.alpha", "body.7.activation1.alpha", "body.7.activation2.alpha", "body.7.activation3.alpha", "body.8.activation1.alpha", "body. 8.activation2.alpha", "body.8.activation3.alpha", "body.9.activation1.alpha", "body.9.activation2.alpha", "body.9.activation3.alpha", "body.10.activation1.alpha", "body.10.activation2.alpha", "body.10.activation3.alpha", "body.11.activation1.alpha", "body.11.activation2.alpha", "body.11.activation3.alpha", "body.12.activation1.alpha", "body.12.activation2.alpha", "body.12.activation3.alpha", "body.13.activation1.alpha", "body.13.activation2.alpha", "body.13.activation3.alpha", "body.14.activat ion1.alpha", "body.14.activation2.alpha", "body.14.activation3.alpha", "body.15.activation1.alpha", "body.15.activation2.alpha", "body.15.activation3.alpha". size mismatch for body.0.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.1.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.2.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.3.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.4.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.5.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.6.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.7.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.8.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.9.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.10.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.11.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.12.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.13.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.14.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]). size mismatch for body.15.body.2.alpha: copying a param with shape torch.Size([]) from checkpoint, the shape in current model is torch.Size([1]).
It seems that the pre-trained model's parameters are different from the parameters defined in edsr.py .
Did I ignore some important details? Or did you provide a model that doesn't match the current code?
Hoping you can reply as soon as possible, Thanks~
The figure 1 in the paper implies that the input of 1st conv in the PAMSblock is quantized.
However, according to your code, the input of 1st convolution in the residual block is not quantized.
Accordingly, the experimental results are from the wrong code..?
Can you solve the inconsistency?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.