YOLO V8 保存结果自定义文件名

huangapple go评论98阅读模式
英文:

YOLO V8 save results custom file name

问题

我想保存Yolo v8的预测结果。
我知道如何设置路径或项目/名称,但我不想只是任何文件名,例如“image0.jpg”。我想将文件名指定为类似于“custom-name.jpg”的内容。
我想要在目录中的一些图像上进行迭代地检测人体姿势。

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 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

得分: 1

问题首先是使用cv2读取图像文件img = cv2.imread(file)
解决方案:
results = model(source=file, save=True, project='../place')
YOLO将直接读取源文件,并在结果中使用文件名。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月5日 18:15:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76405425.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定