MrYxJ / calculate-flops.pytorch

The calflops is designed to calculate FLOPs、MACs and Parameters in all various neural networks, such as Linear、 CNN、 RNN、 GCN、Transformer(Bert、LlaMA etc Large Language Model)
https://pypi.org/project/calflops/
MIT License
392 stars 14 forks source link

On the calculation of FLOPs for SAM/MobileSAM #29

Open BeliverK opened 2 weeks ago

BeliverK commented 2 weeks ago

SAM model requires multiple inputs, image, point_prompt or boxes_prompt, how do you pass these parameters to the calculate_flops?For example, in the following code, how to set parameters?

from mobile_sam import MobileSAM, SamPredictor
import torch

model = MobileSAM.from_pretrained("nielsr/mobilesam")

# perform inference
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device=device)

predictor = SamPredictor(model)
predictor.set_image(<your_image>)
masks, _, _ = predictor.predict(<input_prompts>)