I am testing this code, to compare model parameters, which will help me to modify the models/layers, but I don't know which method gives me the actual number of parameters.
from torchsummary import summary
import torchinfo
from ultralytics.nn.tasks import DetectionModel
yolo_model = DetectionModel(cfg, nc=80 )
summary(yolo_model,(3, 640, 640))
torchinfo.summary( yolo_model, (3, 640, 640), batch_dim = 0)
Result from torchinfo
:
=======================================
Total params: 5,257,936
Trainable params: 5,257,920
Non-trainable params: 16
Total mult-adds (G): 4.37
====================================================================================================
Input size (MB): 4.92
Forward/backward pass size (MB): 232.15
Params size (MB): 12.63
Estimated Total Size (MB): 249.70
====================================================================================================
Result from torchsummary
:
==========================================================================================
Total params: 1,312,416
Trainable params: 1,312,400
Non-trainable params: 16
Total mult-adds (G): 1.39
==========================================================================================
Input size (MB): 4.69
Forward/backward pass size (MB): 128.38
Params size (MB): 5.01
Estimated Total Size (MB): 138.08
==========================================================================================
Beside this, the number of parameters printed by yolov8
itself is different. Please let me know best way to get the actual number of parameters.