import cv2
from ultralytics import YOLO
import torch
model = YOLO('seg.pt')
img = cv2.imread('ballon2.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
results = model.predict(img, show = True)
cv2.imshow('seg',(results[0].masks.data[0].numpy() * 255).astype("uint8"))
the last line is our answer.