本文整理汇总了Python中rcnn.get_rcnn_batch方法的典型用法代码示例。如果您正苦于以下问题:Python rcnn.get_rcnn_batch方法的具体用法?Python rcnn.get_rcnn_batch怎么用?Python rcnn.get_rcnn_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcnn
的用法示例。
在下文中一共展示了rcnn.get_rcnn_batch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_batch
# 需要导入模块: import rcnn [as 别名]
# 或者: from rcnn import get_rcnn_batch [as 别名]
def get_batch(self):
# slice roidb
cur_from = self.cur
cur_to = min(cur_from + self.batch_size, self.size)
roidb = [self.roidb[self.index[i]] for i in range(cur_from, cur_to)]
# decide multi device slices
work_load_list = self.work_load_list
ctx = self.ctx
if work_load_list is None:
work_load_list = [1] * len(ctx)
assert isinstance(work_load_list, list) and len(work_load_list) == len(ctx), \
"Invalid settings for work load. "
slices = _split_input_slice(self.batch_size, work_load_list)
# get each device
data_list = []
label_list = []
for islice in slices:
iroidb = [roidb[i] for i in range(islice.start, islice.stop)]
data, label = get_rcnn_batch(iroidb, self.cfg)
data_list.append(data)
label_list.append(label)
all_data = dict()
for key in data_list[0].keys():
all_data[key] = tensor_vstack([batch[key] for batch in data_list])
all_label = dict()
for key in label_list[0].keys():
all_label[key] = tensor_vstack([batch[key] for batch in label_list])
self.data = [mx.nd.array(all_data[name]) for name in self.data_name]
self.label = [mx.nd.array(all_label[name]) for name in self.label_name]
示例2: parfetch
# 需要导入模块: import rcnn [as 别名]
# 或者: from rcnn import get_rcnn_batch [as 别名]
def parfetch(self, iroidb):
data, label = get_rcnn_batch(iroidb, self.cfg)
return {'data': data, 'label': label}
示例3: parfetch
# 需要导入模块: import rcnn [as 别名]
# 或者: from rcnn import get_rcnn_batch [as 别名]
def parfetch(self, iroidb):
# get testing data for multigpu
data, label = get_rcnn_batch(iroidb, self.cfg)
# add gt_boxes to data for learn nms
if 'gt_boxes' in data:
data['gt_boxes'] = data['gt_boxes'][np.newaxis, :, :]
return {'data': data, 'label': label}
示例4: get_batch_individual
# 需要导入模块: import rcnn [as 别名]
# 或者: from rcnn import get_rcnn_batch [as 别名]
def get_batch_individual(self, cur_from=None):
if cur_from is None:
cur_from = self.cur
cur_to = min(cur_from + self.batch_size, self.size)
roidb = [self.roidb[self.index[i]] for i in range(cur_from, cur_to)]
# decide multi device slices
work_load_list = self.work_load_list
ctx = self.ctx
if work_load_list is None:
work_load_list = [1] * len(ctx)
assert isinstance(work_load_list, list) and len(work_load_list) == len(ctx), \
"Invalid settings for work load. "
slices = _split_input_slice(self.batch_size, work_load_list)
rst = []
for idx, islice in enumerate(slices):
iroidb = [roidb[i] for i in range(islice.start, islice.stop)]
rst.append(self.parfetch(iroidb))
all_data = [_['data'] for _ in rst]
all_label = [_['label'] for _ in rst]
data = [[mx.nd.array(data[key]) for key in self.data_name] for data in all_data]
label = [[mx.nd.array(label[key]) for key in self.label_name] for label in all_label]
self.lock_data.acquire()
self.data = data
self.label = label
self.lock_data.release()
return data, label
#def parfetch(self, iroidb):
# data, label = get_rcnn_batch(iroidb, self.cfg)
# return {'data': data, 'label': label}
示例5: get_batch
# 需要导入模块: import rcnn [as 别名]
# 或者: from rcnn import get_rcnn_batch [as 别名]
def get_batch(self, cur_from=None):
# slice roidb
if cur_from is None:
cur_from = self.cur
cur_to = min(cur_from + self.batch_size, self.size)
roidb = [self.roidb[self.index[i]] for i in range(cur_from, cur_to)]
# decide multi device slices
work_load_list = self.work_load_list
ctx = self.ctx
if work_load_list is None:
work_load_list = [1] * len(ctx)
assert isinstance(work_load_list, list) and len(work_load_list) == len(ctx), \
"Invalid settings for work load. "
slices = _split_input_slice(self.batch_size, work_load_list)
# get each device
data_list = []
label_list = []
for islice in slices:
iroidb = [roidb[i] for i in range(islice.start, islice.stop)]
data, label = get_rcnn_batch(iroidb, self.cfg)
data_list.append(data)
label_list.append(label)
all_data = dict()
for key in data_list[0].keys():
all_data[key] = tensor_vstack([batch[key] for batch in data_list])
all_label = dict()
for key in label_list[0].keys():
all_label[key] = tensor_vstack([batch[key] for batch in label_list])
data = [mx.nd.array(all_data[name]) for name in self.data_name]
label = [mx.nd.array(all_label[name]) for name in self.label_name]
self.lock_data.acquire()
self.data = data
self.label = label
self.lock_data.release()
return data, label