SwinIR icon indicating copy to clipboard operation
SwinIR copied to clipboard

About #Parameters in the model

Open prateek-77 opened this issue 2 years ago • 4 comments

Thanks for providing the code for SwinIR!

I calculated the #Params and #FLOPS for the lightweight SwinIR model using KAIR. However, I'm not able to replicate the numbers mentioned in table 3 of the paper. For example, I get the #Params as 910.2K instead of 878K in the table. The same happens with #FLOPS too. Could you please guide me on how to reproduce the results? Thanks!

prateek-77 avatar Nov 06 '21 20:11 prateek-77

#Params: use

 print({sum(map(lambda x: x.numel(), model.parameters())):,d})

# FLOPS: refer to https://github.com/JingyunLiang/SwinIR/blob/510b75617620b05f4e35f74dec8d30d59c721cf6/models/network_swinir.py#L862

JingyunLiang avatar Nov 06 '21 21:11 JingyunLiang

Thanks for the suggestions! The #Flops for the lightweight SwinIR model are matching, however, the #Params are not. It's coming out to be around 910.2K.

I'm using the following model config for lightweight-SwinIR:

height = (1024 // upscale // window_size + 1) * window_size
width = (720 // upscale // window_size + 1) * window_size
model = SwinIR(upscale=2, in_chans=3, img_size=(height, width), window_size=8,
                    img_range=1., depths=[6, 6, 6, 6], embed_dim=60, num_heads=[6, 6, 6, 6],
                    mlp_ratio=2, upsampler='pixelshuffledirect', resi_connection='1conv')

Also, I'm not able to use model.flops() with classic image SR models, since flop calculation is not defined for the Upsample class.

Can you please provide help with these queries? Thanks a lot!

prateek-77 avatar Nov 07 '21 13:11 prateek-77

Im facing the same thing. The number of network parameters is 910K!

Auth0rM0rgan avatar Dec 05 '21 12:12 Auth0rM0rgan

I found that #params in paper excludes "relative_position_bias_table" parameters. These parameters should be included in #params. But this code print({sum(map(lambda x: x.numel(), model.parameters())):,d}) produces right #params that includes "relative_position_bias_table". I think it should be corrected in your paper.

rami0205 avatar Aug 24 '22 14:08 rami0205