如下,越来越喜欢用Pytorch了
import torch
from thop import profile
from torchvision.models import resnet18
# 创建一个示例输入
input = torch.randn(1, 3, 224, 224)
# 加载您的模型
model = MV2_CBAM_Shuffle()
# 使用thop.profile()函数计算模型的FLOPs
flops, params = profile(model, inputs=(input,))
print(f"FLOPs: {flops}, Params: {params}")