import os
import shutil
import xml.etree.ElementTree as ET
import pdb
#shutil.rmtree(os.getcwd()+"/VOC2007");
os.mkdir (os.getcwd()+"/VOC2007");
os.mkdir (os.getcwd()+"/VOC2007/Annotations");
os.mkdir (os.getcwd()+"/VOC2007/ImageSets");
os.mkdir (os.getcwd()+"/VOC2007/ImageSets/Main");
os.mkdir (os.getcwd()+"/VOC2007/JPEGImages");
my_files = os.listdir(os.getcwd()+"/");
for files in my_files:
if "jpg" in files:
print(os.getcwd() + "/" + files)
print('\n')
print(os.getcwd()+"/VOC2007/JPEGImages/" + files)
#pdb.set_trace()
shutil.copyfile(os.getcwd() + "/" + files, os.getcwd()+"/VOC2007/JPEGImages/" + files)
for files in my_files:
if "xml" in files:
shutil.copyfile(os.getcwd() + "/" + files, os.getcwd()+"/VOC2007/Annotations/" + files)
#my_files = os.listdir("jpg");
#print(my_files)
listFiles = []
for files in my_files:
if "jpg" in files:
#print(files)
listFiles.append(files[:-4])
listFiles.sort()
fo = open(os.getcwd()+"/VOC2007/ImageSets/Main/" + "trainval.txt", "w")
for fileName in listFiles:
fo.write(fileName + "\n")
print(fileName)
fo.close()
fo = open(os.getcwd()+"/VOC2007/ImageSets/Main/" + "test.txt", "w")
for fileName in listFiles:
fo.write(fileName + "\n")
print(fileName)
fo.close()