66、将同图片下的多个不同类别的xml标注文件合并成一个xml标注文件-labelImg格式

基本思想:手中有一套抽烟的数据集是labelimg格式,但是没有人物标注的数据集,因此使用自动化标注脚本将图片过滤一边,进行生成labelimg文件,只含有80类别的人物标注xml,然后使用脚本将生成标注的人物xml和手中有的抽烟xml进行合并,生成一份xml文件

代码

# -*- coding: utf-8 -*-
import glob

import xml.etree.ElementTree as ET
import os
from xml.etree.ElementTree import parse, Element

path_0 = '/home/ubuntu/Downloads/smoke-used/smoke/images/xml_file_0' #来自自动化生成人物xml标注文件
path_1 = '/home/ubuntu/Downloads/smoke-used/smoke/images/xml_file_1' #来自公开数据集抽烟的xml标注文件
destPath = "/home/ubuntu/Downloads/smoke-used/smoke/images/combine" #合并的xml标注文件 格式lableImg



xml_0=glob.glob(os.path.join(path_0,"*.xml"))
xml_1=glob.glob(os.path.join(path_1,"*.xml"))

for item_0 in xml_0:
    name_0=os.path.split(item_0)
    for item_1 in xml_1:
        name_1 = os.path.split(item_1)
        new_location=os.path.join(destPath,name_1[-1])
        if name_1[-1]==name_0[-1]:

            

最近更新

  1. TCP协议是安全的吗?

    2024-03-24 20:20:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-24 20:20:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-24 20:20:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-24 20:20:01       20 阅读

热门阅读

  1. 设计模式-单例模式(模拟面试官八股)

    2024-03-24 20:20:01       23 阅读
  2. 使用 Python 读取 Word 文件

    2024-03-24 20:20:01       19 阅读
  3. LeetCode hot100-16

    2024-03-24 20:20:01       17 阅读
  4. LEETCODE-DAY31

    2024-03-24 20:20:01       18 阅读
  5. MONSD和SSD的区别

    2024-03-24 20:20:01       20 阅读
  6. 新概念英语1:Lesson11学习笔记

    2024-03-24 20:20:01       17 阅读
  7. ChatGPT:提升论文写作能力

    2024-03-24 20:20:01       20 阅读
  8. Rust 语言中 Vec 的元素的删除方法

    2024-03-24 20:20:01       21 阅读
  9. 【深度学习】NestedTensors

    2024-03-24 20:20:01       18 阅读
  10. ubuntu安装k8s

    2024-03-24 20:20:01       19 阅读