In [1]:
import LoadDataset

In [2]:
# Dumps all Datasets in HDF5 format for each image seaparately
for numDigits in range(5,10):
    LoadDataset.createHDF5FixedNumDigits(numDigits)

In [12]:
# Test the datasets
import matplotlib.pyplot as plt
from PIL import Image
import h5py
f,ax = plt.subplots(1,2, figsize=(15,15))
for i in range(6,7):
    h5File = h5py.File('svhn_' + str(i) + '.h5')
    img = h5File['images'][0]
    label = h5File['digits'][0]
    ax[i].imshow(img, cmap = 'gray')
    print (str(i) + ' -> ' + str(label))
    h5File.close()
plt.show() # or display.display(plt.gcf()) if you prefer


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-06e281e92c63> in <module>()
      6 for i in range(6,7):
      7     h5File = h5py.File('svhn_' + str(i) + '.h5')
----> 8     img = h5File['images'][0]
      9     label = h5File['digits'][0]
     10     ax[i-5].imshow(img, cmap = 'gray')

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)()

/home/ankdesh/installed/anaconda2/envs/tf0.11/lib/python2.7/site-packages/h5py/_hl/dataset.pyc in __getitem__(self, args)
    460 
    461         # Perform the dataspace selection.
--> 462         selection = sel.select(self.shape, args, dsid=self.id)
    463 
    464         if selection.nselect == 0:

/home/ankdesh/installed/anaconda2/envs/tf0.11/lib/python2.7/site-packages/h5py/_hl/selections.pyc in select(shape, args, dsid)
     90 
     91     sel = SimpleSelection(shape)
---> 92     sel[args]
     93     return sel
     94 

/home/ankdesh/installed/anaconda2/envs/tf0.11/lib/python2.7/site-packages/h5py/_hl/selections.pyc in __getitem__(self, args)
    257             return self
    258 
--> 259         start, count, step, scalar = _handle_simple(self.shape,args)
    260 
    261         self._id.select_hyperslab(start, count, step)

/home/ankdesh/installed/anaconda2/envs/tf0.11/lib/python2.7/site-packages/h5py/_hl/selections.pyc in _handle_simple(shape, args)
    445         else:
    446             try:
--> 447                 x,y,z = _translate_int(int(arg), length)
    448                 s = True
    449             except TypeError:

/home/ankdesh/installed/anaconda2/envs/tf0.11/lib/python2.7/site-packages/h5py/_hl/selections.pyc in _translate_int(exp, length)
    465 
    466     if not 0<=exp<length:
--> 467         raise ValueError("Index (%s) out of range (0-%s)" % (exp, length-1))
    468 
    469     return exp, 1, 1

ValueError: Index (0) out of range (0--1)

In [ ]: