I find that current
mxnet.io.CSVIter does not support running-time image augmentations when reading from
.csv files. So I am working on customing my own
csv data iterator which inherits from super class
MXDataIter, for that the MXNet doc said
MXDataIter is the wrapper class of
CSVIter(C++) in Python. Below is my codes of
import mxnet as mx class myCSVIter(mx.io.MXDataIter): def __init__(self, handle, augs, **kwargs): super(myCSVIter, self).__init__(handle， **kwargs) self.augs = augs def reset(): super(myCSVIter, self).reset() def __next__(): self.next() def next(): try: data_batch = super(myCSVIter, self).next() image = data_batch.data label = data_batch.label for aug in self.augs: image = aug(image) # apply image augmentations return mx.io.DataBatch(image, label) except StopIteration: raise StopIteration
However, I don’t know what the
handle paramete means in
mx.io.MXDataIter ? So I tried to pass a
CSVIter object (
train_img_iter) to it, as belows:
train_img_iter = mx.io.CSVIter(data_csv='train_datas_tmp.csv', data_shape=(4, 640, 480), label_csv='train_labels_tmp.csv', label_shape=(640, 480), batch_size=1, dtype='float32')
i.e. I take the
train_img_iter as the
handle parameter when construct an instance of
myCSVIter, but I got an error: Don’t know how to convert parameter 1.
So, my question is:
- Is what I have done to implement a customed
CSVIter(Enabled by image augmentation) correct ?
- What’s the meaning of
- Is there any way to read
.csvdata files and do image augmentations simultaneously ?