uzh-rpg / svit

Official implementation of "SViT: Revisiting Token Pruning for Object Detection and Instance Segmentation"
Apache License 2.0
23 stars 3 forks source link

FLOPs calculation #4

Closed King4819 closed 2 months ago

King4819 commented 5 months ago

Hi, I want to ask that is there any method that can calculates FLOPs based on your code ?

I want to calculate the FLOPs of SViT-T when inferencing different images (since the method will give different prune ratio according to different images).

I have tried fvcore but it doesn't work. I have also tried mmcv tools to calculate FLOPs but the function can only take input image shape instead of image (so that I can't calculate FLOPs after token-pruning)

THANKS !!!

kaikai23 commented 4 months ago

Hi, it can be easier to test the latency rather than FLOPs.

For FLOPs, see issue 5.

King4819 commented 3 months ago

I would like to ask another question about FLOPs calculation. Since the method will automatically allocate different number of tokens for different images, the FLOPs will therefore be different with different input images (larger FLOPs for complicated image and smaller FLOPs for simple image). One reasonable way to calculate the FLOPs result of pruned model is by calculating the FLOPs given each image in ImageNet val set then average them ?

kaikai23 commented 2 months ago

I would like to ask another question about FLOPs calculation. Since the method will automatically allocate different number of tokens for different images, the FLOPs will therefore be different with different input images (larger FLOPs for complicated image and smaller FLOPs for simple image). One reasonable way to calculate the FLOPs result of pruned model is by calculating the FLOPs given each image in ImageNet val set then average them ?

Yes, I think so! Or you could approximate it by finding the average number of tokens used on ImageNet val and use one image which activated this number of tokens.

King4819 commented 2 months ago

Thanks for your reply