展示模型概要summary,查看模型结构工具Netron
推荐torchinfo,官网地址 TylerYep/torchinfo: View model summaries in PyTorch!
torchsummary、torch-summary都用过,还是torchinfo更准,尤其是显示yolo模型的时候。
展示形式如下:
对于一般模型,如resnet
from torchinfo import summary from torchvision import models model = models.resnet18() summary(model,(1,3,224,224))
对于yolo
from torchinfo import summary from ultralytics import YOLO model = YOLO("yolo11n.pt") summary(model.model,(1,3,640,640))
具体的模型文件,如pt、onnx等,直接双击用Netron软件打开查看
下载 lutzroeder/netron: Visualizer for neural network, deep learning and machine learning models