本文整理匯總了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