Test your split data function not printing expected output

Hello @Waffles ,

Thanks for your response! I have seen your code snippet. I will be explaining here in detail and hope this will clear all your doubts.

For split function, you have directly written directories without defining anything before like this :

TRAINING_DIR = train_dir
VALIDATION_DIR = validation_dir

For which you were getting 0 images.
You need to define the things at first, step by step.

I would suggest you to go through the hint .

  1. It’s given in the hint :
    All images should be checked before the copy, so if they have a zero file length, they will be omitted from the copying process. If this is the case then your function should print out a message such as "filename is zero length, so ignoring.". You should perform this check before the split so that only non-zero images are considered when doing the actual split.
    Hence you need to write a condition to check if file size is greater than 0 and accept only the ones >0.

  2. It’s given in the hint : For example, if SOURCE_DIR is PetImages/Cat, and SPLIT_SIZE is .9 then 90% of the images in PetImages/Cat will be copied to the TRAINING_DIR directory and 10% of the images will be copied to the VALIDATION_DIR directory.
    So you have to Divide the file size into 2 parts- Test data size and train data size, which you can get using the split size like the above.

  3. Then group data in 2 sets.

  4. Then finally write code for the directory path for the training set and test set

Note : You need to do the above, using the given Hints below:

os.listdir(DIRECTORY) returns a list with the contents of that directory.
os.path.getsize(PATH) returns the size of the file
copyfile(source, destination) copies a file from source to destination
random.sample(list, len(list)) shuffles a list

Hope this helps.

With regards,
Nilosree Sengupta