0

I'm currently working in a project in which I'm using Flask and Yolov8 together.

When I run this code

from ultralytics import YOLO

model = YOLO("./yolov8n.pt")

results = model.predict(source="../TEST/doggy.jpg", save=True, save_txt=True)

the output will be saved in this default directory /run/detect/

like

Ultralytics YOLOv8.0.9  Python-3.10.8 torch-2.0.0+cpu CPU
Fusing layers... 
YOLOv8n summary: 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
Results saved to d:\runs\detect\predict4
1 labels saved to d:\runs\detect\predict4\labels

and what I want is the predict directory number or the entire directory path in a variable.

I tried capturing the path using sys.stdout methods but i want a direct solution.

paleonix
  • 2,293
  • 1
  • 13
  • 29
Hariharan
  • 191
  • 7

1 Answers1

2

You can change the directory where the results are saved (save_dir) by modifying two arguments in predict: project and name

results = model.predict(source=xxx, project="xxx", name="yyy")

such that:

save_dir=project/name
Mike B
  • 2,136
  • 2
  • 12
  • 31