26 lines
1.4 KiB
Python
Executable File
26 lines
1.4 KiB
Python
Executable File
'''
|
||
author : Hatcher W
|
||
Email: hcwang@semi.ac.cn
|
||
use: 用于根据VOC的images中train和test的图像文件分成annotation 的xml文件,将Annotation分开放到Anno_train,Anno_val中,
|
||
input:images/train ,test 图像文件路径
|
||
output:COCO/Anno_train and COCO/Anno_val
|
||
'''
|
||
import os,shutil
|
||
from tqdm import tqdm
|
||
rootPath = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/images/train"
|
||
rootPathxml = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/Annotations"
|
||
rootresultpath = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/COCO/Anno_train"
|
||
if not os.path.exists(rootresultpath):
|
||
os.makedirs(rootresultpath)
|
||
for image in tqdm(os.listdir(rootPath)):
|
||
shutil.copy(os.path.join(rootPathxml,image.replace(".jpg",".xml").replace(".png",".xml")),os.path.join(rootresultpath,image.replace(".jpg",".xml").replace(".png",".xml")))
|
||
#exit()
|
||
|
||
rootPath = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/images/test"
|
||
rootPathxml = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/Annotations"
|
||
rootresultpath = "/data4/Hatcher/smallobject/voc_class/CDB_vehicle/COCO/Anno_test"
|
||
if not os.path.exists(rootresultpath):
|
||
os.makedirs(rootresultpath)
|
||
for image in tqdm(os.listdir(rootPath)):
|
||
shutil.copy(os.path.join(rootPathxml,image.replace(".jpg",".xml").replace(".png",".xml")),os.path.join(rootresultpath,image.replace(".jpg",".xml").replace(".png",".xml")))
|