Make the generate_images even more generic