No, the script doesn’t need to be in the same folder.
Note that the passed folder should contain subfolders with the images. The images should not be in the passed root folder. Did you make sure that’s the case?