A simple approach to check for valid data would be to print the final img9_path, where the images should be located, copy this path, and check the files in the terminal via:
ls COPIED_PATH | grep png

If no output is shown, this folder does not contain any png files and the choice operation is thus expected to fail.