YOLO V8 save results custom file name

1.1k Views Asked by At

I want to save the results the prediction of Yolo v8. I know how so set the path or project/name but I don't want just any file name, e.g. "image0.jpg". I want to specify the file name to something like "custom-name.jpg". I want to iteratively detect human pose on a number of images from a directory.

model = YOLO("./yolov8x-pose.pt")
for file in os.listdir(dir_path):
  img = cv2.imread(file)
  results = model(source=img, save=True, project='/../place')

I want to specify the file names of the results in the folder, to either the original file name or something close.

1

There are 1 best solutions below

0
foxychev On

The problem was first reading the image file with cv2 img = cv2.imread(file). Solution: results = model(source=file, save=True, project='../place') YOLO will read the source file directly and use the filename in the results.