dimanche 17 février 2019

How to save and remove some of images to other files in Python?

Although i am new at Python i am trying to classify some images. Since i have to augment my train dataset, i decided to split my test and train images into different files. Now, i am trying to remove and save the test images into other files. But after the images had been finished to read i don't now what i will do.

dataset_dir = "C:/Users/asus/Desktop/TEZ/Dataset"
test_dataset_dir = "C:/Users/asus/Desktop/TEZ/TEST"

classes = os.listdir(dataset_dir)
label = 0
if not os.path.exists(test_dataset_dir):
       os.makedirs(test_dataset_dir)

for f in classes:
    if not f.startswith('.'):
       class_file = os.path.join(dataset_dir, f)
       out_class_file = os.path.join(test_dataset_dir, f)
       if not os.path.exists(out_class_file):
              os.makedirs(out_class_file)
              print(f)
              label += 1
              ships = os.listdir(class_file)
              for ship in ships:
              ship_name = os.path.join(class_file, ship)
              img = data.load(ship_name)
              test_set.append(img)
              if s in test_set # i don't know how i can teach that ship in 
last file were read and split in 20% for the code which is below  
sec = 0.2
tis = random.sample(test_set, int(sec*len(test_set)))
tis.remove

Please help me and excuse me for my english.

Aucun commentaire:

Enregistrer un commentaire