SimpleCVReproduction icon indicating copy to clipboard operation
SimpleCVReproduction copied to clipboard

关于pascal.py里的annopath

Open mastergao57 opened this issue 3 years ago • 2 comments

作者您好,当我运行到这句代码时self.annopath = os.path.join(VOC_test_root, 'VOC2007', 'Annotations', '{:s}.xml')recs[imagename] = self.parse_record(annopath.format(imagename))总是报错找不到.xml文件,显示路径有错误,不知道您有没有遇到类似的问题。`

mastergao57 avatar Apr 11 '22 05:04 mastergao57

import os
import cv2
import json
import math
import pickle
import numpy as np
import xml.etree.ElementTree as ET
VOC_test_root = './data/voc'
apath = os.path.join(VOC_test_root, 'VOC2007', 'Annotations')
annopath = os.path.join(VOC_test_root, 'VOC2007', 'Annotations','{:s}.xml')
print(annopath.format('123456'))
print(apath)

运行这段代码发现使用format会丢失路径,结果如下 123456.xml ./data/voc\VOC2007\Annotations 正常的结果应该是./data/voc\VOC2007\Annotations\123456.xml

mastergao57 avatar Apr 11 '22 05:04 mastergao57

Thank you for your interest in my project.

From your descriptions above, IMO, maybe this part {:s}.xml didn't work.

You can modify it to: f"{your_variable}.xml"

pprp avatar Apr 18 '22 02:04 pprp