資源簡介
提取深度學習目標檢測標注文件xml文件中的目標的坐標,并保存到txt文件中,批量讀取
代碼片段和文件信息
#?coding=utf-8
#?讀xml文件中的一個rect
import?xml.etree.ElementTree?as?ET
import?sys
import?importlib
importlib.reload(sys)
import?os
image_dir?=?‘G:/FasterRcnn/exesize/Annotations/‘
for?image_name?in?os.listdir(image_dir):
????base_name?=?image_name[0:-4]
????tree?=?ET.parse(os.path.join(image_dir?image_name))
????rect={}
????line=““
????root?=?tree.getroot()
????f1?=?open(‘G:/FasterRcnn/exesize/%s.txt‘%(base_name)?‘w‘)
????for?name?in?root.iter(‘filename‘):
????????rect[‘path‘]?=?name.text
????for?ob?in?root.iter(‘ob
- 上一篇:美圖錄爬蟲(python源碼)
- 下一篇:python批量提取 龍源期刊文檔
評論
共有 條評論