前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PaddingFIFOQueue '_1_get_batch/batch/padding_fifo_queue'

PaddingFIFOQueue '_1_get_batch/batch/padding_fifo_queue'

作者头像
狼啸风云
修改2022-09-04 21:56:02
1.4K0
修改2022-09-04 21:56:02
举报

博主在用原始的NWPU VHR-10数据集进行训练的时候遇到这个错误,最后发现是原始数据集中的标签文件的长和宽被统一成了256x256,与实际图片的尺寸不符合就会引发这个错误,将xml文件中的width和height设置为真实值就可以了。代码如下:

代码语言:javascript
复制
from xml.etree.ElementTree import ElementTree,Element
import os
import cv2
 
def read_xml(in_path):
    tree = ElementTree()
    tree.parse(in_path)
    return tree
 
 
if __name__ == '__main__':
  source_pic_root_path = '/home/user8/Desktop/Calculate the size of target/nwpu/JPEGImages/'
  source_xml_root_path = '/home/user8/Desktop/Calculate the size of target/nwpu/Annotations/'
  for parent, _, files in os.walk(source_pic_root_path):
    for file in files:
        pic_path = os.path.join(parent, file)
        img = cv2.imread(pic_path)
        size = img.shape
        xml_path = os.path.join(source_xml_root_path, file[:-4] + '.xml')
        tree = read_xml(xml_path)
        root = tree.getroot()
        for h_node in root.iter('height'):
            height = str(size[0])
            h_node.text = height
 
        for w_node in root.iter('width'):
            width = str(size[1])
            w_node.text = width
        tree.write(xml_path)

出现这种错误一般都不是代码的问题。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年05月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档