91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

一個WiderFace數據集標注格式轉VOC標注格式的工具,方便進行目標檢測的訓練

資源截圖

代碼片段和文件信息

import?scipy.io?as?sio
import?numpy?as?np
import?cv2
import?matplotlib.pyplot?as?plt
import?xml.dom.minidom?as?minidom
import?os
import?shutil?


def?Write_xml(image_shapeface_boxexpressionilluminationinvalidposeocclusionblurxml_namedata_name):
????
????doc=minidom.Document()
????root=doc.createElement(“annotation“)
????doc.appendChild(root)

????filename?=?doc.createElement(‘filename‘)
????filename_text?=?doc.createTextNode(data_name)
????filename.appendChild(filename_text)
????root.appendChild(filename)

????database?=?doc.createElement(‘database‘)
????database_text?=?doc.createTextNode(‘WIDER_Face‘)
????database.appendChild(database_text)
????root.appendChild(database)

????size?=?doc.createElement(‘size‘)

????width?=?doc.createElement(‘width‘)
????width_text?=?doc.createTextNode(‘%d‘%image_shape[1])
????width.appendChild(width_text)
????size.appendChild(width)

????height?=?doc.createElement(‘height‘)
????height_text?=?doc.createTextNode(‘%d‘%image_shape[0])
????height.appendChild(height_text)
????size.appendChild(height)

????depth?=?doc.createElement(‘width‘)
????depth_text?=?doc.createTextNode(‘%d‘%image_shape[2])
????depth.appendChild(depth_text)
????size.appendChild(depth)

????root.appendChild(size)

????i?=?0
????for?bbox?in?face_box:
????????object_?=?doc.createElement(‘object‘)

????????name?=?doc.createElement(‘name‘)
????????name_text?=?doc.createTextNode(‘face‘)
????????name.appendChild(name_text)
????????object_.appendChild(name)

????????difficult?=?doc.createElement(‘difficult‘)
????????difficult_text?=?doc.createTextNode(‘0‘)
????????difficult.appendChild(difficult_text)
????????object_.appendChild(difficult)

????????if?bbox[0]?<=?0:
????????????bbox[0]?=?bbox[0]?+?1
????????????bbox[2]?=??bbox[2]?-?1

????????if?bbox[1]?<=?0:
????????????bbox[1]?=?bbox[1]?+?1
????????????bbox[3]?=?bbox[3]?-?1

????????if?bbox[0]?+?bbox[2]?>=?image_shape[1]:
????????????bbox[2]?=??bbox[2]?-?1

????????if?bbox[1]?+?bbox[3]?>=?image_shape[0]:
????????????bbox[3]?=?bbox[3]?-?1

????????bndbox?=?doc.createElement(‘bndbox‘)
????????xmin?=?doc.createElement(‘xmin‘)

????????xmin_text?=?doc.createTextNode(‘%d‘%bbox[0])
????????xmin.appendChild(xmin_text)
????????bndbox.appendChild(xmin)

????????ymin?=?doc.createElement(‘ymin‘)
????????ymin_text?=?doc.createTextNode(‘%d‘%bbox[1])
????????ymin.appendChild(ymin_text)
????????bndbox.appendChild(ymin)

????????xmax?=?doc.createElement(‘xmax‘)
????????xmax_text?=?doc.createTextNode(‘%d‘%(bbox[0]?+?bbox[2]))
????????xmax.appendChild(xmax_text)
????????bndbox.appendChild(xmax)

????????ymax?=?doc.createElement(‘ymax‘)
????????ymax_text?=?doc.createTextNode(‘%d‘%(bbox[1]?+?bbox[3]))
????????ymax.appendChild(ymax_text)
????????bndbox.appendChild(ymax)

????????object_.appendChild(bndbox)
????
????????root.appendChild(object_)


????with?open(xml_name‘w‘)?as?xml_file:
????????doc.writexml(xml_fileindent?=?‘\t‘newl?=?‘\n‘?addindent?=?‘\t‘encoding=‘utf-8‘)
????xml_file.close()

????


def?Show_re

評論

共有 條評論