0

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.

Yavuz A.
  • 11
  • 5
  • How are you recognizing which files are what? BTW, `os.listdir(class_file)` isn't going to work on a individual file, it needs to be passed a directory, not file, path-name. – martineau Feb 17 '19 at 21:42
  • i identify class_file as a path above class_file = os.path.join(dataset_dir, f) – Yavuz A. Feb 17 '19 at 21:48
  • I meant the line `ships = os.listdir(class_file)` isn't going to work because `class_file` isn't a directory. I also think you need to [edit] your question and correct the indentation of the code, which matters a great deal in Python. – martineau Feb 17 '19 at 22:39

0 Answers0