import os
# input_dir='D:\\Users\\FPN\\FPN_Tensorflow-master\\tools\\test\\Annotations'
input_dir='D:\\Users\\FPN\\FPN_Tensorflow-master\\VOCdevkit\\train\\Annotations'
import xml.etree.ElementTree as ET
import xml.dom.minidom
n = 0
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
for filename in os.listdir(input_dir):
file_path = os.path.join(input_dir, filename)
dom = ET.parse(file_path)
root = dom.getroot()
for obj in root.iter('object'): # 获取object节点中的name子节点
#tmp_name = obj.find('name').text
if obj.find('name').text =='crack':
n=n+1
elif obj.find('name').text=='finger':
a=a+1
elif obj.find('name').text=='black_heart':
b=b+1
# elif obj.find('name').text=='ic':
目标检测——计算voc数据集中每一类的标注框的数量
最新推荐文章于 2023-03-08 14:36:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)