当前位置: 首页>>代码示例>>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;未经允许,请勿转载。