最后修改COCO128.yaml文件

数据集处理
解压图像
先解压
tar -xvf ILSVRC2012_img_train.tar
解压之后其实还是1000个tar压缩包(对应1000个类别),需要再次解压 , 解压脚本unzip.sh如下(PS:可能需要自己改一下目录 dir ):
(这里也可以用解压软件一键解压)
批量解压脚本
dir=./train for x in `ls $dir/*tar` dofilename=`basename $x .tar`mkdir $dir/$filenametar -xvf $x -C $dir/$filename done rm *.tar
执行 sh 脚本
chmod 777 unzip.sh./ unzip.sh
报错:./unzip.sh: line 3:error neartoken = $x .tar`’
直接使用指令ls *.tar | xargs -n1 tar xvf
将当前文件夹下的tar解压linux批量解压方法
或者:
批量解压zip文件
import osimport shutilimport zipfile# 首先引入需要的工具包# shutil为后期移动文件所需,可以忽略此项 # 路径改这里!#parent_path = r'输入路径 , 会解压该路径下的所有zip压缩文件'parent_path = r'E:\py\python3.7\test\test99\zip' # 文件类型选择# 可以自行更改压缩文件类型,需要引入其它工具包,如tarfile等# 这里是因为在自己的windows上,zip比较常见,其他类型请自行更改file_flag = '.zip'#修改需解压的格式 例如:.rar# 删除已解压的zip文件# 不建议初次使用,在确定程序无误后可以添加使用def del_old_zip(file_path):os.remove(file_path)# 解压def decompress(file_path, root):# 开始# zipfile打开zip文件z = zipfile.ZipFile(f'{file_path}', 'r') # 解压z.extractall(path=f"{root}")# path为解压路径,解包后位于该路径下 # 判断是否需要重复解包for names in z.namelist():if names.endswith(file_flag):z.close()return 1 # 结束z.close() return 0# 因为我在使用过程中发现有些zip解包后会混在一起# 在平时大家手动解压时可能也会遇到提示是否覆盖的问题# 下面的两个函数解决这一问题 # 开始要先创建一个大文件夹与压缩包名字相同# 避免后期混乱和麻烦def start_dir_make(root, dirname):os.chdir(root)os.mkdir(dirname)return os.path.join(root, dirname) # 去除多余文件夹def rem_dir_extra(root, father_dir_name):# 递归要注意信息的正常处理搞不好上一个调用已经改变了东西而下面的调用还是使用之前的数据 try: # 判断文件夹重名开始for item in os.listdir(os.path.join(root, father_dir_name)): # 第一步判断是不是一个文件夹,如果不是则跳过本次循环if not os.path.isdir(os.path.join(root, father_dir_name, item)):continue # 判断是否要脱掉一层目录结构# 文件夹名字要相同,且子目录中只有单独的一个文件夹if item == father_dir_name and len(os.listdir(os.path.join(root, father_dir_name))) == 1: # 改变工作目录os.chdir(root)# 将无用文件夹重命名,因为直接移动会有重名错误os.rename(father_dir_name, father_dir_name + '-old')# 移动文件后删除空文件夹shutil.move(os.path.join(root, father_dir_name + '-old', item), os.path.join(root))os.rmdir(os.path.join(root, father_dir_name + '-old')) # 将去掉一层目录结构后的文件夹继续作为父本递归处理下去# 这里要注意,上面已经发生过数据的改动,所以下面递归传参一定要正确!rem_dir_extra(root, item) else: # 处理那些不满足上面条件的文件夹rem_dir_extra(os.path.join(root, father_dir_name), item) except Exception as e: # 打印错误信息print("清除文件夹出错" + str(e)) # 入口if __name__ == '__main__': flag = 1 while flag: #循环遍历文件夹for root, dirs, files in os.walk(parent_path): # 读取文件名for name in files:if name.endswith(file_flag): # 创建文件夹new_ws = start_dir_make(root, name.replace(file_flag, '')) # zip文件地址zip_path = os.path.join(root, name) # 解压flag = decompress(zip_path, new_ws) # 删除解压后的文件# 有点危险# 但不删除又可能会重复运行# 一定要备份或先测试,不然可能会凉,自己选择修改del_old_zip(zip_path) # 去掉多余的文件结构rem_dir_extra(root, name.replace(file_flag, '')) print(f'{root}\\{name}'.join(['文件:', '\n解压完成\n']))# 由于解压可能解了好几次 所以可能会有已经解压好的父级目录重名无法处理 这里要再处理一次rem_dir_extra(os.path.split(parent_path)[0], os.path.split(parent_path)[1])print("解压完成啦,记得检查有没有zip格式之外的呀!\n\n其他格式需要自己改一下了")
查看文件夹下文件数量
ls -l|grep "^-" |wc -l
统计文件名中包含某个名称()的文件的文件总数
find -name "n15075141_*" | wc -l
这里我使用这官方提供的脚本文件
#!/bin/bash## script to extract ImageNet dataset# ILSVRC2012_img_train.tar (about 138 GB)# ILSVRC2012_img_val.tar (about 6.3 GB)# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory##Adapted from:#https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md#https://gist.github.com/BIGBALLON/8a71d225eff18d88e469e6ea9b39cef4# #imagenet/train/#├── n01440764#│├── n01440764_10026.JPEG#│├── n01440764_10027.JPEG#│├── ......#├── ......#imagenet/val/#├── n01440764#│├── ILSVRC2012_val_00000293.JPEG#│├── ILSVRC2012_val_00002138.JPEG#│├── ......#├── ......### Make imagnet directory#mkdir imagenet## Extract the training data:## Create train directory; move .tar file; change directorymkdir imagenet/train && mv ILSVRC2012_img_train.tar imagenet/train/ && cd imagenet/train# Extract training set; remove compressed filetar -xvf ILSVRC2012_img_train.tar && rm -f ILSVRC2012_img_train.tar## At this stage imagenet/train will contain 1000 compressed .tar files, one for each category## For each .tar file: #1. create directory with same name as .tar file#2. extract and copy contents of .tar file into directory#3. remove .tar filefind . -name "*.tar" | while read NAME ; do mkdir -p "${NAME%.tar}"; tar -xvf "${NAME}" -C "${NAME%.tar}"; rm -f "${NAME}"; done## This results in a training directory like so:##imagenet/train/#├── n01440764#│├── n01440764_10026.JPEG#│├── n01440764_10027.JPEG#│├── ......#├── ......## Change back to original directorycd ../..## Extract the validation data and move images to subfolders:## Create validation directory; move .tar file; change directory; extract validation .tar; remove compressed filemkdir imagenet/val && mv ILSVRC2012_img_val.tar imagenet/val/ && cd imagenet/val && tar -xvf ILSVRC2012_img_val.tar && rm -f ILSVRC2012_img_val.tar# get script from soumith and run; this script creates all class directories and moves images into corresponding directorieswget -qO- https://raw.githubusercontent.com/soumith/imagenetloader.torch/master/valprep.sh | bash## This results in a validation directory like so:##imagenet/val/#├── n01440764#│├── ILSVRC2012_val_00000293.JPEG#│├── ILSVRC2012_val_00002138.JPEG#│├── ......#├── ......### Check total files after extract##$ find train/ -name "*.JPEG" | wc -l#1281167#$ find val/ -name "*.JPEG" | wc -l#50000#
参考文章
具体类别如下1000类信息
处理标签和图像
因为标签很少 , 图像较多,只有部分图像有标签对应,所以需要删除多余的图像 。
数据集目录结构如下
先查看一下类别信息
在2中的meta.mat文件中存放着类型信息(1000)类
配置
下通过命令打开图片
xdg-open n02098286_4811.JPEG
在一个文件夹下就是一类的
将标签全部复制到ann下

最后修改COCO128.yaml文件

文章插图
遍历文件夹下的所有子文件夹,并将指定的文件复制到指定目录
# coding: utf-8from PIL import Image, ImageDraw, ImageFontimport osimport shutilimport cv2 as cvimport numpy as npimport json#批量复制# 为了防止重名覆盖问题 , 先使用改名软件将文件名全部改了def batchCopy(src,des,suffix):print("封装代码")for root, dirs, files in os.walk(src):print(root)all_files = os.listdir(root)filtered_files = [file for file in all_files if file.endswith(suffix)]# 遍历原文件夹中的文件if (len(filtered_files)):for i in range(len(files)):full_file_name = root+"/"+files[i]print("要被复制的全文件路径全名:", full_file_name)shutil.copy(full_file_name, des)# shutil.copy函数放入原文件的路径文件全名然后放入目标文件夹if __name__ == "__main__":src = "http://www.kingceram.com/home/ubuntu/data/ilsvrc2012/ILSVRC2012_img_train_new/imagenet/val"# 原文件夹路径des = "/home/ubuntu/data/ilsvrc2012/imageval"# 目标文件夹路径suffix = ".JPEG"batchCopy(src,des,suffix)
删除两文件夹多出的文件,两文件夹文件后缀名不同,单个文件夹有多个后缀名文件
参考代码
就是图片比标签多,将多余的图片删除,使得图片和标签数量一一对应
# encoding:utf-8import osimport os.path# 删除pic_dir中比txt_dir多出的文件pic_dir = 'D:\\dataset\\total'# 你的图片文件夹路径txt_dir = 'D:\\dataset\\ann'# 你的标签文件夹路径def txt(rootdir):a = []for parent, dirnames, filenames in os.walk(rootdir):for filenames in filenames:filenames = filenames.split('.')[0]# 获取无后缀名的文件名称a.append(filenames)return adef pic(rootdir):b = []for parent, dirnames, filenames in os.walk(rootdir):for filenames in filenames:filenames = filenames.split('.')[0]# 获取无后缀名的文件名称b.append(filenames)return bif __name__ == '__main__':txt_set = txt(txt_dir)txt_set = set(txt_set)# 删除txt_set中的重复pic_set = pic(pic_dir)pic_set = set(pic_set)# 删除pic_set中的重复# comp=txt_set-pic_setcomp = pic_set - txt_set# 图片比标注多时,进行做差print("ok")print(len(comp))for item in comp:# 删去这些无标注的图片for root, dirs, files in os.walk(pic_dir):for file in files:filename = file.split('.')[0]# 获取无后缀名的文件名称if item == filename:os.remove(pic_dir + '/' + file)# file = pic_dir + '/' + item + '.png' #删除pic_dir中多出的文件# if os.path.exists(file):#os.remove(file)#print(file)
这种方法删除很慢,特别是有70W张图片待删除
高效删除多余图片方法
效果:
统计待删除txt文件的行数
file_path = '/home/ubuntu/code/yolov8-pytorch-master/myDel.txt'# 替换成你的文本文件路径with open(file_path, 'r') as file:lines = file.readlines()num_lines = len(lines)print("文本文件的行数:", num_lines)
待删除图像张(半分钟就找出来了)
后缀转换后:
VOC转YOLO
提供了标签是xml的 , 就和voc是一样的
首先获取类别信息文件(.txt)
0 n01440764 tench 鱼1 n01443537 goldfish 鱼2 n01484850 great_white_shark 鱼3 n01491361 tiger_shark 鱼4 n01494475 hammerhead 鱼5 n01496331 electric_ray 鱼6 n01498041 stingray 鱼7 n01514668 cock 鸡8 n01514859 hen 鸡9 n01518878 ostrich 鸵鸟10 n01530575 brambling 鸟11 n01531178 goldfinch 鸟12 n01532829 house_finch 鸟13 n01534433 junco 鸟14 n01537544 indigo_bunting 鸟15 n01558993 robin 鸟16 n01560419 bulbul 鸟17 n01580077 jay 鸟18 n01582220 magpie 鸟19 n01592084 chickadee 鸟20 n01601694 water_ouzel 鸟21 n01608432 kite 鸟22 n01614925 bald_eagle 鹰23 n01616318 vulture 鹰24 n01622779 great_grey_owl 猫头鹰25 n01629819 European_fire_salamander 壁虎26 n01630670 common_newt 壁虎27 n01631663 eft 壁虎28 n01632458 spotted_salamander 壁虎29 n01632777 axolotl 壁虎30 n01641577 bullfrog 蛤蟆31 n01644373 tree_frog 青蛙32 n01644900 tailed_frog 青蛙33 n01664065 loggerhead 龟34 n01665541 leatherback_turtle 龟35 n01667114 mud_turtle 龟36 n01667778 terrapin 龟37 n01669191 box_turtle 龟38 n01675722 banded_gecko 蜥蜴39 n01677366 common_iguana 蜥蜴40 n01682714 American_chameleon 蜥蜴41 n01685808 whiptail 蜥蜴42 n01687978 agama 蜥蜴43 n01688243 frilled_lizard 蜥蜴44 n01689811 alligator_lizard 蜥蜴45 n01692333 Gila_monster 蜥蜴46 n01693334 green_lizard 蜥蜴47 n01694178 African_chameleon 蜥蜴48 n01695060 Komodo_dragon 蜥蜴49 n01697457 African_crocodile 鳄鱼50 n01698640 American_alligator 鳄鱼51 n01704323 triceratops 恐龙52 n01728572 thunder_snake 蛇53 n01728920 ringneck_snake 蛇54 n01729322 hognose_snake 蛇55 n01729977 green_snake 蛇56 n01734418 king_snake 蛇57 n01735189 garter_snake 蛇58 n01737021 water_snake 蛇59 n01739381 vine_snake 蛇60 n01740131 night_snake 蛇61 n01742172 boa_constrictor 蛇62 n01744401 rock_python 蛇63 n01748264 Indian_cobra 蛇64 n01749939 green_mamba 蛇65 n01751748 sea_snake 蛇66 n01753488 horned_viper 蛇67 n01755581 diamondback 蛇68 n01756291 sidewinder 蛇69 n01768244 trilobite 化石70 n01770081 harvestman 蜘蛛71 n01770393 scorpion 蝎子72 n01773157 black_and_gold_garden_spider 蜘蛛73 n01773549 barn_spider 蜘蛛74 n01773797 garden_spider 蜘蛛75 n01774384 black_widow 蜘蛛76 n01774750 tarantula 蜘蛛77 n01775062 wolf_spider 蜘蛛78 n01776313 tick 蜘蛛79 n01784675 centipede 蜈蚣80 n01795545 black_grouse 鸟81 n01796340 ptarmigan 鸟82 n01797886 ruffed_grouse 鸟83 n01798484 prairie_chicken 鸟84 n01806143 peacock 孔雀85 n01806567 quail 鸟86 n01807496 partridge 鸟87 n01817953 African_grey 鸟88 n01818515 macaw 鸟89 n01819313 sulphur-crested_cockatoo 鸟90 n01820546 lorikeet 鸟91 n01824575 coucal 鸟92 n01828970 bee_eater 鸟93 n01829413 hornbill 鸟94 n01833805 hummingbird 鸟95 n01843065 jacamar 鸟96 n01843383 toucan 鸟97 n01847000 drake 鸭子98 n01855032 red-breasted_merganser 鹅99 n01855672 goose 鹅100 n01860187 black_swan 鹅101 n01871265 tusker 大象102 n01872401 echidna 刺猬103 n01873310 platypus 鸭嘴兽104 n01877812 wallaby 袋鼠105 n01882714 koala 考拉106 n01883070 wombat 土拨鼠107 n01910747 jellyfish 水母108 n01914609 sea_anemone 珊瑚109 n01917289 brain_coral 珊瑚110 n01924916 flatworm 海洋生物111 n01930112 nematode 海蛇112 n01943899 conch 海螺113 n01944390 snail 蜗牛114 n01945685 slug 蜗牛115 n01950731 sea_slug 海洋生物116 n01955084 chiton 海洋生物117 n01968897 chambered_nautilus 海螺118 n01978287 Dungeness_crab 螃蟹119 n01978455 rock_crab 螃蟹120 n01980166 fiddler_crab 螃蟹121 n01981276 king_crab 螃蟹122 n01983481 American_lobster 龙虾123 n01984695 spiny_lobster 龙虾124 n01985128 crayfish 龙虾125 n01986214 hermit_crab 寄居蟹126 n01990800 isopod 海洋生物127 n02002556 white_stork 鸟128 n02002724 black_stork 鸟129 n02006656 spoonbill 鸟130 n02007558 flamingo 鸟131 n02009229 little_blue_heron 鸟132 n02009912 American_egret 鸟133 n02011460 bittern 鸟134 n02012849 crane 鸟135 n02013706 limpkin 鸟136 n02017213 European_gallinule 鸟137 n02018207 American_coot 鸟138 n02018795 bustard 鸟139 n02025239 ruddy_turnstone 鸟140 n02027492 red-backed_sandpiper 鸟141 n02028035 redshank 鸟142 n02033041 dowitcher 鸟143 n02037110 oystercatcher 鸟144 n02051845 pelican 鸟145 n02056570 king_penguin 企鹅146 n02058221 albatross 鸟147 n02066245 grey_whale 鲸鱼148 n02071294 killer_whale 鲸鱼149 n02074367 dugong 海象150 n02077923 sea_lion 海狮151 n02085620 Chihuahua 狗152 n02085782 Japanese_spaniel 狗153 n02085936 Maltese_dog 狗154 n02086079 Pekinese 狗155 n02086240 Shih-Tzu 狗156 n02086646 Blenheim_spaniel 狗157 n02086910 papillon 狗158 n02087046 toy_terrier 狗159 n02087394 Rhodesian_ridgeback 狗160 n02088094 Afghan_hound 狗161 n02088238 basset 狗162 n02088364 beagle 狗163 n02088466 bloodhound 狗164 n02088632 bluetick 狗165 n02089078 black-and-tan_coonhound 狗166 n02089867 Walker_hound 狗167 n02089973 English_foxhound 狗168 n02090379 redbone 狗169 n02090622 borzoi 狗170 n02090721 Irish_wolfhound 狗171 n02091032 Italian_greyhound 狗172 n02091134 whippet 狗173 n02091244 Ibizan_hound 狗174 n02091467 Norwegian_elkhound 狗175 n02091635 otterhound 狗176 n02091831 Saluki 狗177 n02092002 Scottish_deerhound 狗178 n02092339 Weimaraner 狗179 n02093256 Staffordshire_bullterrier 狗180 n02093428 American_Staffordshire_terrier 狗181 n02093647 Bedlington_terrier 狗182 n02093754 Border_terrier 狗183 n02093859 Kerry_blue_terrier 狗184 n02093991 Irish_terrier 狗185 n02094114 Norfolk_terrier 狗186 n02094258 Norwich_terrier 狗187 n02094433 Yorkshire_terrier 狗188 n02095314 wire-haired_fox_terrier 狗189 n02095570 Lakeland_terrier 狗190 n02095889 Sealyham_terrier 狗191 n02096051 Airedale 狗192 n02096177 cairn 狗193 n02096294 Australian_terrier 狗194 n02096437 Dandie_Dinmont 狗195 n02096585 Boston_bull 狗196 n02097047 miniature_schnauzer 狗197 n02097130 giant_schnauzer 狗198 n02097209 standard_schnauzer 狗199 n02097298 Scotch_terrier 狗200 n02097474 Tibetan_terrier 狗201 n02097658 silky_terrier 狗202 n02098105 soft-coated_wheaten_terrier 狗203 n02098286 West_Highland_white_terrier 狗204 n02098413 Lhasa 狗205 n02099267 flat-coated_retriever 狗206 n02099429 curly-coated_retriever 狗207 n02099601 golden_retriever 狗208 n02099712 Labrador_retriever 狗209 n02099849 Chesapeake_Bay_retriever 狗210 n02100236 German_short-haired_pointer 狗211 n02100583 vizsla 狗212 n02100735 English_setter 狗213 n02100877 Irish_setter 狗214 n02101006 Gordon_setter 狗215 n02101388 Brittany_spaniel 狗216 n02101556 clumber 狗217 n02102040 English_springer 狗218 n02102177 Welsh_springer_spaniel 狗219 n02102318 cocker_spaniel 狗220 n02102480 Sussex_spaniel 狗221 n02102973 Irish_water_spaniel 狗222 n02104029 kuvasz 狗223 n02104365 schipperke 狗224 n02105056 groenendael 狗225 n02105162 malinois 狗226 n02105251 briard 狗227 n02105412 kelpie 狗228 n02105505 komondor 狗229 n02105641 Old_English_sheepdog 狗230 n02105855 Shetland_sheepdog 狗231 n02106030 collie 狗232 n02106166 Border_collie 狗233 n02106382 Bouvier_des_Flandres 狗234 n02106550 Rottweiler 狗235 n02106662 German_shepherd 狗236 n02107142 Doberman 狗237 n02107312 miniature_pinscher 狗238 n02107574 Greater_Swiss_Mountain_dog 狗239 n02107683 Bernese_mountain_dog 狗240 n02107908 Appenzeller 狗241 n02108000 EntleBucher 狗242 n02108089 boxer 狗243 n02108422 bull_mastiff 狗244 n02108551 Tibetan_mastiff 狗245 n02108915 French_bulldog 狗246 n02109047 Great_Dane 狗247 n02109525 Saint_Bernard 狗248 n02109961 Eskimo_dog 狗249 n02110063 malamute 狗250 n02110185 Siberian_husky 狗251 n02110341 dalmatian 狗252 n02110627 affenpinscher 狗253 n02110806 basenji 狗254 n02110958 pug 狗255 n02111129 Leonberg 狗256 n02111277 Newfoundland 狗257 n02111500 Great_Pyrenees 狗258 n02111889 Samoyed 狗259 n02112018 Pomeranian 狗260 n02112137 chow 狗261 n02112350 keeshond 狗262 n02112706 Brabancon_griffon 狗263 n02113023 Pembroke 狗264 n02113186 Cardigan 狗265 n02113624 toy_poodle 狗266 n02113712 miniature_poodle 狗267 n02113799 standard_poodle 狗268 n02113978 Mexican_hairless 狗269 n02114367 timber_wolf 狼270 n02114548 white_wolf 狼271 n02114712 red_wolf 狼272 n02114855 coyote 狼273 n02115641 dingo 狼274 n02115913 dhole 狼275 n02116738 African_hunting_dog 狼276 n02117135 hyena 狼277 n02119022 red_fox 狐狸278 n02119789 kit_fox 狐狸279 n02120079 Arctic_fox 狐狸280 n02120505 grey_fox 狐狸281 n02123045 tabby 猫282 n02123159 tiger_cat 猫283 n02123394 Persian_cat 猫284 n02123597 Siamese_cat 猫285 n02124075 Egyptian_cat 猫286 n02125311 cougar 猫287 n02127052 lynx 猫288 n02128385 leopard 豹289 n02128757 snow_leopard 豹290 n02128925 jaguar 豹291 n02129165 lion 狮子292 n02129604 tiger 老虎293 n02130308 cheetah 豹294 n02132136 brown_bear 熊295 n02133161 American_black_bear 熊296 n02134084 ice_bear 熊297 n02134418 sloth_bear 熊298 n02137549 mongoose 猫鼬299 n02138441 meerkat 猫鼬300 n02165105 tiger_beetle 昆虫301 n02165456 ladybug 昆虫302 n02167151 ground_beetle 昆虫303 n02168699 long-horned_beetle 昆虫304 n02169497 leaf_beetle 昆虫305 n02172182 dung_beetle 昆虫306 n02174001 rhinoceros_beetle 昆虫307 n02177972 weevil 昆虫308 n02190166 fly 昆虫309 n02206856 bee 昆虫310 n02219486 ant 昆虫311 n02226429 grasshopper 昆虫312 n02229544 cricket 昆虫313 n02231487 walking_stick 昆虫314 n02233338 cockroach 昆虫315 n02236044 mantis 昆虫316 n02256656 cicada 昆虫317 n02259212 leafhopper 昆虫318 n02264363 lacewing 昆虫319 n02268443 dragonfly 蜻蜓320 n02268853 damselfly 蜻蜓321 n02276258 admiral 蝴蝶322 n02277742 ringlet 蝴蝶323 n02279972 monarch 蝴蝶324 n02280649 cabbage_butterfly 蝴蝶325 n02281406 sulphur_butterfly 蝴蝶326 n02281787 lycaenid 蝴蝶327 n02317335 starfish 海星328 n02319095 sea_urchin 海胆329 n02321529 sea_cucumber 海洋生物330 n02325366 wood_rabbit 兔子331 n02326432 hare 兔子332 n02328150 Angora 兔子333 n02342885 hamster 鼠334 n02346627 porcupine 鼠335 n02356798 fox_squirrel 松鼠336 n02361337 marmot 鼠337 n02363005 beaver 鼠338 n02364673 guinea_pig 鼠339 n02389026 sorrel 马340 n02391049 zebra 斑马341 n02395406 hog 猪342 n02396427 wild_boar 猪343 n02397096 warthog 猪344 n02398521 hippopotamus 河马345 n02403003 ox 牛346 n02408429 water_buffalo 牛347 n02410509 bison 牛348 n02412080 ram 羊349 n02415577 bighorn 羊350 n02417914 ibex 羊351 n02422106 hartebeest 羊352 n02422699 impala 羊353 n02423022 gazelle 羊354 n02437312 Arabian_camel 骆驼355 n02437616 llama 羊驼356 n02441942 weasel 狸357 n02442845 mink 狸358 n02443114 polecat 狸359 n02443484 black-footed_ferret 狸360 n02444819 otter 狸361 n02445715 skunk 狸362 n02447366 badger 狸363 n02454379 armadillo 穿山甲364 n02457408 three-toed_sloth 树懒365 n02480495 orangutan 狒狒366 n02480855 gorilla 猩猩367 n02481823 chimpanzee 猴子368 n02483362 gibbon 猴子369 n02483708 siamang 猴子370 n02484975 guenon 猴子371 n02486261 patas 猴子372 n02486410 baboon 猴子373 n02487347 macaque 猴子374 n02488291 langur 猴子375 n02488702 colobus 猴子376 n02489166 proboscis_monkey 猴子377 n02490219 marmoset 猴子378 n02492035 capuchin 猴子379 n02492660 howler_monkey 猴子380 n02493509 titi 猴子381 n02493793 spider_monkey 猴子382 n02494079 squirrel_monkey 猴子383 n02497673 Madagascar_cat 猴子384 n02500267 indri 猴子385 n02504013 Indian_elephant 大象386 n02504458 African_elephant 大象387 n02509815 lesser_panda 浣熊388 n02510455 giant_panda 熊猫389 n02514041 barracouta 鱼390 n02526121 eel 鱼391 n02536864 coho 鱼392 n02606052 rock_beauty 鱼393 n02607072 anemone_fish 鱼394 n02640242 sturgeon 鱼395 n02641379 gar 鱼396 n02643566 lionfish 鱼397 n02655020 puffer 鱼398 n02666196 abacus 算盘399 n02667093 abaya 穆斯林400 n02669723 academic_gown 学士服401 n02672831 accordion 手风琴402 n02676566 acoustic_guitar 吉他403 n02687172 aircraft_carrier 航空母舰404 n02690373 airliner 飞机405 n02692877 airship 飞艇406 n02699494 altar 教堂407 n02701002 ambulance 救护车408 n02704792 amphibian 水陆两用车409 n02708093 analog_clock 钟410 n02727426 apiary 箱子411 n02730930 apron 围裙412 n02747177 ashcan 垃圾箱413 n02749479 assault_rifle 枪414 n02769748 backpack 背包415 n02776631 bakery 面包柜416 n02777292 balance_beam 体操417 n02782093 balloon 热气球418 n02783161 ballpoint 钢笔419 n02786058 Band_Aid 邦迪420 n02787622 banjo 乐器421 n02788148 bannister 楼梯422 n02790996 barbell 杠铃423 n02791124 barber_chair 座椅424 n02791270 barbershop 理发425 n02793495 barn 木屋426 n02794156 barometer 表427 n02795169 barrel 酒桶428 n02797295 barrow 手推车429 n02799071 baseball 棒球430 n02802426 basketball 篮球431 n02804414 bassinet 婴儿432 n02804610 bassoon 乐器433 n02807133 bathing_cap 游泳434 n02808304 bath_towel 婴儿毛巾435 n02808440 bathtub 浴缸436 n02814533 beach_wagon 轿车437 n02814860 beacon 灯塔438 n02815834 beaker 烧杯439 n02817516 bearskin 守卫440 n02823428 beer_bottle 啤酒441 n02823750 beer_glass 啤酒442 n02825657 bell_cote 建筑443 n02834397 bib 围兜444 n02835271 bicycle-built-for-two 双人自行车445 n02837789 bikini 比基尼446 n02840245 binder 笔记本447 n02841315 binoculars 望远镜448 n02843684 birdhouse 信箱449 n02859443 boathouse 小屋450 n02860847 bobsled 雪橇451 n02865351 bolo_tie 项链452 n02869837 bonnet 帽子453 n02870880 bookcase 书柜454 n02871525 bookshop 书店455 n02877765 bottlecap 瓶盖456 n02879718 bow 弓箭457 n02883205 bow_tie 领结458 n02892201 brass 墓碑459 n02892767 brassiere 胸罩460 n02894605 breakwater 海岸461 n02895154 breastplate 盔甲462 n02906734 broom 扫帚463 n02909870 bucket 水桶464 n02910353 buckle 皮带465 n02916936 bulletproof_vest 防弹背心466 n02917067 bullet_train 火车467 n02927161 butcher_shop 肉铺468 n02930766 cab 出租车469 n02939185 caldron 锅470 n02948072 candle 蜡烛471 n02950826 cannon 炮472 n02951358 canoe 艇473 n02951585 can_opener 订书机474 n02963159 cardigan 毛衣475 n02965783 car_mirror 反光镜476 n02966193 carousel 旋转木马477 n02966687 carpenter’s_kit 工具箱478 n02971356 carton 盒子479 n02974003 car_wheel 轮胎480 n02977058 cash_machine 取款机481 n02978881 cassette 磁带482 n02979186 cassette_player 磁带483 n02980441 castle 城堡484 n02981792 catamaran 帆船485 n02988304 CD_player cd播放器486 n02992211 cello 大提琴487 n02992529 cellular_telephone 手机488 n02999410 chain 铁链489 n03000134 chainlink_fence 铁丝网490 n03000247 chain_mail 铁丝网491 n03000684 chain_saw 电锯492 n03014705 chest 木箱493 n03016953 chiffonier 木柜494 n03017168 chime 锣鼓495 n03018349 china_cabinet 柜子496 n03026506 Christmas_stocking 袜子497 n03028079 church 教堂498 n03032252 cinema 剧院499 n03041632 cleaver 刀500 n03042490 cliff_dwelling 堡垒501 n03045698 cloak 斗篷502 n03047690 clog 鞋子503 n03062245 cocktail_shaker 瓶子504 n03063599 coffee_mug 杯子505 n03063689 coffeepot 壶506 n03065424 coil 螺旋507 n03075370 combination_lock 锁508 n03085013 computer_keyboard 键盘509 n03089624 confectionery 糖果510 n03095699 container_ship 船511 n03100240 convertible 轿车512 n03109150 corkscrew 开瓶器513 n03110669 cornet 号(乐器)514 n03124043 cowboy_boot 靴子515 n03124170 cowboy_hat 帽子516 n03125729 cradle 婴儿床517 n03126707 crane 起重机518 n03127747 crash_helmet 头盔519 n03127925 crate 木箱520 n03131574 crib 婴儿床521 n03133878 Crock_Pot 电饭锅522 n03134739 croquet_ball 推球523 n03141823 crutch 拐杖524 n03146219 cuirass 盔甲525 n03160309 dam 水库526 n03179701 desk 办公桌527 n03180011 desktop_computer 电脑528 n03187595 dial_telephone 电话机529 n03188531 diaper 尿布530 n03196217 digital_clock 闹钟531 n03197337 digital_watch 手表532 n03201208 dining_table 餐桌533 n03207743 dishrag 垫子534 n03207941 dishwasher 洗碗柜535 n03208938 disk_brake 车轮536 n03216828 dock 港口537 n03218198 dogsled 雪橇538 n03220513 dome 穹顶539 n03223299 doormat 地毯540 n03240683 drilling_platform 油田541 n03249569 drum 鼓542 n03250847 drumstick 鼓棒543 n03255030 dumbbell 哑铃544 n03259280 Dutch_oven 锅545 n03271574 electric_fan 风扇546 n03272010 electric_guitar 电吉他547 n03272562 electric_locomotive 火车548 n03290653 entertainment_center 电视机549 n03291819 envelope 信550 n03297495 espresso_maker 咖啡机551 n03314780 face_powder 化妆品552 n03325584 feather_boa 绒毛553 n03337140 file 柜子554 n03344393 fireboat 喷泉555 n03345487 fire_engine 消防车556 n03347037 fire_screen 壁炉557 n03355925 flagpole 旗杆558 n03372029 flute 笛子559 n03376595 folding_chair 座椅560 n03379051 football_helmet 橄榄球561 n03384352 forklift 叉车562 n03388043 fountain 喷泉563 n03388183 fountain_pen 钢笔564 n03388549 four-poster 床565 n03393912 freight_car 火车566 n03394916 French_horn 圆号567 n03400231 frying_pan 平底锅568 n03404251 fur_coat 裘皮569 n03417042 garbage_truck 卡车570 n03424325 gasmask 面具571 n03425413 gas_pump 加油572 n03443371 goblet 酒杯573 n03444034 go-kart 卡丁车574 n03445777 golf_ball 高尔夫575 n03445924 golfcart 高尔夫车576 n03447447 gondola 小船577 n03447721 gong 锣鼓578 n03450230 gown 婚纱579 n03452741 grand_piano 钢琴580 n03457902 greenhouse 大棚581 n03459775 grille 轿车582 n03461385 grocery_store 菜场583 n03467068 guillotine 断头台584 n03476684 hair_slide 发饰585 n03476991 hair_spray 发蜡586 n03478589 half_track 坦克587 n03481172 hammer 榔头588 n03482405 hamper 竹筒589 n03483316 hand_blower 吹风机590 n03485407 hand-held_computer pos机591 n03485794 handkerchief 手帕592 n03492542 hard_disc 硬盘593 n03494278 harmonica 口风琴594 n03495258 harp 竖琴595 n03496892 harvester 起重机596 n03498962 hatchet 斧头597 n03527444 holster 手枪598 n03529860 home_theater 电视机599 n03530642 honeycomb 蜂巢600 n03532672 hook 钩子601 n03534580 hoopskirt 裙子602 n03535780 horizontal_bar 体操603 n03538406 horse_cart 马车604 n03544143 hourglass 沙漏605 n03584254 iPod 音乐播放器606 n03584829 iron 电熨斗607 n03590841 jack-o’-lantern 南瓜灯608 n03594734 jean 牛仔裤609 n03594945 jeep 吉普车610 n03595614 jersey T恤611 n03598930 jigsaw_puzzle 拼图612 n03599486 jinrikisha 黄包车613 n03602883 joystick 操纵杆614 n03617480 kimono 和服615 n03623198 knee_pad 护具616 n03627232 knot 绳结617 n03630383 lab_coat 医生618 n03633091 ladle 勺子619 n03637318 lampshade 灯620 n03642806 laptop 笔记本电脑621 n03649909 lawn_mower 割草机622 n03657121 lens_cap 镜头盖623 n03658185 letter_opener 小刀624 n03661043 library 图书馆625 n03662601 lifeboat 救生船626 n03666591 lighter 打火机627 n03670208 limousine 加长车628 n03673027 liner 轮船629 n03676483 lipstick 口红630 n03680355 Loafer 鞋子631 n03690938 lotion 护肤品632 n03691459 loudspeaker 音响633 n03692522 loupe 放大镜634 n03697007 lumbermill 原木635 n03706229 magnetic_compass 指南针636 n03709823 mailbag 包637 n03710193 mailbox 邮箱638 n03710637 maillot 泳衣639 n03710721 maillot 泳衣640 n03717622 manhole_cover 窨井盖641 n03720891 maraca 手摇铃642 n03721384 marimba 木琴643 n03724870 mask 面具644 n03729826 matchstick 火柴645 n03733131 maypole 绳子646 n03733281 maze 迷宫647 n03733805 measuring_cup 烧杯648 n03742115 medicine_chest 冰箱649 n03743016 megalith 石柱650 n03759954 microphone 话筒651 n03761084 microwave 微波炉652 n03763968 military_uniform 军人653 n03764736 milk_can 水壶654 n03769881 minibus 小客车655 n03770439 miniskirt 短裙656 n03770679 minivan 面包车657 n03773504 missile 导弹658 n03775071 mitten 手套659 n03775546 mixing_bowl 碗660 n03776460 mobile_home 房车661 n03777568 Model_T 老爷车662 n03777754 modem 路由器663 n03781244 monastery 建筑664 n03782006 monitor 显示器665 n03785016 moped 摩托车666 n03786901 mortar 砚667 n03787032 mortarboard 学士帽668 n03788195 mosque 建筑669 n03788365 mosquito_net 蚊帐670 n03791053 motor_scooter 助动车671 n03792782 mountain_bike 自行车672 n03792972 mountain_tent 帐篷673 n03793489 mouse 键盘鼠标674 n03794056 mousetrap 捕鼠夹675 n03796401 moving_van 货车676 n03803284 muzzle 狗嘴套677 n03804744 nail 钉子678 n03814639 neck_brace 颈托679 n03814906 necklace 项链680 n03825788 nipple 奶瓶681 n03832673 notebook 笔记本电脑682 n03837869 obelisk 建筑683 n03838899 oboe 黑管684 n03840681 ocarina 埙685 n03841143 odometer 仪表盘686 n03843555 oil_filter 机油滤清器687 n03854065 organ 管风琴688 n03857828 oscilloscope 示波器689 n03866082 overskirt 礼服690 n03868242 oxcart 牛车691 n03868863 oxygen_mask 呼吸器692 n03871628 packet 零食693 n03873416 paddle 划桨694 n03874293 paddlewheel 水轮695 n03874599 padlock 锁696 n03876231 paintbrush 刷子697 n03877472 pajama 睡衣698 n03877845 palace 建筑699 n03884397 panpipe 乐器700 n03887697 paper_towel 纸巾701 n03888257 parachute 降落伞702 n03888605 parallel_bars 体操703 n03891251 park_bench 长椅704 n03891332 parking_meter 停车缴费器705 n03895866 passenger_car 火车706 n03899768 patio 院子707 n03902125 pay-phone 公用电话708 n03903868 pedestal 柱子709 n03908618 pencil_box 文具袋710 n03908714 pencil_sharpener 卷笔刀711 n03916031 perfume 香水712 n03920288 Petri_dish 培养皿713 n03924679 photocopier 打印机714 n03929660 pick 吉他拨片715 n03929855 pickelhaube 头盔716 n03930313 picket_fence 栅栏717 n03930630 pickup 轿车718 n03933933 pier 桥719 n03935335 piggy_bank 储蓄罐720 n03937543 pill_bottle 药丸721 n03938244 pillow 枕头722 n03942813 ping-pong_ball 乒乓球723 n03944341 pinwheel 风车724 n03947888 pirate 帆船725 n03950228 pitcher 茶壶726 n03954731 plane 刨子727 n03956157 planetarium 建筑728 n03958227 plastic_bag 塑料袋729 n03961711 plate_rack 碗架730 n03967562 plow 推土机731 n03970156 plunger 搋子732 n03976467 Polaroid_camera 相机733 n03976657 pole 杆子734 n03977966 police_van 警车735 n03980874 poncho 披风736 n03982430 pool_table 桌球737 n03983396 pop_bottle 瓶子738 n03991062 pot 盆栽739 n03992509 potter’s_wheel 陶艺740 n03995372 power_drill 钻机741 n03998194 prayer_rug 毯子742 n04004767 printer 打印机743 n04005630 prison 监狱744 n04008634 projectile 导弹745 n04009552 projector 投影仪746 n04019541 puck 冰球747 n04023962 punching_bag 拳击748 n04026417 purse 手提袋749 n04033901 quill 羽毛笔750 n04033995 quilt 床751 n04037443 racer 赛车752 n04039381 racket 网球753 n04040759 radiator 加热器754 n04041544 radio 收音机755 n04044716 radio_telescope 卫星接收器756 n04049303 rain_barrel 酒桶757 n04065272 recreational_vehicle 房车758 n04067472 reel 鱼竿759 n04069434 reflex_camera 相机760 n04070727 refrigerator 冰箱761 n04074963 remote_control 遥控器762 n04081281 restaurant 餐厅763 n04086273 revolver 手枪764 n04090263 rifle 狙击枪765 n04099969 rocking_chair 摇椅766 n04111531 rotisserie 烤箱767 n04116512 rubber_eraser 橡皮768 n04118538 rugby_ball 橄榄球769 n04118776 rule 尺770 n04120489 running_shoe 运动鞋771 n04125021 safe 保险箱772 n04127249 safety_pin 回形针773 n04131690 saltshaker 调料瓶774 n04133789 sandal 拖鞋775 n04136333 sarong 长裙776 n04141076 sax 萨克斯777 n04141327 scabbard 剑778 n04141975 scale 秤779 n04146614 school_bus 校车780 n04147183 schooner 帆船781 n04149813 scoreboard 计分板782 n04152593 screen 显示器783 n04153751 screw 螺丝784 n04154565 screwdriver 螺丝刀785 n04162706 seat_belt 安全带786 n04179913 sewing_machine 缝纫机787 n04192698 shield 盾牌788 n04200800 shoe_shop 鞋店789 n04201297 shoji 榻榻米790 n04204238 shopping_basket 购物篮791 n04204347 shopping_cart 购物车792 n04208210 shovel 铲子793 n04209133 shower_cap 浴帽794 n04209239 shower_curtain 浴帘795 n04228054 ski 滑雪796 n04229816 ski_mask 面罩797 n04235860 sleeping_bag 睡袋798 n04238763 slide_rule 游标卡尺799 n04239074 sliding_door 移门800 n04243546 slot 老虎机801 n04251144 snorkel 游泳眼镜802 n04252077 snowmobile 滑雪车803 n04252225 snowplow 铲雪车804 n04254120 soap_dispenser 洗手液805 n04254680 soccer_ball 足球806 n04254777 sock 袜子807 n04258138 solar_dish 太阳能板808 n04259630 sombrero 帽子809 n04263257 soup_bowl 碗810 n04264628 space_bar 键盘811 n04265275 space_heater 电热器812 n04266014 space_shuttle 航天飞船813 n04270147 spatula 锅铲814 n04273569 speedboat 快艇815 n04275548 spider_web 蜘蛛网816 n04277352 spindle 毛线817 n04285008 sports_car 运动型轿车818 n04286575 spotlight 探照灯819 n04296562 stage 乐队820 n04310018 steam_locomotive 蒸汽机车821 n04311004 steel_arch_bridge 桥822 n04311174 steel_drum 鼓823 n04317175 stethoscope 听诊器824 n04325704 stole 担架825 n04326547 stone_wall 石堆826 n04328186 stopwatch 秒表827 n04330267 stove 火炉828 n04332243 strainer 滤网829 n04335435 streetcar 公交车830 n04336792 stretcher 担架831 n04344873 studio_couch 沙发832 n04346328 stupa 皇宫833 n04347754 submarine 轮船834 n04350905 suit 西装835 n04355338 sundial 日晷836 n04355933 sunglass 墨镜837 n04356056 sunglasses 墨镜838 n04357314 sunscreen 防晒霜839 n04366367 suspension_bridge 桥840 n04367480 swab 拖把841 n04370456 sweatshirt 连帽衫842 n04371430 swimming_trunks 沙滩裤843 n04371774 swing 秋千844 n04372370 switch 开关845 n04376876 syringe 针筒846 n04380533 table_lamp 台灯847 n04389033 tank 坦克848 n04392985 tape_player 磁带播放器849 n04398044 teapot 茶壶850 n04399382 teddy 毛绒玩具851 n04404412 television 电视机852 n04409515 tennis_ball 网球853 n04417672 thatch 草屋854 n04418357 theater_curtain 幕布855 n04423845 thimble 指套856 n04428191 thresher 装甲车857 n04429376 throne 皇位858 n04435653 tile_roof 瓦片859 n04442312 toaster 面包机860 n04443257 tobacco_shop 烟酒店861 n04447861 toilet_seat 马桶862 n04456115 torch 火炬863 n04458633 totem_pole 图腾864 n04461696 tow_truck 大卡车865 n04462240 toyshop 玩具店866 n04465501 tractor 拖拉机867 n04467665 trailer_truck 大货车868 n04476259 tray 碟子869 n04479046 trench_coat 风衣870 n04482393 tricycle 儿童自行车871 n04483307 trimaran 船872 n04485082 tripod 三脚架873 n04486054 triumphal_arch 拱门874 n04487081 trolleybus 巴士875 n04487394 trombone 长号876 n04493381 tub 浴缸877 n04501370 turnstile 闸机878 n04505470 typewriter_keyboard 打字机879 n04507155 umbrella 伞880 n04509417 unicycle 独轮车881 n04515003 upright 钢琴882 n04517823 vacuum 吸尘器883 n04522168 vase 花瓶884 n04523525 vault 拱廊885 n04525038 velvet 珊瑚绒886 n04525305 vending_machine 自动贩卖机887 n04532106 vestment 教皇袍888 n04532670 viaduct 桥889 n04536866 violin 小提琴890 n04540053 volleyball 排球891 n04542943 waffle_iron 煎饼锅892 n04548280 wall_clock 挂钟893 n04548362 wallet 钱夹894 n04550184 wardrobe 柜子895 n04552348 warplane 飞机896 n04553703 washbasin 台盆897 n04554684 washer 洗衣机898 n04557648 water_bottle 水瓶899 n04560804 water_jug 水壶900 n04562935 water_tower 煤气包901 n04579145 whiskey_jug 水壶902 n04579432 whistle 哨子903 n04584207 wig 头发904 n04589890 window_screen 窗户905 n04590129 window_shade 百叶窗906 n04591157 Windsor_tie 领带907 n04591713 wine_bottle 葡萄酒908 n04592741 wing 飞机909 n04596742 wok 炒锅910 n04597913 wooden_spoon 勺子911 n04599235 wool 围巾912 n04604644 worm_fence 栅栏913 n04606251 wreck 沉船914 n04612504 yawl 帆船915 n04613696 yurt 蒙古包916 n06359193 web_site 网页917 n06596364 comic_book 海报918 n06785654 crossword_puzzle 填字游戏919 n06794110 street_sign 交通标志920 n06874185 traffic_light 交通灯921 n07248320 book_jacket 书922 n07565083 menu 菜单923 n07579787 plate 菜924 n07583066 guacamole 菜925 n07584110 consomme 菜926 n07590611 hot_pot 菜927 n07613480 trifle 蛋糕928 n07614500 ice_cream 冰激凌929 n07615774 ice_lolly 棒冰930 n07684084 French_loaf 面包931 n07693725 bagel 甜甜圈932 n07695742 pretzel 面包933 n07697313 cheeseburger 汉堡934 n07697537 hotdog 热狗935 n07711569 mashed_potato 焗饭936 n07714571 head_cabbage 蔬菜937 n07714990 broccoli 西蓝花938 n07715103 cauliflower 花椰菜939 n07716358 zucchini 蔬菜940 n07716906 spaghetti_squash 金瓜941 n07717410 acorn_squash 南瓜942 n07717556 butternut_squash 南瓜943 n07718472 cucumber 黄瓜944 n07718747 artichoke 蔬菜945 n07720875 bell_pepper 青椒946 n07730033 cardoon 花947 n07734744 mushroom 蘑菇948 n07742313 Granny_Smith 苹果949 n07745940 strawberry 草莓950 n07747607 orange 橙子951 n07749582 lemon 柠檬952 n07753113 fig 水果953 n07753275 pineapple 菠萝954 n07753592 banana 香蕉955 n07754684 jackfruit 榴莲956 n07760859 custard_apple 水果957 n07768694 pomegranate 石榴958 n07802026 hay 草垛959 n07831146 carbonara 意大利面960 n07836838 chocolate_sauce 甜品961 n07860988 dough 面团962 n07871810 meat_loaf 肉酱963 n07873807 pizza 披萨964 n07875152 potpie 派965 n07880968 burrito 肉卷966 n07892512 red_wine 红酒967 n07920052 espresso 咖啡968 n07930864 cup 茶969 n07932039 eggnog 饮料杯970 n09193705 alp 雪山971 n09229709 bubble 泡泡972 n09246464 cliff 悬崖973 n09256479 coral_reef 珊瑚974 n09288635 geyser 温泉975 n09332890 lakeside 风景976 n09399592 promontory 小岛977 n09421951 sandbar 沙滩978 n09428293 seashore 海滩979 n09468604 valley 瀑布980 n09472597 volcano 火山981 n09835506 ballplayer 棒球982 n10148035 groom 婚礼983 n10565667 scuba_diver 潜水984 n11879895 rapeseed 油菜花985 n11939491 daisy 菊花986 n12057211 yellow_lady’s_slipper 植物987 n12144580 corn 玉米988 n12267677 acorn 松果989 n12620546 hip 植物990 n12768682 buckeye 栗子991 n12985857 coral_fungus 菌菇992 n12998815 agaric 菌菇993 n13037406 gyromitra 菌菇994 n13040303 stinkhorn 菌菇995 n13044778 earthstar 菌菇996 n13052670 hen-of-the-woods 菌菇997 n13054560 bolete 菌菇998 n13133613 ear 玉米999 n15075141 toilet_tissue 卷筒纸
使用脚本将数字编号和末尾中文删除
import codecsimport ospath = 'D:/code/yolov8-pytorch-master/voc_classes.txt'# 标签文件train路径newFile = 'D:/code/yolov8-pytorch-master/voc_classesNew.txt'# 读取路径下的txt文件t = codecs.open(path, mode='r', encoding='utf-8')line = t.readline()# 以行的形式进行读取文件list1 = []# 保存了信息列表while line:a = line.split()list1.append(a)line = t.readline()t.close()lt = open(newFile, "w")newlist1 = list1for num in range(0, len(newlist1)):del newlist1[num][0]del newlist1[num][2]for num in range(0, len(newlist1)):lt.writelines(' '.join(newlist1[num]) + '\n')# 每个元素以空格间隔,一行元素写完并换行lt.close()print(" 修改完成")
转换的时候,列表存在编码问题
删掉修改就行
处理思路为;
先转成voc格式
在将voc格式转yolo格式
转voc格式
转将xml数据转换为标准的VOC格式
.py里面有一些参数需要设置 。
分别是、、、、 , 第一次训练可以仅修改
import osimport randomimport xml.etree.ElementTree as ETimport numpy as npfrom utils.utils import get_classes#--------------------------------------------------------------------------------------------------------------------------------##annotation_mode用于指定该文件运行时计算的内容#annotation_mode为0代表整个标签处理过程,包括获得VOCdevkit/VOC2007/ImageSets里面的txt以及训练用的2007_train.txt、2007_val.txt#annotation_mode为1代表获得VOCdevkit/VOC2007/ImageSets里面的txt#annotation_mode为2代表获得训练用的2007_train.txt、2007_val.txt#--------------------------------------------------------------------------------------------------------------------------------#annotation_mode= 0#-------------------------------------------------------------------##必须要修改,用于生成2007_train.txt、2007_val.txt的目标信息#与训练和预测所用的classes_path一致即可#如果生成的2007_train.txt里面没有目标信息#那么就是因为classes没有设定正确#仅在annotation_mode为0和2的时候有效#-------------------------------------------------------------------#classes_path= 'model_data/voc_classesNew.txt'#--------------------------------------------------------------------------------------------------------------------------------##trainval_percent用于指定(训练集+验证集)与测试集的比例,默认情况下 (训练集+验证集):测试集 = 9:1#train_percent用于指定(训练集+验证集)中训练集与验证集的比例 , 默认情况下 训练集:验证集 = 9:1#仅在annotation_mode为0和1的时候有效#--------------------------------------------------------------------------------------------------------------------------------#trainval_percent= 0.9train_percent= 0.9#-------------------------------------------------------##指向VOC数据集所在的文件夹#默认指向根目录下的VOC数据集#-------------------------------------------------------#VOCdevkit_path= 'VOCdevkit'VOCdevkit_sets= [('2007', 'train'), ('2007', 'val')]classes, _= get_classes(classes_path)#-------------------------------------------------------##统计目标数量#-------------------------------------------------------#photo_nums= np.zeros(len(VOCdevkit_sets))nums= np.zeros(len(classes))def convert_annotation(year, image_id, list_file):in_file = open(os.path.join(VOCdevkit_path, 'VOC%s/Annotations/%s.xml'%(year, image_id)), encoding='utf-8')tree=ET.parse(in_file)root = tree.getroot()for obj in root.iter('object'):difficult = 0 if obj.find('difficult')!=None:difficult = obj.find('difficult').textcls = obj.find('name').textif cls not in classes or int(difficult)==1:continuecls_id = classes.index(cls)xmlbox = obj.find('bndbox')b = (int(float(xmlbox.find('xmin').text)), int(float(xmlbox.find('ymin').text)), int(float(xmlbox.find('xmax').text)), int(float(xmlbox.find('ymax').text)))list_file.write(" " + ",".join([str(a) for a in b]) + ',' + str(cls_id))nums[classes.index(cls)] = nums[classes.index(cls)] + 1if __name__ == "__main__":random.seed(0)if " " in os.path.abspath(VOCdevkit_path):raise ValueError("数据集存放的文件夹路径与图片名称中不可以存在空格 , 否则会影响正常的模型训练,请注意修改 。")if annotation_mode == 0 or annotation_mode == 1:print("Generate txt in ImageSets.")xmlfilepath= os.path.join(VOCdevkit_path, 'VOC2007/Annotations')saveBasePath= os.path.join(VOCdevkit_path, 'VOC2007/ImageSets/Main')temp_xml= os.listdir(xmlfilepath)total_xml= []for xml in temp_xml:if xml.endswith(".xml"):total_xml.append(xml)num= len(total_xml)list= range(num)tv= int(num*trainval_percent)tr= int(tv*train_percent)trainval= random.sample(list,tv)train= random.sample(trainval,tr)print("train and val size",tv)print("train size",tr)ftrainval= open(os.path.join(saveBasePath,'trainval.txt'), 'w')ftest= open(os.path.join(saveBasePath,'test.txt'), 'w')ftrain= open(os.path.join(saveBasePath,'train.txt'), 'w')fval= open(os.path.join(saveBasePath,'val.txt'), 'w')for i in list:name=total_xml[i][:-4]+'\n'if i in trainval:ftrainval.write(name)if i in train:ftrain.write(name)else:fval.write(name)else:ftest.write(name)ftrainval.close()ftrain.close()fval.close()ftest.close()print("Generate txt in ImageSets done.")if annotation_mode == 0 or annotation_mode == 2:print("Generate 2007_train.txt and 2007_val.txt for train.")type_index = 0for year, image_set in VOCdevkit_sets:image_ids = open(os.path.join(VOCdevkit_path, 'VOC%s/ImageSets/Main/%s.txt'%(year, image_set)), encoding='utf-8').read().strip().split()list_file = open('%s_%s.txt'%(year, image_set), 'w', encoding='utf-8')for image_id in image_ids:list_file.write('%s/VOC%s/JPEGImages/%s.jpg'%(os.path.abspath(VOCdevkit_path), year, image_id))convert_annotation(year, image_id, list_file)list_file.write('\n')photo_nums[type_index] = len(image_ids)type_index += 1list_file.close()print("Generate 2007_train.txt and 2007_val.txt for train done.")def printTable(List1, List2):for i in range(len(List1[0])):print("|", end=' ')for j in range(len(List1)):print(List1[j][i].rjust(int(List2[j])), end=' ')print("|", end=' ')print()str_nums = [str(int(x)) for x in nums]tableData = http://www.kingceram.com/post/[classes, str_nums]colWidths = [0]*len(tableData)len1 = 0for i in range(len(tableData)):for j in range(len(tableData[i])):if len(tableData[i][j])> colWidths[i]:colWidths[i] = len(tableData[i][j])printTable(tableData, colWidths)if photo_nums[0] <= 500:print("训练集数量小于500,属于较小的数据量,请注意设置较大的训练世代(Epoch)以满足足够的梯度下降次数(Step) 。")if np.sum(nums) == 0:print("在数据集中并未获得任何目标,请注意修改classes_path对应自己的数据集,并且保证标签名字正确,否则训练将会没有任何效果!")print("在数据集中并未获得任何目标,请注意修改classes_path对应自己的数据集,并且保证标签名字正确,否则训练将会没有任何效果!")print("在数据集中并未获得任何目标,请注意修改classes_path对应自己的数据集,并且保证标签名字正确 , 否则训练将会没有任何效果!")print("(重要的事情说三遍) 。")
需要注意的是,xml中的类别是文件名,为了识别匹配到类别信息,类别txt文件需要对应
类别文件保留名称
最后修改COCO128.yaml文件

文章插图
这时再执行.py
看得出类别已经识别了
只不过后续还得将名称和类别做一次转换
将xml文件转化为txt文件,xml文件包含了对应的GT框以及图片长宽大小等信息 , 通过对其解析,并进行归一化最终读到txt文件中同时生成train、val和test数据集中图片的绝对路径,用于索引到图片位置
获取纯类别信息的txt
import codecsimport ospath = 'D:/code/yolov8-pytorch-master/voc_classesNew.txt'# 标签文件train路径newFile = 'D:/code/yolov8-pytorch-master/voc_classesNew2.txt'# 读取路径下的txt文件t = codecs.open(path, mode='r', encoding='utf-8')line = t.readline()# 以行的形式进行读取文件list1 = []# 保存了信息列表while line:a = line.split()list1.append(a)line = t.readline()t.close()lt = open(newFile, "w")newlist1 = list1for num in range(0, len(newlist1)):del newlist1[num][0]for num in range(0, len(newlist1)):lt.writelines(' '.join(newlist1[num]) + '\n')# 每个元素以空格间隔,一行元素写完并换行lt.close()print(" 修改完成")
在上述类别信息txt中存在个别编码错误 , 需要改一下编码
查看一下VOC中数据格式
最后一个999是类别编号(最后一行)
【最后修改COCO128.yaml文件】代码
import xml.etree.ElementTree as ETimport pickleimport osfrom os import listdir, getcwdfrom os.path import joinimport randomfrom shutil import copyfile# 根据自己的数据标签修改classes=["tumor"]def clear_hidden_files(path):dir_list = os.listdir(path)for i in dir_list:abspath = os.path.join(os.path.abspath(path), i)if os.path.isfile(abspath):if i.startswith("._"):os.remove(abspath)else:clear_hidden_files(abspath)def convert(size, box):dw = 1./size[0]dh = 1./size[1]x = (box[0] + box[1])/2.0y = (box[2] + box[3])/2.0w = box[1] - box[0]h = box[3] - box[2]x = x*dww = w*dwy = y*dhh = h*dhreturn (x,y,w,h)def convert_annotation(image_id):in_file = open('VOCdevkit/VOC2007/Annotations/%s.xml' %image_id)out_file = open('VOCdevkit/VOC2007/YOLOLabels/%s.txt' %image_id, 'w')tree=ET.parse(in_file)root = tree.getroot()size = root.find('size')w = int(size.find('width').text)h = int(size.find('height').text)for obj in root.iter('object'):difficult = obj.find('difficult').textcls = obj.find('name').textif cls not in classes or int(difficult) == 1:continuecls_id = classes.index(cls)xmlbox = obj.find('bndbox')b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text), float(xmlbox.find('ymin').text), float(xmlbox.find('ymax').text))bb = convert((w,h), b)out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')in_file.close()out_file.close()wd = os.getcwd()wd = os.getcwd()data_base_dir = os.path.join(wd, "VOCdevkit/")if not os.path.isdir(data_base_dir):os.mkdir(data_base_dir)work_sapce_dir = os.path.join(data_base_dir, "VOC2007/")if not os.path.isdir(work_sapce_dir):os.mkdir(work_sapce_dir)annotation_dir = os.path.join(work_sapce_dir, "Annotations/")if not os.path.isdir(annotation_dir):os.mkdir(annotation_dir)clear_hidden_files(annotation_dir)image_dir = os.path.join(work_sapce_dir, "JPEGImages/")if not os.path.isdir(image_dir):os.mkdir(image_dir)clear_hidden_files(image_dir)yolo_labels_dir = os.path.join(work_sapce_dir, "YOLOLabels/")if not os.path.isdir(yolo_labels_dir):os.mkdir(yolo_labels_dir)clear_hidden_files(yolo_labels_dir)yolov5_images_dir = os.path.join(data_base_dir, "images/")if not os.path.isdir(yolov5_images_dir):os.mkdir(yolov5_images_dir)clear_hidden_files(yolov5_images_dir)yolov5_labels_dir = os.path.join(data_base_dir, "labels/")if not os.path.isdir(yolov5_labels_dir):os.mkdir(yolov5_labels_dir)clear_hidden_files(yolov5_labels_dir)yolov5_images_train_dir = os.path.join(yolov5_images_dir, "train/")if not os.path.isdir(yolov5_images_train_dir):os.mkdir(yolov5_images_train_dir)clear_hidden_files(yolov5_images_train_dir)yolov5_images_test_dir = os.path.join(yolov5_images_dir, "val/")if not os.path.isdir(yolov5_images_test_dir):os.mkdir(yolov5_images_test_dir)clear_hidden_files(yolov5_images_test_dir)yolov5_labels_train_dir = os.path.join(yolov5_labels_dir, "train/")if not os.path.isdir(yolov5_labels_train_dir):os.mkdir(yolov5_labels_train_dir)clear_hidden_files(yolov5_labels_train_dir)yolov5_labels_test_dir = os.path.join(yolov5_labels_dir, "val/")if not os.path.isdir(yolov5_labels_test_dir):os.mkdir(yolov5_labels_test_dir)clear_hidden_files(yolov5_labels_test_dir)train_file = open(os.path.join(wd, "yolov5_train.txt"), 'w')test_file = open(os.path.join(wd, "yolov5_val.txt"), 'w')train_file.close()test_file.close()train_file = open(os.path.join(wd, "yolov5_train.txt"), 'a')test_file = open(os.path.join(wd, "yolov5_val.txt"), 'a')list_imgs = os.listdir(image_dir) # list image filesprobo = random.randint(1, 100)print("Probobility: %d" % probo)for i in range(0,len(list_imgs)):path = os.path.join(image_dir,list_imgs[i])if os.path.isfile(path):image_path = image_dir + list_imgs[i]voc_path = list_imgs[i](nameWithoutExtention, extention) = os.path.splitext(os.path.basename(image_path))(voc_nameWithoutExtention, voc_extention) = os.path.splitext(os.path.basename(voc_path))annotation_name = nameWithoutExtention + '.xml'annotation_path = os.path.join(annotation_dir, annotation_name)label_name = nameWithoutExtention + '.txt'label_path = os.path.join(yolo_labels_dir, label_name)probo = random.randint(1, 100)print("Probobility: %d" % probo)if(probo < 80): # train datasetif os.path.exists(annotation_path):train_file.write(image_path + '\n')convert_annotation(nameWithoutExtention) # convert labelcopyfile(image_path, yolov5_images_train_dir + voc_path)copyfile(label_path, yolov5_labels_train_dir + label_name)else: # test datasetif os.path.exists(annotation_path):test_file.write(image_path + '\n')convert_annotation(nameWithoutExtention) # convert labelcopyfile(image_path, yolov5_images_test_dir + voc_path)copyfile(label_path, yolov5_labels_test_dir + label_name)train_file.close()test_file.close()
关键就在于如何将1000类的信息写到代码里面的列表中去 。。。。
实现代码
import codecsimport ospath = 'D:/code/yolov8-pytorch-master/voc_classes.txt'# 类别文件路径newpath = 'D:/code/yolov8-pytorch-master/voc_classList.txt'# 生成类别列表#["n1507514100","n150751410","n15075142","n15075141"]DEMO# 使用with open打开文件 , 这样不用调用close()方法来关闭文件了with open(path, 'r') as f:# readlines()方法 , 读取文件中所有行,每一行作为一个字符串存入在列表中,并且换行符用\n来表示 。content = f.readlines()#print(content)separator = '\\'newcontent = []for i in range(len(content)):newcontent =newcontent+[content[i].replace('\n','')]#print(content[i].split('\\',1)[0])#print(type(content[i].split('\\',1)[0]))print(newcontent)
读写文件详解,将数据写入一个文件或读一个文件写入另一个文件中
在中如何删除指定字符之前或之后的所有内容
去除字符串最后的换行符‘\n’
得到代码
import xml.etree.ElementTree as ETimport pickleimport osfrom os import listdir, getcwdfrom os.path import joinimport randomfrom shutil import copyfile# 根据自己的数据标签修改classes=['n01440764', 'n01443537', 'n01484850', 'n01491361', 'n01494475', 'n01496331', 'n01498041', 'n01514668', 'n01514859', 'n01518878', 'n01530575', 'n01531178', 'n01532829', 'n01534433', 'n01537544', 'n01558993', 'n01560419', 'n01580077', 'n01582220', 'n01592084', 'n01601694', 'n01608432', 'n01614925', 'n01616318', 'n01622779', 'n01629819', 'n01630670', 'n01631663', 'n01632458', 'n01632777', 'n01641577', 'n01644373', 'n01644900', 'n01664065', 'n01665541', 'n01667114', 'n01667778', 'n01669191', 'n01675722', 'n01677366', 'n01682714', 'n01685808', 'n01687978', 'n01688243', 'n01689811', 'n01692333', 'n01693334', 'n01694178', 'n01695060', 'n01697457', 'n01698640', 'n01704323', 'n01728572', 'n01728920', 'n01729322', 'n01729977', 'n01734418', 'n01735189', 'n01737021', 'n01739381', 'n01740131', 'n01742172', 'n01744401', 'n01748264', 'n01749939', 'n01751748', 'n01753488', 'n01755581', 'n01756291', 'n01768244', 'n01770081', 'n01770393', 'n01773157', 'n01773549', 'n01773797', 'n01774384', 'n01774750', 'n01775062', 'n01776313', 'n01784675', 'n01795545', 'n01796340', 'n01797886', 'n01798484', 'n01806143', 'n01806567', 'n01807496', 'n01817953', 'n01818515', 'n01819313', 'n01820546', 'n01824575', 'n01828970', 'n01829413', 'n01833805', 'n01843065', 'n01843383', 'n01847000', 'n01855032', 'n01855672', 'n01860187', 'n01871265', 'n01872401', 'n01873310', 'n01877812', 'n01882714', 'n01883070', 'n01910747', 'n01914609', 'n01917289', 'n01924916', 'n01930112', 'n01943899', 'n01944390', 'n01945685', 'n01950731', 'n01955084', 'n01968897', 'n01978287', 'n01978455', 'n01980166', 'n01981276', 'n01983481', 'n01984695', 'n01985128', 'n01986214', 'n01990800', 'n02002556', 'n02002724', 'n02006656', 'n02007558', 'n02009229', 'n02009912', 'n02011460', 'n02012849', 'n02013706', 'n02017213', 'n02018207', 'n02018795', 'n02025239', 'n02027492', 'n02028035', 'n02033041', 'n02037110', 'n02051845', 'n02056570', 'n02058221', 'n02066245', 'n02071294', 'n02074367', 'n02077923', 'n02085620', 'n02085782', 'n02085936', 'n02086079', 'n02086240', 'n02086646', 'n02086910', 'n02087046', 'n02087394', 'n02088094', 'n02088238', 'n02088364', 'n02088466', 'n02088632', 'n02089078', 'n02089867', 'n02089973', 'n02090379', 'n02090622', 'n02090721', 'n02091032', 'n02091134', 'n02091244', 'n02091467', 'n02091635', 'n02091831', 'n02092002', 'n02092339', 'n02093256', 'n02093428', 'n02093647', 'n02093754', 'n02093859', 'n02093991', 'n02094114', 'n02094258', 'n02094433', 'n02095314', 'n02095570', 'n02095889', 'n02096051', 'n02096177', 'n02096294', 'n02096437', 'n02096585', 'n02097047', 'n02097130', 'n02097209', 'n02097298', 'n02097474', 'n02097658', 'n02098105', 'n02098286', 'n02098413', 'n02099267', 'n02099429', 'n02099601', 'n02099712', 'n02099849', 'n02100236', 'n02100583', 'n02100735', 'n02100877', 'n02101006', 'n02101388', 'n02101556', 'n02102040', 'n02102177', 'n02102318', 'n02102480', 'n02102973', 'n02104029', 'n02104365', 'n02105056', 'n02105162', 'n02105251', 'n02105412', 'n02105505', 'n02105641', 'n02105855', 'n02106030', 'n02106166', 'n02106382', 'n02106550', 'n02106662', 'n02107142', 'n02107312', 'n02107574', 'n02107683', 'n02107908', 'n02108000', 'n02108089', 'n02108422', 'n02108551', 'n02108915', 'n02109047', 'n02109525', 'n02109961', 'n02110063', 'n02110185', 'n02110341', 'n02110627', 'n02110806', 'n02110958', 'n02111129', 'n02111277', 'n02111500', 'n02111889', 'n02112018', 'n02112137', 'n02112350', 'n02112706', 'n02113023', 'n02113186', 'n02113624', 'n02113712', 'n02113799', 'n02113978', 'n02114367', 'n02114548', 'n02114712', 'n02114855', 'n02115641', 'n02115913', 'n02116738', 'n02117135', 'n02119022', 'n02119789', 'n02120079', 'n02120505', 'n02123045', 'n02123159', 'n02123394', 'n02123597', 'n02124075', 'n02125311', 'n02127052', 'n02128385', 'n02128757', 'n02128925', 'n02129165', 'n02129604', 'n02130308', 'n02132136', 'n02133161', 'n02134084', 'n02134418', 'n02137549', 'n02138441', 'n02165105', 'n02165456', 'n02167151', 'n02168699', 'n02169497', 'n02172182', 'n02174001', 'n02177972', 'n02190166', 'n02206856', 'n02219486', 'n02226429', 'n02229544', 'n02231487', 'n02233338', 'n02236044', 'n02256656', 'n02259212', 'n02264363', 'n02268443', 'n02268853', 'n02276258', 'n02277742', 'n02279972', 'n02280649', 'n02281406', 'n02281787', 'n02317335', 'n02319095', 'n02321529', 'n02325366', 'n02326432', 'n02328150', 'n02342885', 'n02346627', 'n02356798', 'n02361337', 'n02363005', 'n02364673', 'n02389026', 'n02391049', 'n02395406', 'n02396427', 'n02397096', 'n02398521', 'n02403003', 'n02408429', 'n02410509', 'n02412080', 'n02415577', 'n02417914', 'n02422106', 'n02422699', 'n02423022', 'n02437312', 'n02437616', 'n02441942', 'n02442845', 'n02443114', 'n02443484', 'n02444819', 'n02445715', 'n02447366', 'n02454379', 'n02457408', 'n02480495', 'n02480855', 'n02481823', 'n02483362', 'n02483708', 'n02484975', 'n02486261', 'n02486410', 'n02487347', 'n02488291', 'n02488702', 'n02489166', 'n02490219', 'n02492035', 'n02492660', 'n02493509', 'n02493793', 'n02494079', 'n02497673', 'n02500267', 'n02504013', 'n02504458', 'n02509815', 'n02510455', 'n02514041', 'n02526121', 'n02536864', 'n02606052', 'n02607072', 'n02640242', 'n02641379', 'n02643566', 'n02655020', 'n02666196', 'n02667093', 'n02669723', 'n02672831', 'n02676566', 'n02687172', 'n02690373', 'n02692877', 'n02699494', 'n02701002', 'n02704792', 'n02708093', 'n02727426', 'n02730930', 'n02747177', 'n02749479', 'n02769748', 'n02776631', 'n02777292', 'n02782093', 'n02783161', 'n02786058', 'n02787622', 'n02788148', 'n02790996', 'n02791124', 'n02791270', 'n02793495', 'n02794156', 'n02795169', 'n02797295', 'n02799071', 'n02802426', 'n02804414', 'n02804610', 'n02807133', 'n02808304', 'n02808440', 'n02814533', 'n02814860', 'n02815834', 'n02817516', 'n02823428', 'n02823750', 'n02825657', 'n02834397', 'n02835271', 'n02837789', 'n02840245', 'n02841315', 'n02843684', 'n02859443', 'n02860847', 'n02865351', 'n02869837', 'n02870880', 'n02871525', 'n02877765', 'n02879718', 'n02883205', 'n02892201', 'n02892767', 'n02894605', 'n02895154', 'n02906734', 'n02909870', 'n02910353', 'n02916936', 'n02917067', 'n02927161', 'n02930766', 'n02939185', 'n02948072', 'n02950826', 'n02951358', 'n02951585', 'n02963159', 'n02965783', 'n02966193', 'n02966687', 'n02971356', 'n02974003', 'n02977058', 'n02978881', 'n02979186', 'n02980441', 'n02981792', 'n02988304', 'n02992211', 'n02992529', 'n02999410', 'n03000134', 'n03000247', 'n03000684', 'n03014705', 'n03016953', 'n03017168', 'n03018349', 'n03026506', 'n03028079', 'n03032252', 'n03041632', 'n03042490', 'n03045698', 'n03047690', 'n03062245', 'n03063599', 'n03063689', 'n03065424', 'n03075370', 'n03085013', 'n03089624', 'n03095699', 'n03100240', 'n03109150', 'n03110669', 'n03124043', 'n03124170', 'n03125729', 'n03126707', 'n03127747', 'n03127925', 'n03131574', 'n03133878', 'n03134739', 'n03141823', 'n03146219', 'n03160309', 'n03179701', 'n03180011', 'n03187595', 'n03188531', 'n03196217', 'n03197337', 'n03201208', 'n03207743', 'n03207941', 'n03208938', 'n03216828', 'n03218198', 'n03220513', 'n03223299', 'n03240683', 'n03249569', 'n03250847', 'n03255030', 'n03259280', 'n03271574', 'n03272010', 'n03272562', 'n03290653', 'n03291819', 'n03297495', 'n03314780', 'n03325584', 'n03337140', 'n03344393', 'n03345487', 'n03347037', 'n03355925', 'n03372029', 'n03376595', 'n03379051', 'n03384352', 'n03388043', 'n03388183', 'n03388549', 'n03393912', 'n03394916', 'n03400231', 'n03404251', 'n03417042', 'n03424325', 'n03425413', 'n03443371', 'n03444034', 'n03445777', 'n03445924', 'n03447447', 'n03447721', 'n03450230', 'n03452741', 'n03457902', 'n03459775', 'n03461385', 'n03467068', 'n03476684', 'n03476991', 'n03478589', 'n03481172', 'n03482405', 'n03483316', 'n03485407', 'n03485794', 'n03492542', 'n03494278', 'n03495258', 'n03496892', 'n03498962', 'n03527444', 'n03529860', 'n03530642', 'n03532672', 'n03534580', 'n03535780', 'n03538406', 'n03544143', 'n03584254', 'n03584829', 'n03590841', 'n03594734', 'n03594945', 'n03595614', 'n03598930', 'n03599486', 'n03602883', 'n03617480', 'n03623198', 'n03627232', 'n03630383', 'n03633091', 'n03637318', 'n03642806', 'n03649909', 'n03657121', 'n03658185', 'n03661043', 'n03662601', 'n03666591', 'n03670208', 'n03673027', 'n03676483', 'n03680355', 'n03690938', 'n03691459', 'n03692522', 'n03697007', 'n03706229', 'n03709823', 'n03710193', 'n03710637', 'n03710721', 'n03717622', 'n03720891', 'n03721384', 'n03724870', 'n03729826', 'n03733131', 'n03733281', 'n03733805', 'n03742115', 'n03743016', 'n03759954', 'n03761084', 'n03763968', 'n03764736', 'n03769881', 'n03770439', 'n03770679', 'n03773504', 'n03775071', 'n03775546', 'n03776460', 'n03777568', 'n03777754', 'n03781244', 'n03782006', 'n03785016', 'n03786901', 'n03787032', 'n03788195', 'n03788365', 'n03791053', 'n03792782', 'n03792972', 'n03793489', 'n03794056', 'n03796401', 'n03803284', 'n03804744', 'n03814639', 'n03814906', 'n03825788', 'n03832673', 'n03837869', 'n03838899', 'n03840681', 'n03841143', 'n03843555', 'n03854065', 'n03857828', 'n03866082', 'n03868242', 'n03868863', 'n03871628', 'n03873416', 'n03874293', 'n03874599', 'n03876231', 'n03877472', 'n03877845', 'n03884397', 'n03887697', 'n03888257', 'n03888605', 'n03891251', 'n03891332', 'n03895866', 'n03899768', 'n03902125', 'n03903868', 'n03908618', 'n03908714', 'n03916031', 'n03920288', 'n03924679', 'n03929660', 'n03929855', 'n03930313', 'n03930630', 'n03933933', 'n03935335', 'n03937543', 'n03938244', 'n03942813', 'n03944341', 'n03947888', 'n03950228', 'n03954731', 'n03956157', 'n03958227', 'n03961711', 'n03967562', 'n03970156', 'n03976467', 'n03976657', 'n03977966', 'n03980874', 'n03982430', 'n03983396', 'n03991062', 'n03992509', 'n03995372', 'n03998194', 'n04004767', 'n04005630', 'n04008634', 'n04009552', 'n04019541', 'n04023962', 'n04026417', 'n04033901', 'n04033995', 'n04037443', 'n04039381', 'n04040759', 'n04041544', 'n04044716', 'n04049303', 'n04065272', 'n04067472', 'n04069434', 'n04070727', 'n04074963', 'n04081281', 'n04086273', 'n04090263', 'n04099969', 'n04111531', 'n04116512', 'n04118538', 'n04118776', 'n04120489', 'n04125021', 'n04127249', 'n04131690', 'n04133789', 'n04136333', 'n04141076', 'n04141327', 'n04141975', 'n04146614', 'n04147183', 'n04149813', 'n04152593', 'n04153751', 'n04154565', 'n04162706', 'n04179913', 'n04192698', 'n04200800', 'n04201297', 'n04204238', 'n04204347', 'n04208210', 'n04209133', 'n04209239', 'n04228054', 'n04229816', 'n04235860', 'n04238763', 'n04239074', 'n04243546', 'n04251144', 'n04252077', 'n04252225', 'n04254120', 'n04254680', 'n04254777', 'n04258138', 'n04259630', 'n04263257', 'n04264628', 'n04265275', 'n04266014', 'n04270147', 'n04273569', 'n04275548', 'n04277352', 'n04285008', 'n04286575', 'n04296562', 'n04310018', 'n04311004', 'n04311174', 'n04317175', 'n04325704', 'n04326547', 'n04328186', 'n04330267', 'n04332243', 'n04335435', 'n04336792', 'n04344873', 'n04346328', 'n04347754', 'n04350905', 'n04355338', 'n04355933', 'n04356056', 'n04357314', 'n04366367', 'n04367480', 'n04370456', 'n04371430', 'n04371774', 'n04372370', 'n04376876', 'n04380533', 'n04389033', 'n04392985', 'n04398044', 'n04399382', 'n04404412', 'n04409515', 'n04417672', 'n04418357', 'n04423845', 'n04428191', 'n04429376', 'n04435653', 'n04442312', 'n04443257', 'n04447861', 'n04456115', 'n04458633', 'n04461696', 'n04462240', 'n04465501', 'n04467665', 'n04476259', 'n04479046', 'n04482393', 'n04483307', 'n04485082', 'n04486054', 'n04487081', 'n04487394', 'n04493381', 'n04501370', 'n04505470', 'n04507155', 'n04509417', 'n04515003', 'n04517823', 'n04522168', 'n04523525', 'n04525038', 'n04525305', 'n04532106', 'n04532670', 'n04536866', 'n04540053', 'n04542943', 'n04548280', 'n04548362', 'n04550184', 'n04552348', 'n04553703', 'n04554684', 'n04557648', 'n04560804', 'n04562935', 'n04579145', 'n04579432', 'n04584207', 'n04589890', 'n04590129', 'n04591157', 'n04591713', 'n04592741', 'n04596742', 'n04597913', 'n04599235', 'n04604644', 'n04606251', 'n04612504', 'n04613696', 'n06359193', 'n06596364', 'n06785654', 'n06794110', 'n06874185', 'n07248320', 'n07565083', 'n07579787', 'n07583066', 'n07584110', 'n07590611', 'n07613480', 'n07614500', 'n07615774', 'n07684084', 'n07693725', 'n07695742', 'n07697313', 'n07697537', 'n07711569', 'n07714571', 'n07714990', 'n07715103', 'n07716358', 'n07716906', 'n07717410', 'n07717556', 'n07718472', 'n07718747', 'n07720875', 'n07730033', 'n07734744', 'n07742313', 'n07745940', 'n07747607', 'n07749582', 'n07753113', 'n07753275', 'n07753592', 'n07754684', 'n07760859', 'n07768694', 'n07802026', 'n07831146', 'n07836838', 'n07860988', 'n07871810', 'n07873807', 'n07875152', 'n07880968', 'n07892512', 'n07920052', 'n07930864', 'n07932039', 'n09193705', 'n09229709', 'n09246464', 'n09256479', 'n09288635', 'n09332890', 'n09399592', 'n09421951', 'n09428293', 'n09468604', 'n09472597', 'n09835506', 'n10148035', 'n10565667', 'n11879895', 'n11939491', 'n12057211', 'n12144580', 'n12267677', 'n12620546', 'n12768682', 'n12985857', 'n12998815', 'n13037406', 'n13040303', 'n13044778', 'n13052670', 'n13054560', 'n13133613', 'n15075141']def clear_hidden_files(path):dir_list = os.listdir(path)for i in dir_list:abspath = os.path.join(os.path.abspath(path), i)if os.path.isfile(abspath):if i.startswith("._"):os.remove(abspath)else:clear_hidden_files(abspath)def convert(size, box):dw = 1./size[0]dh = 1./size[1]x = (box[0] + box[1])/2.0y = (box[2] + box[3])/2.0w = box[1] - box[0]h = box[3] - box[2]x = x*dww = w*dwy = y*dhh = h*dhreturn (x,y,w,h)def convert_annotation(image_id):in_file = open('VOCdevkit/VOC2007/Annotations/%s.xml' %image_id)out_file = open('VOCdevkit/VOC2007/YOLOLabels/%s.txt' %image_id, 'w')tree=ET.parse(in_file)root = tree.getroot()size = root.find('size')w = int(size.find('width').text)h = int(size.find('height').text)for obj in root.iter('object'):difficult = obj.find('difficult').textcls = obj.find('name').text#在这里完成标签中类别转换# if cls =='n15075141':#cls = 'toilet_tissue'if cls not in classes or int(difficult) == 1:continuecls_id = classes.index(cls)xmlbox = obj.find('bndbox')b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text), float(xmlbox.find('ymin').text), float(xmlbox.find('ymax').text))bb = convert((w,h), b)out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')in_file.close()out_file.close()wd = os.getcwd()wd = os.getcwd()data_base_dir = os.path.join(wd, "VOCdevkit/")if not os.path.isdir(data_base_dir):os.mkdir(data_base_dir)work_sapce_dir = os.path.join(data_base_dir, "VOC2007/")if not os.path.isdir(work_sapce_dir):os.mkdir(work_sapce_dir)annotation_dir = os.path.join(work_sapce_dir, "Annotations/")if not os.path.isdir(annotation_dir):os.mkdir(annotation_dir)clear_hidden_files(annotation_dir)image_dir = os.path.join(work_sapce_dir, "JPEGImages/")if not os.path.isdir(image_dir):os.mkdir(image_dir)clear_hidden_files(image_dir)yolo_labels_dir = os.path.join(work_sapce_dir, "YOLOLabels/")if not os.path.isdir(yolo_labels_dir):os.mkdir(yolo_labels_dir)clear_hidden_files(yolo_labels_dir)yolov5_images_dir = os.path.join(data_base_dir, "images/")if not os.path.isdir(yolov5_images_dir):os.mkdir(yolov5_images_dir)clear_hidden_files(yolov5_images_dir)yolov5_labels_dir = os.path.join(data_base_dir, "labels/")if not os.path.isdir(yolov5_labels_dir):os.mkdir(yolov5_labels_dir)clear_hidden_files(yolov5_labels_dir)yolov5_images_train_dir = os.path.join(yolov5_images_dir, "train/")if not os.path.isdir(yolov5_images_train_dir):os.mkdir(yolov5_images_train_dir)clear_hidden_files(yolov5_images_train_dir)yolov5_images_test_dir = os.path.join(yolov5_images_dir, "val/")if not os.path.isdir(yolov5_images_test_dir):os.mkdir(yolov5_images_test_dir)clear_hidden_files(yolov5_images_test_dir)yolov5_labels_train_dir = os.path.join(yolov5_labels_dir, "train/")if not os.path.isdir(yolov5_labels_train_dir):os.mkdir(yolov5_labels_train_dir)clear_hidden_files(yolov5_labels_train_dir)yolov5_labels_test_dir = os.path.join(yolov5_labels_dir, "val/")if not os.path.isdir(yolov5_labels_test_dir):os.mkdir(yolov5_labels_test_dir)clear_hidden_files(yolov5_labels_test_dir)train_file = open(os.path.join(wd, "yolov8_train.txt"), 'w')test_file = open(os.path.join(wd, "yolov8_val.txt"), 'w')train_file.close()test_file.close()train_file = open(os.path.join(wd, "yolov8_train.txt"), 'a')test_file = open(os.path.join(wd, "yolov8_val.txt"), 'a')list_imgs = os.listdir(image_dir) # list image filesprobo = random.randint(1, 100)print("Probobility: %d" % probo)for i in range(0,len(list_imgs)):path = os.path.join(image_dir,list_imgs[i])if os.path.isfile(path):image_path = image_dir + list_imgs[i]voc_path = list_imgs[i](nameWithoutExtention, extention) = os.path.splitext(os.path.basename(image_path))(voc_nameWithoutExtention, voc_extention) = os.path.splitext(os.path.basename(voc_path))annotation_name = nameWithoutExtention + '.xml'annotation_path = os.path.join(annotation_dir, annotation_name)label_name = nameWithoutExtention + '.txt'label_path = os.path.join(yolo_labels_dir, label_name)probo = random.randint(1, 100)print("Probobility: %d" % probo)if(probo < 80): # train datasetif os.path.exists(annotation_path):train_file.write(image_path + '\n')convert_annotation(nameWithoutExtention) # convert labelcopyfile(image_path, yolov5_images_train_dir + voc_path)copyfile(label_path, yolov5_labels_train_dir + label_name)else: # test datasetif os.path.exists(annotation_path):test_file.write(image_path + '\n')convert_annotation(nameWithoutExtention) # convert labelcopyfile(image_path, yolov5_images_test_dir + voc_path)copyfile(label_path, yolov5_labels_test_dir + label_name)train_file.close()test_file.close()
这样转换后,类别信息就对啦!
最后修改.yaml文件
同样也是需要修改类别信息
将1000类插入进去
代码如下
#读取所有的行数,并按列输出SaveList = []# 存档列表# 读取文本内容到列表filepath = r'D:\code\yolov8-pytorch-master\voc_classes3.txt'with open(filepath, "r", encoding='utf-8') as file:for line in file:line = line.strip('\n')# 删除换行符SaveList.append(line)file.close()print(SaveList)#写入存档到文件writhpath = r'D:\code\yolov8-pytorch-master\voc_classes4.txt'#(按列写入)# with open(writhpath,"w",encoding='utf-8') as file:#for i,j,z in zip(SaveList[0].split(), SaveList[1].split(), SaveList[2].split()):#此处修改为你自己的行数SaveList[1],或者添加行#file.write(str(i)+''+str(j)+''+str(z)+'\n')#file.close()#按行写入with open(writhpath,"w+",encoding='utf-8') as file2:i = 0#类别起始编号for line in SaveList:file2.writelines(str(i) + ': '+line+'\n')i = i+1file2.close()
日常工具搬运——逐行写入txt文件
按行读取txt文件任意行内容,并按列写入另一个txt文件中(修改行数后直接使用)
结果如下:
0: tench1: goldfish2: great_white_shark3: tiger_shark4: hammerhead5: electric_ray6: stingray7: cock8: hen9: ostrich10: brambling11: goldfinch12: house_finch13: junco14: indigo_bunting15: robin16: bulbul17: jay18: magpie19: chickadee20: water_ouzel21: kite22: bald_eagle23: vulture24: great_grey_owl25: European_fire_salamander26: common_newt27: eft28: spotted_salamander29: axolotl30: bullfrog31: tree_frog32: tailed_frog33: loggerhead34: leatherback_turtle35: mud_turtle36: terrapin37: box_turtle38: banded_gecko39: common_iguana40: American_chameleon41: whiptail42: agama43: frilled_lizard44: alligator_lizard45: Gila_monster46: green_lizard47: African_chameleon48: Komodo_dragon49: African_crocodile50: American_alligator51: triceratops52: thunder_snake53: ringneck_snake54: hognose_snake55: green_snake56: king_snake57: garter_snake58: water_snake59: vine_snake60: night_snake61: boa_constrictor62: rock_python63: Indian_cobra64: green_mamba65: sea_snake66: horned_viper67: diamondback68: sidewinder69: trilobite70: harvestman71: scorpion72: black_and_gold_garden_spider73: barn_spider74: garden_spider75: black_widow76: tarantula77: wolf_spider78: tick79: centipede80: black_grouse81: ptarmigan82: ruffed_grouse83: prairie_chicken84: peacock85: quail86: partridge87: African_grey88: macaw89: sulphur-crested_cockatoo90: lorikeet91: coucal92: bee_eater93: hornbill94: hummingbird95: jacamar96: toucan97: drake98: red-breasted_merganser99: goose100: black_swan101: tusker102: echidna103: platypus104: wallaby105: koala106: wombat107: jellyfish108: sea_anemone109: brain_coral110: flatworm111: nematode112: conch113: snail114: slug115: sea_slug116: chiton117: chambered_nautilus118: Dungeness_crab119: rock_crab120: fiddler_crab121: king_crab122: American_lobster123: spiny_lobster124: crayfish125: hermit_crab126: isopod127: white_stork128: black_stork129: spoonbill130: flamingo131: little_blue_heron132: American_egret133: bittern134: crane135: limpkin136: European_gallinule137: American_coot138: bustard139: ruddy_turnstone140: red-backed_sandpiper141: redshank142: dowitcher143: oystercatcher144: pelican145: king_penguin146: albatross147: grey_whale148: killer_whale149: dugong150: sea_lion151: Chihuahua152: Japanese_spaniel153: Maltese_dog154: Pekinese155: Shih-Tzu156: Blenheim_spaniel157: papillon158: toy_terrier159: Rhodesian_ridgeback160: Afghan_hound161: basset162: beagle163: bloodhound164: bluetick165: black-and-tan_coonhound166: Walker_hound167: English_foxhound168: redbone169: borzoi170: Irish_wolfhound171: Italian_greyhound172: whippet173: Ibizan_hound174: Norwegian_elkhound175: otterhound176: Saluki177: Scottish_deerhound178: Weimaraner179: Staffordshire_bullterrier180: American_Staffordshire_terrier181: Bedlington_terrier182: Border_terrier183: Kerry_blue_terrier184: Irish_terrier185: Norfolk_terrier186: Norwich_terrier187: Yorkshire_terrier188: wire-haired_fox_terrier189: Lakeland_terrier190: Sealyham_terrier191: Airedale192: cairn193: Australian_terrier194: Dandie_Dinmont195: Boston_bull196: miniature_schnauzer197: giant_schnauzer198: standard_schnauzer199: Scotch_terrier200: Tibetan_terrier201: silky_terrier202: soft-coated_wheaten_terrier203: West_Highland_white_terrier204: Lhasa205: flat-coated_retriever206: curly-coated_retriever207: golden_retriever208: Labrador_retriever209: Chesapeake_Bay_retriever210: German_short-haired_pointer211: vizsla212: English_setter213: Irish_setter214: Gordon_setter215: Brittany_spaniel216: clumber217: English_springer218: Welsh_springer_spaniel219: cocker_spaniel220: Sussex_spaniel221: Irish_water_spaniel222: kuvasz223: schipperke224: groenendael225: malinois226: briard227: kelpie228: komondor229: Old_English_sheepdog230: Shetland_sheepdog231: collie232: Border_collie233: Bouvier_des_Flandres234: Rottweiler235: German_shepherd236: Doberman237: miniature_pinscher238: Greater_Swiss_Mountain_dog239: Bernese_mountain_dog240: Appenzeller241: EntleBucher242: boxer243: bull_mastiff244: Tibetan_mastiff245: French_bulldog246: Great_Dane247: Saint_Bernard248: Eskimo_dog249: malamute250: Siberian_husky251: dalmatian252: affenpinscher253: basenji254: pug255: Leonberg256: Newfoundland257: Great_Pyrenees258: Samoyed259: Pomeranian260: chow261: keeshond262: Brabancon_griffon263: Pembroke264: Cardigan265: toy_poodle266: miniature_poodle267: standard_poodle268: Mexican_hairless269: timber_wolf270: white_wolf271: red_wolf272: coyote273: dingo274: dhole275: African_hunting_dog276: hyena277: red_fox278: kit_fox279: Arctic_fox280: grey_fox281: tabby282: tiger_cat283: Persian_cat284: Siamese_cat285: Egyptian_cat286: cougar287: lynx288: leopard289: snow_leopard290: jaguar291: lion292: tiger293: cheetah294: brown_bear295: American_black_bear296: ice_bear297: sloth_bear298: mongoose299: meerkat300: tiger_beetle301: ladybug302: ground_beetle303: long-horned_beetle304: leaf_beetle305: dung_beetle306: rhinoceros_beetle307: weevil308: fly309: bee310: ant311: grasshopper312: cricket313: walking_stick314: cockroach315: mantis316: cicada317: leafhopper318: lacewing319: dragonfly320: damselfly321: admiral322: ringlet323: monarch324: cabbage_butterfly325: sulphur_butterfly326: lycaenid327: starfish328: sea_urchin329: sea_cucumber330: wood_rabbit331: hare332: Angora333: hamster334: porcupine335: fox_squirrel336: marmot337: beaver338: guinea_pig339: sorrel340: zebra341: hog342: wild_boar343: warthog344: hippopotamus345: ox346: water_buffalo347: bison348: ram349: bighorn350: ibex351: hartebeest352: impala353: gazelle354: Arabian_camel355: llama356: weasel357: mink358: polecat359: black-footed_ferret360: otter361: skunk362: badger363: armadillo364: three-toed_sloth365: orangutan366: gorilla367: chimpanzee368: gibbon369: siamang370: guenon371: patas372: baboon373: macaque374: langur375: colobus376: proboscis_monkey377: marmoset378: capuchin379: howler_monkey380: titi381: spider_monkey382: squirrel_monkey383: Madagascar_cat384: indri385: Indian_elephant386: African_elephant387: lesser_panda388: giant_panda389: barracouta390: eel391: coho392: rock_beauty393: anemone_fish394: sturgeon395: gar396: lionfish397: puffer398: abacus399: abaya400: academic_gown401: accordion402: acoustic_guitar403: aircraft_carrier404: airliner405: airship406: altar407: ambulance408: amphibian409: analog_clock410: apiary411: apron412: ashcan413: assault_rifle414: backpack415: bakery416: balance_beam417: balloon418: ballpoint419: Band_Aid420: banjo421: bannister422: barbell423: barber_chair424: barbershop425: barn426: barometer427: barrel428: barrow429: baseball430: basketball431: bassinet432: bassoon433: bathing_cap434: bath_towel435: bathtub436: beach_wagon437: beacon438: beaker439: bearskin440: beer_bottle441: beer_glass442: bell_cote443: bib444: bicycle-built-for-two445: bikini446: binder447: binoculars448: birdhouse449: boathouse450: bobsled451: bolo_tie452: bonnet453: bookcase454: bookshop455: bottlecap456: bow457: bow_tie458: brass459: brassiere460: breakwater461: breastplate462: broom463: bucket464: buckle465: bulletproof_vest466: bullet_train467: butcher_shop468: cab469: caldron470: candle471: cannon472: canoe473: can_opener474: cardigan475: car_mirror476: carousel477: carpenter’s_kit478: carton479: car_wheel480: cash_machine481: cassette482: cassette_player483: castle484: catamaran485: CD_player486: cello487: cellular_telephone488: chain489: chainlink_fence490: chain_mail491: chain_saw492: chest493: chiffonier494: chime495: china_cabinet496: Christmas_stocking497: church498: cinema499: cleaver500: cliff_dwelling501: cloak502: clog503: cocktail_shaker504: coffee_mug505: coffeepot506: coil507: combination_lock508: computer_keyboard509: confectionery510: container_ship511: convertible512: corkscrew513: cornet514: cowboy_boot515: cowboy_hat516: cradle517: crane518: crash_helmet519: crate520: crib521: Crock_Pot522: croquet_ball523: crutch524: cuirass525: dam526: desk527: desktop_computer528: dial_telephone529: diaper530: digital_clock531: digital_watch532: dining_table533: dishrag534: dishwasher535: disk_brake536: dock537: dogsled538: dome539: doormat540: drilling_platform541: drum542: drumstick543: dumbbell544: Dutch_oven545: electric_fan546: electric_guitar547: electric_locomotive548: entertainment_center549: envelope550: espresso_maker551: face_powder552: feather_boa553: file554: fireboat555: fire_engine556: fire_screen557: flagpole558: flute559: folding_chair560: football_helmet561: forklift562: fountain563: fountain_pen564: four-poster565: freight_car566: French_horn567: frying_pan568: fur_coat569: garbage_truck570: gasmask571: gas_pump572: goblet573: go-kart574: golf_ball575: golfcart576: gondola577: gong578: gown579: grand_piano580: greenhouse581: grille582: grocery_store583: guillotine584: hair_slide585: hair_spray586: half_track587: hammer588: hamper589: hand_blower590: hand-held_computer591: handkerchief592: hard_disc593: harmonica594: harp595: harvester596: hatchet597: holster598: home_theater599: honeycomb600: hook601: hoopskirt602: horizontal_bar603: horse_cart604: hourglass605: iPod606: iron607: jack-o’-lantern608: jean609: jeep610: jersey611: jigsaw_puzzle612: jinrikisha613: joystick614: kimono615: knee_pad616: knot617: lab_coat618: ladle619: lampshade620: laptop621: lawn_mower622: lens_cap623: letter_opener624: library625: lifeboat626: lighter627: limousine628: liner629: lipstick630: Loafer631: lotion632: loudspeaker633: loupe634: lumbermill635: magnetic_compass636: mailbag637: mailbox638: maillot639: maillot640: manhole_cover641: maraca642: marimba643: mask644: matchstick645: maypole646: maze647: measuring_cup648: medicine_chest649: megalith650: microphone651: microwave652: military_uniform653: milk_can654: minibus655: miniskirt656: minivan657: missile658: mitten659: mixing_bowl660: mobile_home661: Model_T662: modem663: monastery664: monitor665: moped666: mortar667: mortarboard668: mosque669: mosquito_net670: motor_scooter671: mountain_bike672: mountain_tent673: mouse674: mousetrap675: moving_van676: muzzle677: nail678: neck_brace679: necklace680: nipple681: notebook682: obelisk683: oboe684: ocarina685: odometer686: oil_filter687: organ688: oscilloscope689: overskirt690: oxcart691: oxygen_mask692: packet693: paddle694: paddlewheel695: padlock696: paintbrush697: pajama698: palace699: panpipe700: paper_towel701: parachute702: parallel_bars703: park_bench704: parking_meter705: passenger_car706: patio707: pay-phone708: pedestal709: pencil_box710: pencil_sharpener711: perfume712: Petri_dish713: photocopier714: pick715: pickelhaube716: picket_fence717: pickup718: pier719: piggy_bank720: pill_bottle721: pillow722: ping-pong_ball723: pinwheel724: pirate725: pitcher726: plane727: planetarium728: plastic_bag729: plate_rack730: plow731: plunger732: Polaroid_camera733: pole734: police_van735: poncho736: pool_table737: pop_bottle738: pot739: potter’s_wheel740: power_drill741: prayer_rug742: printer743: prison744: projectile745: projector746: puck747: punching_bag748: purse749: quill750: quilt751: racer752: racket753: radiator754: radio755: radio_telescope756: rain_barrel757: recreational_vehicle758: reel759: reflex_camera760: refrigerator761: remote_control762: restaurant763: revolver764: rifle765: rocking_chair766: rotisserie767: rubber_eraser768: rugby_ball769: rule770: running_shoe771: safe772: safety_pin773: saltshaker774: sandal775: sarong776: sax777: scabbard778: scale779: school_bus780: schooner781: scoreboard782: screen783: screw784: screwdriver785: seat_belt786: sewing_machine787: shield788: shoe_shop789: shoji790: shopping_basket791: shopping_cart792: shovel793: shower_cap794: shower_curtain795: ski796: ski_mask797: sleeping_bag798: slide_rule799: sliding_door800: slot801: snorkel802: snowmobile803: snowplow804: soap_dispenser805: soccer_ball806: sock807: solar_dish808: sombrero809: soup_bowl810: space_bar811: space_heater812: space_shuttle813: spatula814: speedboat815: spider_web816: spindle817: sports_car818: spotlight819: stage820: steam_locomotive821: steel_arch_bridge822: steel_drum823: stethoscope824: stole825: stone_wall826: stopwatch827: stove828: strainer829: streetcar830: stretcher831: studio_couch832: stupa833: submarine834: suit835: sundial836: sunglass837: sunglasses838: sunscreen839: suspension_bridge840: swab841: sweatshirt842: swimming_trunks843: swing844: switch845: syringe846: table_lamp847: tank848: tape_player849: teapot850: teddy851: television852: tennis_ball853: thatch854: theater_curtain855: thimble856: thresher857: throne858: tile_roof859: toaster860: tobacco_shop861: toilet_seat862: torch863: totem_pole864: tow_truck865: toyshop866: tractor867: trailer_truck868: tray869: trench_coat870: tricycle871: trimaran872: tripod873: triumphal_arch874: trolleybus875: trombone876: tub877: turnstile878: typewriter_keyboard879: umbrella880: unicycle881: upright882: vacuum883: vase884: vault885: velvet886: vending_machine887: vestment888: viaduct889: violin890: volleyball891: waffle_iron892: wall_clock893: wallet894: wardrobe895: warplane896: washbasin897: washer898: water_bottle899: water_jug900: water_tower901: whiskey_jug902: whistle903: wig904: window_screen905: window_shade906: Windsor_tie907: wine_bottle908: wing909: wok910: wooden_spoon911: wool912: worm_fence913: wreck914: yawl915: yurt916: web_site917: comic_book918: crossword_puzzle919: street_sign920: traffic_light921: book_jacket922: menu923: plate924: guacamole925: consomme926: hot_pot927: trifle928: ice_cream929: ice_lolly930: French_loaf931: bagel932: pretzel933: cheeseburger934: hotdog935: mashed_potato936: head_cabbage937: broccoli938: cauliflower939: zucchini940: spaghetti_squash941: acorn_squash942: butternut_squash943: cucumber944: artichoke945: bell_pepper946: cardoon947: mushroom948: Granny_Smith949: strawberry950: orange951: lemon952: fig953: pineapple954: banana955: jackfruit956: custard_apple957: pomegranate958: hay959: carbonara960: chocolate_sauce961: dough962: meat_loaf963: pizza964: potpie965: burrito966: red_wine967: espresso968: cup969: eggnog970: alp971: bubble972: cliff973: coral_reef974: geyser975: lakeside976: promontory977: sandbar978: seashore979: valley980: volcano981: ballplayer982: groom983: scuba_diver984: rapeseed985: daisy986: yellow_lady’s_slipper987: corn988: acorn989: hip990: buckeye991: coral_fungus992: agaric993: gyromitra994: stinkhorn995: earthstar996: hen-of-the-woods997: bolete998: ear999: toilet_tissue
整合到.yaml中(前面需要空两格)
完成
数据集介绍
数据集介绍