Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The provided model flops are different from those calculated by thop. #37

Open
superxi opened this issue Dec 30, 2024 · 2 comments
Open

Comments

@superxi
Copy link

superxi commented Dec 30, 2024

I calculate the model flops as below. And the result is FLOPs = 114.511724544G Params = 27.327015M. But the provided flops for
DRCT-L is 11.07G. Is there something wrong ?

from thop import profile
import torch
model = DRCT(upscale=4, in_chans=3,  img_size= 64, window_size= 16, compress_ratio= 3,squeeze_factor= 30,
                conv_scale= 0.01, overlap_ratio= 0.5, img_range= 1., depths= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
                embed_dim= 180, num_heads= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], gc= 32,
                mlp_ratio= 2, upsampler= 'pixelshuffle', resi_connection= '1conv').cuda()

img = torch.randn((1,3,64,64)).requires_grad_(True).cuda()
flops, params = profile(model, inputs=(img,))
print('FLOPs = ' + str(flops/1000**3) + 'G')
print('Params = ' + str(params/1000**2) + 'M')`
@xduzhangjiayu
Copy link

I calculate the model flops as below. And the result is FLOPs = 114.511724544G Params = 27.327015M. But the provided flops for DRCT-L is 11.07G. Is there something wrong ?

from thop import profile
import torch
model = DRCT(upscale=4, in_chans=3,  img_size= 64, window_size= 16, compress_ratio= 3,squeeze_factor= 30,
                conv_scale= 0.01, overlap_ratio= 0.5, img_range= 1., depths= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
                embed_dim= 180, num_heads= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], gc= 32,
                mlp_ratio= 2, upsampler= 'pixelshuffle', resi_connection= '1conv').cuda()

img = torch.randn((1,3,64,64)).requires_grad_(True).cuda()
flops, params = profile(model, inputs=(img,))
print('FLOPs = ' + str(flops/1000**3) + 'G')
print('Params = ' + str(params/1000**2) + 'M')`

I have the same issue, I have tested DRCT and HAT with same input, and found that HAT is very faster than DRCT

@xduzhangjiayu
Copy link

I calculate the model flops as below. And the result is FLOPs = 114.511724544G Params = 27.327015M. But the provided flops for DRCT-L is 11.07G. Is there something wrong ?

from thop import profile
import torch
model = DRCT(upscale=4, in_chans=3,  img_size= 64, window_size= 16, compress_ratio= 3,squeeze_factor= 30,
                conv_scale= 0.01, overlap_ratio= 0.5, img_range= 1., depths= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
                embed_dim= 180, num_heads= [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], gc= 32,
                mlp_ratio= 2, upsampler= 'pixelshuffle', resi_connection= '1conv').cuda()

img = torch.randn((1,3,64,64)).requires_grad_(True).cuda()
flops, params = profile(model, inputs=(img,))
print('FLOPs = ' + str(flops/1000**3) + 'G')
print('Params = ' + str(params/1000**2) + 'M')`

Hi, did you solve this problem? I have met the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants