This part is not required, nor is it supported.
It would be good to get an understanding of what which library you are using. Most users are using ultralytics
but some still use the YOLOv5 repo, so knowing which one you’re asking about will be important to provide assistance (see this post for advice on asking for support).
In all likelihood, you should only need to use something along the lines of
from ultralytics import YOLO
model = YOLO("yolo11n-seg.pt")
results = model.predict("path/to/source")
to get results when using ultralytics
. The documentation has lots of examples and you can see the details on the segmentation task here and more information on the predict mode here. If you’re using YOLOv5, unless there’s an explicit need to continue using it, I recommend migrating or using the ultralytics
library instead.