當前位置: 首頁>>代碼示例>>Python>>正文


Python minibatch.get_minibatch方法代碼示例

本文整理匯總了Python中roi_data.minibatch.get_minibatch方法的典型用法代碼示例。如果您正苦於以下問題:Python minibatch.get_minibatch方法的具體用法?Python minibatch.get_minibatch怎麽用?Python minibatch.get_minibatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在roi_data.minibatch的用法示例。


在下文中一共展示了minibatch.get_minibatch方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_next_parallel_minibatch

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def get_next_parallel_minibatch(self, augmentation_process_pool, parallel_size):
        """Return the blobs to be used for the next minibatch. Thread safe."""

        db_inds_list = [self._get_next_minibatch_inds() for _ in range(parallel_size)]
        minibatch_db_list = [[self._roidb[i] for i in db_inds] for db_inds in db_inds_list]

        copy_minibatch_db_list = copy.deepcopy(minibatch_db_list)

        logger.info('get_next_parallel_minibatch MAP POOL Thread: {}'.format(threading.currentThread()))
        res = augmentation_process_pool.map(get_minibatch, copy_minibatch_db_list)
        logger.info('get_next_parallel_minibatch MAP POOL COMPLETE Thread: {}'.format(threading.currentThread()))

        valid_blobs_list = [blobs for blobs, valid in res if valid]

        del copy_minibatch_db_list
        del minibatch_db_list
        del res

        return valid_blobs_list 
開發者ID:gangadhar-p,項目名稱:NucleiDetectron,代碼行數:21,代碼來源:loader.py

示例2: __getitem__

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def __getitem__(self, index_tuple):
        index, ratio = index_tuple
        single_db = [self._roidb[index]]
        blobs, valid = get_minibatch(single_db)
        #TODO: Check if minibatch is valid ? If not, abandon it.
        # Need to change _worker_loop in torch.utils.data.dataloader.py.

        # Squeeze batch dim
        for key in blobs:
            if key != 'roidb':
                blobs[key] = blobs[key].squeeze(axis=0)

        if self._roidb[index]['need_crop']:
            self.crop_data(blobs, ratio)
            # Check bounding box
            entry = blobs['roidb'][0]
            boxes = entry['boxes']
            invalid = (boxes[:, 0] == boxes[:, 2]) | (boxes[:, 1] == boxes[:, 3])
            valid_inds = np.nonzero(~ invalid)[0]
            if len(valid_inds) < len(boxes):
                for key in ['boxes', 'gt_classes', 'seg_areas', 'gt_overlaps', 'is_crowd',
                            'box_to_gt_ind_map', 'gt_keypoints']:
                    if key in entry:
                        entry[key] = entry[key][valid_inds]
                entry['segms'] = [entry['segms'][ind] for ind in valid_inds]

        blobs['roidb'] = blob_utils.serialize(blobs['roidb'])  # CHECK: maybe we can serialize in collate_fn

        return blobs 
開發者ID:roytseng-tw,項目名稱:Detectron.pytorch,代碼行數:31,代碼來源:loader.py

示例3: __getitem__

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def __getitem__(self, index_tuple):
        index, ratio = index_tuple
        single_db = [self._roidb[index]]
        blobs, valid = get_minibatch(single_db, self._num_classes)
        #TODO: Check if minibatch is valid ? If not, abandon it.
        # Need to change _worker_loop in torch.utils.data.dataloader.py.

        # Squeeze batch dim
        # for key in blobs:
        #     if key != 'roidb':
        #         blobs[key] = blobs[key].squeeze(axis=0)
        blobs['data'] = blobs['data'].squeeze(axis=0)

        return blobs 
開發者ID:ppengtang,項目名稱:pcl.pytorch,代碼行數:16,代碼來源:loader.py

示例4: get_next_minibatch

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def get_next_minibatch(self):
        """Return the blobs to be used for the next minibatch. Thread safe."""
        valid = False
        while not valid:
            db_inds = self._get_next_minibatch_inds()
            minibatch_db = [self._roidb[i] for i in db_inds]
            blobs, valid = get_minibatch(minibatch_db)
        return blobs 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:10,代碼來源:loader.py

示例5: __getitem__

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def __getitem__(self, index_tuple):
        index, ratio = index_tuple
        single_db = [self._roidb[index]]

        ## _add_proposals(xxx)
        blobs, valid = get_minibatch(single_db)
        #TODO: Check if minibatch is valid ? If not, abandon it.
        # Need to change _worker_loop in torch.utils.data.dataloader.py.

        # Squeeze batch dim
        for key in blobs:
            if key != 'roidb':
                blobs[key] = blobs[key].squeeze(axis=0)

        if self._roidb[index]['need_crop']:
            self.crop_data(blobs, ratio)
            # Check bounding box
            entry = blobs['roidb'][0]
            boxes = entry['boxes']
            invalid = (boxes[:, 0] == boxes[:, 2]) | (boxes[:, 1] == boxes[:, 3])
            valid_inds = np.nonzero(~ invalid)[0]
            if len(valid_inds) < len(boxes):
                for key in ['boxes', 'precomp_keypoints', 'gt_classes', 'seg_areas', 'gt_overlaps', 'is_crowd',
                            'box_to_gt_ind_map', 'gt_keypoints', 'gt_actions', 'gt_role_id']:
                    if key in entry:
                        entry[key] = entry[key][valid_inds]
                entry['segms'] = [entry['segms'][ind] for ind in valid_inds]

        blobs['roidb'] = blob_utils.serialize(blobs['roidb'])  # CHECK: maybe we can serialize in collate_fn

        return blobs 
