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

calculate FLOPS #10

Open
504058568 opened this issue Sep 11, 2024 · 1 comment
Open

calculate FLOPS #10

504058568 opened this issue Sep 11, 2024 · 1 comment

Comments

@504058568
Copy link

Hello, may I ask if you can provide the script of calculating FLOPS

@dsx0511
Copy link
Owner

dsx0511 commented Dec 7, 2024

Hi @504058568,

you can try to add following code in your test script:

from mmcv.cnn.utils.flops_counter import add_flops_counting_methods

flops_model = add_flops_counting_methods(model)

for i, data in enumerate(data_loader):
        flops_model.start_flops_count()
        with torch.no_grad():
            result = flops_model(return_loss=False, rescale=True, **data)
        
        flops, params = flops_model.compute_average_flops_cost()
        flops_model.stop_flops_count()

        print('flops: ', flops)
        print('params', params)

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