代码拉取完成,页面将自动刷新
同步操作将从 新无止竞/Ultra-Light-Fast-Generic-Face-Detector-1MB 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""
This code is used to check the data size distribution in the dataset.
"""
import xml.etree.ElementTree as ET
from math import sqrt as sqrt
import cv2
import matplotlib.pyplot as plt
# sets = [("./data/wider_face_add_lm_10_10", "trainval")]
sets = [("./data/wider_face_add_lm_10_10", "test")]
classes = ['face']
if __name__ == '__main__':
width = []
height = []
for image_set, set in sets:
image_ids = open('{}/ImageSets/Main/{}.txt'.format(image_set, set)).read().strip().split()
for image_id in image_ids:
img_path = '{}/JPEGImages/{}.jpg'.format(image_set, image_id)
label_file = open('{}/Annotations/{}.xml'.format(image_set, image_id))
tree = ET.parse(label_file)
root = tree.getroot()
size = root.find('size')
img_w = int(size.find('width').text)
img_h = int(size.find('height').text)
img = cv2.imread(img_path)
for obj in root.iter('object'):
difficult = obj.find('difficult').text
cls = obj.find('name').text
if cls not in classes or int(difficult) == 2:
continue
cls_id = classes.index(cls)
xmlbox = obj.find('bndbox')
xmin = int(xmlbox.find('xmin').text)
ymin = int(xmlbox.find('ymin').text)
xmax = int(xmlbox.find('xmax').text)
ymax = int(xmlbox.find('ymax').text)
w = xmax - xmin
h = ymax - ymin
# img = cv2.rectangle(img, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (0, 255, 0), 8)
w_change = (w / img_w) * 320
h_change = (h / img_h) * 240
s = w_change * h_change
if w_change / h_change > 6:
print("{}/{}/{}/{}".format(xmin, xmax, ymin, ymax))
width.append(sqrt(s))
height.append(w_change / h_change)
print(img_path)
# img = cv2.resize(img, (608, 608))
# cv2.imwrite('{}_{}'.format(image_set.split('/')[-1], set), img)
# cv2.waitKey()
plt.plot(width, height, 'ro')
plt.show()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。