yoloX模型默认运行到10个epoch有一个测试,然后我是在测试的时候报错,报错位置在voc_eval.py文件下,相对位置为:
yolox/evaluators/voc_eval.py
报这个错主要原因是标签文件.xml中没有difficult这个类,我们可以直接简单粗暴地注释掉报错行24,即
# obj_struct["difficult"] = int(obj.find("difficult").text)
但是如果直接这样还是会报错,因为下面还是用到了difficult类。大约在100-110行的位置
# extract gt objects for this class
class_recs = {}
npos = 0
for imagename in imagenames:
R = [obj for obj in recs[imagename] if obj["name"] == classname]
bbox = np.array([x["bbox"] for x in R])
difficult = np.array([x["difficult"] for x in R]).astype(np.bool)
det = [False] * len(R)
npos = npos + sum(~difficult)
class_recs[imagename] = {"bbox": bbox, "difficult": difficult, "det": det}
因为difficult类是用来判断该object是不是困难样本的,我们如果xml里面没有这个类,那我们可以认为所有object都是不困难的。因此可以这样改:
# extract gt objects for this class
class_recs = {}
npos = 0
for imagename in imagenames:
R = [obj for obj in recs[imagename] if obj["name"] == classname]
bbox = np.array([x["bbox"] for x in R])
# difficult = np.array([x["difficult"] for x in R]).astype(np.bool)
difficult = np.array([0 for x in R]).astype(np.bool)
det = [False] * len(R)
npos = npos + sum(~difficult)
class_recs[imagename] = {"bbox": bbox, "difficult": difficult, "det": det}
这样就OK了。