zoukankan      html  css  js  c++  java
  • 数据集

    # 删除无关的XML文件和jpg文件
    #所有的类型
    # 需要识别的类型包括 bicycle,bus,car,person
    import os
    import re
    import shutil
    items=['aeroplane','bird','boat','bottle','cat','chair','cow','diningtable','dog','horse','motorbike','pottedplant','sheep','sofa','train','tvmonitor']
    years=['VOC2007','VOC2012']
    
    for item in items:
        pattern=r'[sS]*<name>'+item+'</name>[sS]*'
        for year in years:
        #     imagedir=os.listdir('./VOCdevkit/'+year+'/JPEGImages')
            xmldirs=os.listdir('./VOCdevkit/'+year+'/Annotations')
            for xmldir in xmldirs:
                f=open('./VOCdevkit/'+year+'/Annotations/'+xmldir)
                xmlhasperson=False
                lines=f.readlines()
                for line in lines:
                    if re.match(pattern, line,flags=0):
                        xmlhasperson=True
                f.close()
                if xmlhasperson:
                    os.remove('./VOCdevkit/'+year+'/Annotations/'+xmldir)
                    os.remove('./VOCdevkit/'+year+'/JPEGImages/'+xmldir[:-4]+'.jpg')
    
        #             person_list.append(xmldir[:-4])
        #             shutil.copyfile('./VOCdevkit/'+year+'/Annotations/'+xmldir,'./result/VOCdevkit/'+year+'/Annotations/'+xmldir) 
        #             shutil.copyfile('./VOCdevkit/'+year+'/JPEGImages/'+xmldir[:-4]+'.jpg','./result/VOCdevkit/'+year+'/JPEGImages/'+xmldir[:-4]+'.jpg') 
                
            
  • 相关阅读:
    css命名书写规范小结。
    不断学习,充实自己。
    【openGL】画正弦函数图像
    【openGL】画五角星
    【openGL】画圆
    【openGL】画直线
    【网络资料】Astar算法详解
    【Agorithm】一次一密加密解密算法
    【HTML5】 web上的音频
    【sicily】卡片游戏
  • 原文地址:https://www.cnblogs.com/zhoulixue/p/6776080.html
Copyright © 2011-2022 走看看