Installez le fichier de bibliothèque correspondant
pip install ptflops
code(get_model_complexity_info)
import torchvision.models as models
from ptflops import get_model_complexity_info
net = models.vgg16() #可以为自己搭建的模型
flops, params = get_model_complexity_info(model, (3,512,512), as_strings=True, print_per_layer_stat=True) #(3,512,512)输入图片的尺寸
print("Flops: {}".format(flops))
print("Params: " + params)