Hi ,
I am witting to read image whit im2rec.py creatures’ format based on voc2007 dataset. but got some erros seemly out of my code .So I am confused with that.
here is my code:
data_shape = (3,320,320)
batch_size = 8
std = np.array([51.58252012, 50.01343078, 57.31053303])
rgb_mean = np.array([114.06836982, 130.57876876, 143.64666367])
# rgb_mean = np.array([130.063048, 129.967301, 124.410760])
ctx = mx.gpu(0)
# resize = (512,512)
resize = (320,320)
def get_iterators(rec_prefix, data_shape, batch_size):
class_names = ['meter']
num_class = len(class_names)
train_iter = image.ImageDetIter(
batch_size=batch_size,
data_shape=data_shape,
path_imgrec=rec_prefix + '_train.rec',
path_imgidx=rec_prefix + '_train.idx',
aug_list=None,
shuffle=True,
mean=True,
std=True,
rand_crop=1,
rand_gray=0.2,
rand_mirror=True,
rand_pad=0.4,
pad_val=(rgb_mean[0], rgb_mean[1], rgb_mean[2]),
# min_object_covered=0.95,
# max_attempts=200,
brightness=0.2,
contrast=0.2,
saturation=0.2,
hue=0.05,
pect_ratio_range=(0.9, 1.1),
# pca_noise=0.01,
)
valid_iter = image.ImageDetIter(
batch_size=batch_size,
data_shape=data_shape,
path_imgrec=rec_prefix + '_val.rec',
shuffle=False,
# mean=True,
# std=True
)
return train_iter, valid_iter, class_names, num_class
train_data, valid_data, class_names, num_class = get_iterators(rec_prefix, data_shape, batch_size)
erros are here:
/root/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float
to np.floating
is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type
.
from ._conv import register_converters as register_converters
Traceback (most recent call last):
File “/root/PycharmProjects/untitled/RefineDet/data_loader.py”, _line 61, in
train_data, valid_data, class_names, num_class = get_iterators(rec_prefix, data_shape, batch_size)
File “/root/PycharmProjects/untitled/RefineDet/data_loader.py”, line 41(pect_ratio_range=(0.9, 1.1),), in get_iterators
aspect_ratio_range=(0.9, 1.1),
File “/root/anaconda3/lib/python3.6/site-packages/mxnet/image/detection.py”, line 682, in init
label_shape = self._estimate_label_shape()
File “/root/anaconda3/lib/python3.6/site-packages/mxnet/image/detection.py”, line 709, in _estimate_label_shape
return (max_count, label.shape[1])
UnboundLocalError: local variable ‘label’ referenced before assignment
Thank you for your time and consideration.