You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/17 21:56:23 UTC

[GitHub] rlantz-cfa opened a new issue #9114: Invalid RecordIO File

rlantz-cfa opened a new issue #9114: Invalid RecordIO File
URL: https://github.com/apache/incubator-mxnet/issues/9114
 
 
   I run a modified version of im2rec.py with the following to create the list files:
   `$ python ./incubator-mxnet/tools/im2rec.py --list True --train-ratio 0.7 --test-ratio 0.2 prefix ./jpegs`
   Attached is a sample from the .lst file.  
   ![lst file](https://user-images.githubusercontent.com/34374700/34084179-3d9168c0-e34a-11e7-878c-72b5b5b55fa3.png)
   
   I then run im2rec.py again to create the .rec and .idx files:
   `$ python ./incubator-mxnet/tools/im2rec.py prefix ./jpegs --pack-label True`
   
   When I try to read them in with code more or less borrowed from the gluon tutorial: 
   ```
   import mxnet.image as image
   data_shape = 400
   batch_size = 64
   
   def get_iterators(data_shape, batch_size):
       class_names = ['building']
       num_classes = len(class_names)
       train_iter = image.ImageDetIter(
           batch_size = batch_size,
           data_shape = (3, data_shape, data_shape),
           path_imgrec = './data/prefix_train.rec',
           path_imglist = './data/prefix_train.lst',
           path_imgidx = './data/prefix_train.idx',
           shuffle = True,
           mean = True, 
           rand_crop = 1,
           min_object_covered = 0.6,
           max_attempts = 200)
       print("Successful Train.")
       val_iter = image.ImageDetIter(
           batch_size = batch_size,
           data_shape = (3, data_shape, data_shape),
           path_imgrec = './data/prefix_val.rec',
           shuffle = False,
           mean = True)
       return train_iter, val_iter, class_names, num_classes
   
   train_data, test_data, class_names, num_class = get_iterators(data_shape, batch_size)
   batch = train_data.next()
   print(batch)
   ```
   And I get the following error:
   ```
   MXNetError                                Traceback (most recent call last)
   <ipython-input-28-77a6d1f4b9a8> in <module>()
        26     return train_iter, val_iter, class_names, num_classes
        27 
   ---> 28 train_data, test_data, class_names, num_class = get_iterators(data_shape, batch_size)
        29 batch = train_data.next()
        30 print(batch)
   
   <ipython-input-28-77a6d1f4b9a8> in get_iterators(data_shape, batch_size)
        16         rand_crop = 1,
        17         min_object_covered = 0.6,
   ---> 18         max_attempts = 200)
        19     print("Successful Train.")
        20     val_iter = image.ImageDetIter(
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/image/detection.py in __init__(self, batch_size, data_shape, path_imgrec, path_imglist, path_root, path_imgidx, shuffle, part_index, num_parts, aug_list, imglist, data_name, label_name, **kwargs)
       679 
       680         # went through all labels to get the proper label shape
   --> 681         label_shape = self._estimate_label_shape()
       682         self.provide_label = [(label_name, (self.batch_size, label_shape[0], label_shape[1]))]
       683         self.label_shape = label_shape
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/image/detection.py in _estimate_label_shape(self)
       699         try:
       700             while True:
   --> 701                 label, _ = self.next_sample()
       702                 label = self._parse_label(label)
       703                 max_count = max(max_count, label.shape[0])
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/image/image.py in next_sample(self)
      1147             self.cur += 1
      1148             if self.imgrec is not None:
   -> 1149                 s = self.imgrec.read_idx(idx)
      1150                 header, img = recordio.unpack(s)
      1151                 if self.imglist is None:
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/recordio.py in read_idx(self, idx)
       263         """
       264         self.seek(idx)
   --> 265         return self.read()
       266 
       267     def write_idx(self, idx, buf):
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/recordio.py in read(self)
       161         check_call(_LIB.MXRecordIOReaderReadRecord(self.handle,
       162                                                    ctypes.byref(buf),
   --> 163                                                    ctypes.byref(size)))
       164         if buf:
       165             buf = ctypes.cast(buf, ctypes.POINTER(ctypes.c_char*size.value))
   
   ~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/base.py in check_call(ret)
       144     """
       145     if ret != 0:
   --> 146         raise MXNetError(py_str(_LIB.MXGetLastError()))
       147 
       148 if sys.version_info[0] < 3:
   
   MXNetError: [21:30:52] src/recordio.cc:65: Check failed: header[0] == RecordIOWriter::kMagic Invalid RecordIO File
   
   Stack trace returned 10 entries:
   [bt] (0) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x2664d2b) [0x7ff4c3d58d2b]
   [bt] (1) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/libmxnet.so(MXRecordIOReaderReadRecord+0x1e) [0x7ff4c375f6be]
   [bt] (2) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7ff502c7c5b0]
   [bt] (3) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call+0x1f5) [0x7ff502c7bd55]
   [bt] (4) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x3dc) [0x7ff502c7389c]
   [bt] (5) /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(+0x9df3) [0x7ff502c6bdf3]
   [bt] (6) /home/ec2-user/anaconda3/envs/mxnet_p36/bin/../lib/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x9e) [0x7ff50efc6c1e]
   [bt] (7) /home/ec2-user/anaconda3/envs/mxnet_p36/bin/../lib/libpython3.6m.so.1.0(+0x14895b) [0x7ff50f0a395b]
   [bt] (8) /home/ec2-user/anaconda3/envs/mxnet_p36/bin/../lib/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x2c40) [0x7ff50f0a6d40]
   [bt] (9) /home/ec2-user/anaconda3/envs/mxnet_p36/bin/../lib/libpython3.6m.so.1.0(+0x146514) [0x7ff50f0a1514]
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services