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


Python cfg.PYTORCH_VERSION_LESS_THAN_040屬性代碼示例

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


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

示例1: check_inference

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def check_inference(net_func):
    @wraps(net_func)
    def wrapper(self, *args, **kwargs):
        if not self.training:
            if cfg.PYTORCH_VERSION_LESS_THAN_040:
                return net_func(self, *args, **kwargs)
            else:
                with torch.no_grad():
                    return net_func(self, *args, **kwargs)
        else:
            raise ValueError('You should call this function only on inference.'
                              'Set the network in inference mode by net.eval().')

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

示例2: forward

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def forward(self, data, im_info, roidb=None, **rpn_kwargs):
        if cfg.PYTORCH_VERSION_LESS_THAN_040:
            return self._forward(data, im_info, roidb, **rpn_kwargs)
        else:
            with torch.set_grad_enabled(self.training):
                return self._forward(data, im_info, roidb, **rpn_kwargs) 
開發者ID:roytseng-tw,項目名稱:Detectron.pytorch,代碼行數:8,代碼來源:model_builder.py

示例3: im_conv_body_only

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def im_conv_body_only(model, im, target_scale, target_max_size):
    inputs, im_scale = _get_blobs(im, None, target_scale, target_max_size)

    if cfg.PYTORCH_VERSION_LESS_THAN_040:
        inputs['data'] = Variable(torch.from_numpy(inputs['data']), volatile=True).cuda()
    else:
        inputs['data'] = torch.from_numpy(inputs['data']).cuda()
    inputs.pop('im_info')

    blob_conv = model.module.convbody_net(**inputs)

    return blob_conv, im_scale 
開發者ID:roytseng-tw,項目名稱:Detectron.pytorch,代碼行數:14,代碼來源:test.py

示例4: forward

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def forward(self, data, rois, labels):
        if cfg.PYTORCH_VERSION_LESS_THAN_040:
            return self._forward(data, rois, labels)
        else:
            with torch.set_grad_enabled(self.training):
                return self._forward(data, rois, labels) 
開發者ID:ppengtang,項目名稱:pcl.pytorch,代碼行數:8,代碼來源:model_builder.py

示例5: im_detect_bbox

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def im_detect_bbox(model, im, target_scale, target_max_size, boxes=None):
    """Prepare the bbox for testing"""

    inputs, im_scale = _get_blobs(im, boxes, target_scale, target_max_size)

    if cfg.DEDUP_BOXES > 0:
        v = np.array([1, 1e3, 1e6, 1e9, 1e12])
        hashes = np.round(inputs['rois'] * cfg.DEDUP_BOXES).dot(v)
        _, index, inv_index = np.unique(
            hashes, return_index=True, return_inverse=True
        )
        inputs['rois'] = inputs['rois'][index, :]
        boxes = boxes[index, :]

    if cfg.PYTORCH_VERSION_LESS_THAN_040:
        inputs['data'] = [Variable(torch.from_numpy(inputs['data']), volatile=True)]
        inputs['rois'] = [Variable(torch.from_numpy(inputs['rois']), volatile=True)]
        inputs['labels'] = [Variable(torch.from_numpy(inputs['labels']), volatile=True)]
    else:
        inputs['data'] = [torch.from_numpy(inputs['data'])]
        inputs['rois'] = [torch.from_numpy(inputs['rois'])]
        inputs['labels'] = [torch.from_numpy(inputs['labels'])]

    return_dict = model(**inputs)

    # cls prob (activations after softmax)
    scores = return_dict['refine_score'][0].data.cpu().numpy().squeeze()
    for i in range(1, cfg.REFINE_TIMES):
        scores += return_dict['refine_score'][i].data.cpu().numpy().squeeze()
    scores /= cfg.REFINE_TIMES
    # In case there is 1 proposal
    scores = scores.reshape([-1, scores.shape[-1]])
    pred_boxes = boxes

    if cfg.DEDUP_BOXES > 0:
        # Map scores and predictions back to the original set of boxes
        scores = scores[inv_index, :]
        pred_boxes = pred_boxes[inv_index, :]

    return scores, pred_boxes, im_scale, return_dict['blob_conv'] 
開發者ID:ppengtang,項目名稱:pcl.pytorch,代碼行數:42,代碼來源:test.py

示例6: forward

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def forward(self, data, im_info, roidb=None, rois=None, **rpn_kwargs):
        if cfg.PYTORCH_VERSION_LESS_THAN_040:
            return self._forward(data, im_info, roidb, rois, **rpn_kwargs)
        else:
            with torch.set_grad_enabled(self.training):
                return self._forward(data, im_info, roidb, rois, **rpn_kwargs) 
開發者ID:ruotianluo,項目名稱:Context-aware-ZSR,代碼行數:8,代碼來源:model_builder.py

示例7: forward

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import PYTORCH_VERSION_LESS_THAN_040 [as 別名]
def forward(self, data, im_info, dataset_name=None, roidb=None, use_gt_labels=False, **rpn_kwargs):
        if cfg.PYTORCH_VERSION_LESS_THAN_040:
            return self._forward(data, im_info, dataset_name, roidb, use_gt_labels, **rpn_kwargs)
        else:
            with torch.set_grad_enabled(self.training):
                return self._forward(data, im_info, dataset_name, roidb, use_gt_labels, **rpn_kwargs) 
開發者ID:jz462,項目名稱:Large-Scale-VRD.pytorch,代碼行數:8,代碼來源:model_builder_rel.py


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