I have this code:
import random
rand_smpl = [ test_folders[i] for i in sorted(random.sample(xrange(len(test_folders)), 1)) ]
print(rand_smpl)
from IPython.display import Image, display
listOfImageNames = []
from os import walk
filenames = next(os.walk(rand_smpl[0]))[2]
rand_smpl = [ filenames[i] for i in sorted(random.sample(xrange(len(filenames)), 5)) ]
print(rand_smpl)
for imageName in rand_smpl:
display(Image(filename=imageName))
which is executed on the right directory (as far as I can tell) and I am getting:
['notMNIST_small/B']
['Rm9saW8gQmsgQlQgQm9sZC50dGY=.png', 'Q2hhbnRpbGx5LU1lZGl1bS5vdGY=.png', 'Q2hvd2RlcmhlYWQudHRm.png', 'Q2hlbmdhbHVsdS5vdGY=.png', 'R2lsbFNhbnNNVFN0ZC1Cb2xkLm90Zg==.png']
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-20-aae06acf1bd0> in <module>()
9 print(rand_smpl)
10 for imageName in rand_smpl:
---> 11 display(Image(filename=imageName))
...................<traceback continues>
IOError: [Errno 2] No such file or directory: u'Rm9saW8gQmsgQlQgQm9sZC50dGY=.png'
where I manually checked if the image exists and it does so. How to fix this?
I think that this has to do with the encoding maybe of the filename.
Aucun commentaire:
Enregistrer un commentaire