開發者ID:bobwan1995,項目名稱:PMFNet,代碼行數:33,代碼來源:loader.py

示例6: get_next_minibatch

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def get_next_minibatch(self):
        """Return the blobs to be used for the next minibatch. Thread safe."""
        valid = False
        while not valid:
            db_inds = self._get_next_minibatch_inds()
            minibatch_db = [self._roidb[i] for i in db_inds]
            blobs, valid = get_minibatch(minibatch_db)
            # for index, i in enumerate(db_inds):
            #     self._roidb[i] = new_roidb[index]
        return blobs 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:12,代碼來源:loader.py

示例7: get_next_minibatch

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def get_next_minibatch(self):
        """Return the blobs to be used for the next minibatch. Thread safe."""
        valid = False
        while not valid:
            db_inds, dataset_ind = self._get_next_minibatch_inds()
            minibatch_db = [self._roidbs[dataset_ind][i] for i in db_inds]
            blobs, valid = get_minibatch(minibatch_db)
            # for index, i in enumerate(db_inds):
            #     self._roidbs[dataset_ind][i] = new_roidb[index]
        return blobs 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:12,代碼來源:mix_loader.py

示例8: __getitem__

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def __getitem__(self, index_tuple):
        index, ratio = index_tuple
        single_db = [self._roidb[index]]
        blobs, valid = get_minibatch(single_db)
        #TODO: Check if minibatch is valid ? If not, abandon it.
        # Need to change _worker_loop in torch.utils.data.dataloader.py.        

        # Squeeze batch dim
        for key in blobs:
            if key != 'roidb':
                # print('%s %s' % (key, type(blobs[key])))
                # print(blobs[key].shape)
                blobs[key] = blobs[key].squeeze(axis=0)

        if self._roidb[index]['need_crop']:
            self.crop_data(blobs, ratio)
            # Check bounding box
            entry = blobs['roidb'][0]
            boxes = entry['boxes']
            invalid = (boxes[:, 0] == boxes[:, 2]) | (boxes[:, 1] == boxes[:, 3])
            valid_inds = np.nonzero(~ invalid)[0]

            if len(valid_inds) < len(boxes):
                for key in ['boxes', 'gt_classes', 'seg_areas', 'gt_overlaps', 'is_crowd',
                            'box_to_gt_ind_map', 'gt_keypoints', 'gt_scores', 'dataset_id', 
                            'gt_source']: # EDIT: gt_scores
                    if key in entry:
                        entry[key] = entry[key][valid_inds]
                entry['segms'] = [entry['segms'][ind] for ind in valid_inds]

        blobs['roidb'] = blob_utils.serialize(blobs['roidb'])  # CHECK: maybe we can serialize in collate_fn

        return blobs 
開發者ID:AruniRC,項目名稱:detectron-self-train,代碼行數:35,代碼來源:loader.py

示例9: _get_next_minibatch

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def _get_next_minibatch(self):
        """Return the blobs to be used for the next minibatch. DEPRECATED.
        This only exists for debugging (in train_net.py) and for
        benchmarking."""
        roidb = self._roidb
        valid = False
        while not valid:
            db_inds = self._get_next_minibatch_inds(
                {'roidb': roidb}, self._lock,
                multiprocessing.Value('i', self._cur, lock=False),
                self._perm)
            minibatch_db = [roidb[i] for i in db_inds]
            blobs, valid = get_minibatch(minibatch_db)
        return blobs 
開發者ID:facebookresearch,項目名稱:DetectAndTrack,代碼行數:16,代碼來源:loader.py

示例10: _get_next_minibatch2

# 需要導入模塊: from roi_data import minibatch [as 別名]
# 或者: from roi_data.minibatch import get_minibatch [as 別名]
def _get_next_minibatch2(shared_readonly_dict, lock, mp_cur, mp_perm):
        """Return the blobs to be used for the next minibatch. Thread safe."""
        roidb = shared_readonly_dict['roidb']
        valid = False
        while not valid:
            db_inds = RoIDataLoader._get_next_minibatch_inds(
                shared_readonly_dict, lock, mp_cur, mp_perm)
            minibatch_db = [roidb[i] for i in db_inds]
            blobs, valid = get_minibatch(minibatch_db)
        return blobs 
開發者ID:facebookresearch,項目名稱:DetectAndTrack,代碼行數:12,代碼來源:loader.py


注:本文中的roi_data.minibatch.get_minibatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。