target_file = '/kaggle/working'/path/'forest'
i = 0
for file in target_file.iterdir():
print(file)
Image.open(file).to_thumb(256,256)
i+=1
if i > 5:
break
Output is as follows:
/kaggle/working/bird_or_not/forest/9c34f24c-5db1-4a03-9ef7-60b53f6e2b2e.jpg
/kaggle/working/bird_or_not/forest/e0062310-e425-4058-8bba-00a26b9b81bc.jpg
/kaggle/working/bird_or_not/forest/4ceb232b-8be0-4ede-ba38-85193e1fec91.jpg
/kaggle/working/bird_or_not/forest/d764afd2-8419-4de3-9372-498bb70cec65.jpeg
/kaggle/working/bird_or_not/forest/9a1e05f9-d31d-4c15-b819-e91290dd1c32.jpg
/kaggle/working/bird_or_not/forest/67ca71d8-6059-444f-8351-ec78eb19ae2b.jpeg
And If I give the specific file name, than it is working, i.e. After running the below command, I see the image
Image.open('bird_or_not/forest/ca274e96-48c9-46b3-9eeb-a98ddf3f665d.jpeg').to_thumb(256,256)
I want to why is it not working, if I am providing the file name in a variable format.
New contributor
Arushi_22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.