ImageDetIter label shape mismatch


#1

I try to use the image.ImageDetIter according the docu. I fail to read the lst file properly even trying the example in the docu, i.e.,

1  2  5  480  640  3  0.05  0.16  0.75  0.9  data/xxx.jpg

I just replaced the imagepath and I get always a label mismatch.

Label shape (9,) inconsistent with annotation width 5.

Full error

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-67-f2a121b277b0> in <module>()
      1 data_iter = mx.image.ImageDetIter(batch_size=2, data_shape=(3, 224, 224),
      2                                 path_imglist='/Users/blattner/Desktop/bboxdir/test.lst',
----> 3                                 path_root='/Users/blattner/Desktop/bboxdir/data/')

/usr/local/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

/usr/local/lib/python3.6/site-packages/mxnet/image/detection.py in _estimate_label_shape(self)
    700             while True:
    701                 label, _ = self.next_sample()
--> 702                 label = self._parse_label(label)
    703                 max_count = max(max_count, label.shape[0])
    704         except StopIteration:

/usr/local/lib/python3.6/site-packages/mxnet/image/detection.py in _parse_label(self, label)
    725             msg = "Label shape %s inconsistent with annotation width %d." \
    726                 %(str(raw.shape), obj_width)
--> 727             raise RuntimeError(msg)
    728         out = np.reshape(raw[header_width:], (-1, obj_width))
    729         # remove bad ground-truths

RuntimeError: Label shape (9,) inconsistent with annotation width 5.

I checked the record format many times and it should be ok. Any idea?
Thx.


#2

Can you provide a minimal lst file for me to download, if it’s huge, can you truncate a little?

BTW, in the master doc site: https://mxnet.incubator.apache.org/versions/master/api/python/image/image.html
The explanation is corrected, you should use

0  4  5  640  480  1  0.1  0.2  0.8  0.9  2  0.5  0.3  0.6  0.8  data/xxx.jpg
1  4  5  480  640  3  0.05  0.16  0.75  0.9  data/yyy.jpg

Sorry about the confusion.


#3

seems to work now. thanks for the link with the new docu