Failed test case: incorrect number of (training, testing) images when using a split of 0.5 and 12 images (6 are zero-sized).
Expected:
(3, 3),
but got:
(5, 1).
I use the round up for splitting datasets sometimes it works but sometimes it fails
I just wonder the best way to solve this problem
For this, Inside the function, we need to filter images that are of size 0. The hint for this is given in the markdown above the function also. Hope this solves your problem.
I have a similar problem. I got 48 out of 50 points for this part. My code detects only 3 out of 6 zero-sized images using os.path.getsize(IMG_PATH) resulting in a split of (4,5). However the OP’s zero-image detector seems to work well since he was left with 6 non-zero images. Is there a hint I am missing from your answer? I set IMG_PATH to the source directory + image filename using os.path.join and looked for os.path.getsize(IMG_PATH) with values equal to 0.
Nevermind, I was able to solve it.
It seems like setting the condition to ignore file sizes exactly equal to 0 fails a test case. When I revised my code to consider only images with file sizes greater than 0 (ignoring everything else), then I passed all test cases and got a perfect score.