未验证 提交 b0b089b8 编写于 作者: S SunAhong1993 提交者: GitHub

Update voc.py

上级 1ec46f7b
...@@ -72,9 +72,9 @@ class VOCDetection(Dataset): ...@@ -72,9 +72,9 @@ class VOCDetection(Dataset):
label_id = 1 label_id = 1
with open(label_list, 'r', encoding=get_encoding(label_list)) as fr: with open(label_list, 'r', encoding=get_encoding(label_list)) as fr:
for line in fr.readlines(): for line in fr.readlines():
cname2cid[line[:-1]] = label_id cname2cid[line.strip()]] = label_id
label_id += 1 label_id += 1
self.labels.append(line[:-1]) self.labels.append(line.strip())
logging.info("Starting to read file list from dataset...") logging.info("Starting to read file list from dataset...")
for k, v in cname2cid.items(): for k, v in cname2cid.items():
annotations['categories'].append({ annotations['categories'].append({
...@@ -124,7 +124,7 @@ class VOCDetection(Dataset): ...@@ -124,7 +124,7 @@ class VOCDetection(Dataset):
for i, obj in enumerate(objs): for i, obj in enumerate(objs):
pattern = re.compile('<name>', re.IGNORECASE) pattern = re.compile('<name>', re.IGNORECASE)
name_tag = pattern.findall(str(ET.tostringlist(obj)))[0][1:-1] name_tag = pattern.findall(str(ET.tostringlist(obj)))[0][1:-1]
cname = obj.find(name_tag).text cname = obj.find(name_tag).text.strip()
gt_class[i][0] = cname2cid[cname] gt_class[i][0] = cname2cid[cname]
pattern = re.compile('<difficult>', re.IGNORECASE) pattern = re.compile('<difficult>', re.IGNORECASE)
diff_tag = pattern.findall(str(ET.tostringlist(obj)))[0][1:-1] diff_tag = pattern.findall(str(ET.tostringlist(obj)))[0][1:-1]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册