-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yolov8 segmenation parameter questions #14007
Comments
Hello, Thank you for your detailed question and for providing the code snippet. The discrepancy in the number of parameters you're observing is indeed intriguing. Let's delve into the possible reasons for this difference. Understanding the DiscrepancyThe number of parameters listed in the YOLOv8 Performance Metrics for the
Steps to Verify
Code Example for Parameter CountingHere's a concise example to count the parameters using the from ultralytics import YOLO
from torchinfo import summary
# Load the YOLOv8m-seg model
model = YOLO("yolov8m-seg.pt")
# Print the model summary
summary(model.model, input_size=(1, 3, 640, 640)) This should give you a detailed breakdown of the model's architecture and parameter count. ConclusionThe difference in parameter counts could be due to the inclusion of additional components in the segmentation model or differences in how parameters are counted. Providing a minimal reproducible example and ensuring you are using the latest version of the package will help us further investigate this issue. Feel free to reach out if you have any more questions or need further assistance! |
@glenn-jocher
outputLayer (type:depth-idx) Output Shape Param #SegmentationModel [1, 116, 8400] --
|
@Leo-aetech hello, Thank you for your detailed follow-up and for providing the code snippet and output. I appreciate your diligence in verifying the model parameters. The discrepancy you're observing between the documented parameters (27.3M) and the parameters reported by your script (50,773,504) is indeed puzzling. Here are a few points to consider: Potential Reasons for Discrepancy
Steps to Verify
Code Example for Parameter CountingHere's a concise example to count the parameters using the from ultralytics import YOLO
from torchinfo import summary
# Load the YOLOv8m-seg model
model = YOLO("yolov8m-seg.pt")
# Print the model summary
summary(model.model, input_size=(1, 3, 640, 640)) This should give you a detailed breakdown of the model's architecture and parameter count. ConclusionThe difference in parameter counts could be due to the inclusion of additional components in the segmentation model or differences in how parameters are counted. Providing a minimal reproducible example and ensuring you are using the latest version of the package will help us further investigate this issue. Feel free to reach out if you have any more questions or need further assistance! |
glenn-jocher answer like GPT :( I also confused about total parameters in models. |
Thank you for your comment. The discrepancy in the total parameters you're seeing might be due to differences in how parameters are counted or additional components in the segmentation model. Please ensure you're using the latest version of the Ultralytics YOLO package and verify the parameter count again. If the issue persists, providing a minimal reproducible example would help us investigate further. Feel free to reach out with any more questions. |
@AISTALK @Leo-aetech This approach will yield 27.3M matching the docuements. from ultralytics import YOLO
# Load the YOLOv8m-seg model
model = YOLO("yolov8m-seg.pt")
# It is a pytorch model, so we can count it directrly.
pytorch_total_params = sum(p.numel() for p in model.parameters())
# 27285968
print(pytorch_total_params) |
@6DammK9 That's because docs do not count model's head params as params. In docs there are only sizes of model's backbones. |
Search before asking
Question
We conducted an inference on yolov8m-seg as below. To know the number of parameters in the model, we checked the number of parameters using summary in the method part of the BasePredictor class.
The number of parameters in this way is 50,741,712. In link https://docs.ultralytics.com/models/yolov8/#performance-metrics, the number of parameters of yolov8m-seg is 27.3M. Why is this difference coming out?
Downloading https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m-seg.pt to 'yolov8m-seg.pt'...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 52.4M/52.4M [00:00<00:00, 115MB/s]
====================================================================================================
Layer (type:depth-idx) Output Shape Param #
AutoBackend [1, 116, 8400] --
├─SegmentationModel: 1-1 [1, 116, 8400] --
│ └─Sequential: 2-1 -- --
│ │ └─Conv: 3-1 [1, 48, 320, 320] (1,344)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-3 [1, 96, 160, 160] (41,568)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-5 [1, 96, 160, 160] (110,976)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-15 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-15 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-15 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-15 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-15 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-17 [1, 192, 80, 80] (166,080)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-19 [1, 192, 80, 80] (812,160)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-37 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-39 [1, 384, 40, 40] (663,936)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-41 [1, 384, 40, 40] (3,246,336)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-59 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-61 [1, 576, 20, 20] (1,991,232)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-63 [1, 576, 20, 20] (3,983,616)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-73 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-73 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-73 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-73 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-73 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─SPPF: 3-75 [1, 576, 20, 20] (830,304)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─SPPF: 3-77 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Upsample: 3-79 [1, 576, 40, 40] --
│ │ └─Concat: 3-80 [1, 960, 40, 40] --
│ │ └─C2f: 3-81 [1, 384, 40, 40] (1,992,192)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-91 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-91 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-91 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-91 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-91 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Upsample: 3-93 [1, 384, 80, 80] --
│ │ └─Concat: 3-94 [1, 576, 80, 80] --
│ │ └─C2f: 3-95 [1, 192, 80, 80] (516,864)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-105 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-105 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-105 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-105 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-105 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-107 [1, 192, 40, 40] (331,968)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Concat: 3-109 [1, 576, 40, 40] --
│ │ └─C2f: 3-110 [1, 384, 40, 40] (1,844,736)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-120 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-120 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-120 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-120 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-120 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Conv: 3-122 [1, 384, 20, 20] (1,327,488)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Concat: 3-124 [1, 960, 20, 20] --
│ │ └─C2f: 3-125 [1, 576, 20, 20] (4,204,800)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-135 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-135 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-135 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-135 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─C2f: 3-135 -- (recursive)
│ │ └─Segment: 3-136 -- (recursive)
│ │ └─Segment: 3-137 [1, 116, 8400] (5,203,104)
Total params: 50,741,712
Trainable params: 0
Non-trainable params: 50,741,712
Total mult-adds (G): 55.16
Input size (MB): 4.92
Forward/backward pass size (MB): 490.51
Params size (MB): 109.07
Estimated Total Size (MB): 604.50
image 1/1 /home/aetech/PycharmProjects/torch/JSW_test/ultralytics/seg_test/CH1_240415_vw_19_6_091520.jpg: 416x640 8 bottles, 1 cell phone, 17.7ms
Speed: 3.1ms preprocess, 17.7ms inference, 87.2ms postprocess per image at shape (1, 3, 416, 640)
Unable to init server: Could not connect: Connection refused
Additional
No response
The text was updated successfully, but these errors were encountered: