maskrcnn_benchmark 代码详解之 boxlist_ops.py

本文深入解析maskrcnn_benchmark库中boxlist_ops.py文件,涵盖边框列表的非极大抑制、去除小边框、计算IoU及合并等关键操作,为理解目标检测中的深度学习算法提供帮助。

前言:

  与Bounding Box有关的操作有很多,例如对边框列表进行非极大线性抑制、去除过小的边框、计算边框之间的Iou以及对两个边框列表进行合并等操作。在maskrcnn_benchmark中,这些操作都得以实现,其具体代码以及解释如下:

# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch

from .bounding_box import BoxList

from maskrcnn_benchmark.layers import nms as _box_nms


def boxlist_nms(boxlist, nms_thresh, max_proposals=-1, score_field="scores"):
    """
    Performs non-maximum suppression on a boxlist, with scores specified
    in a boxlist field via score_field.在边框列表上进行非极大线性抑制

    参数:
        boxlist(BoxList):含有边框目标得分,原始图像大小,预测边框列表等信息的边框列表
        nms_thresh (float):非极大线性抑制的阈值
        max_proposals (int): if > 0, then only the top max_proposals are kept
            after non-maximum suppression当大于0时,在非极大线性抑制后只保存前max_proposals个最大目标评分的的预测边框
        score_field (str):保存目标得分列表的键值
    """
    # 如果非极大线性抑制的阈值小于0,则返回所有边框列表
    if nms_thresh <= 0:
        return boxlist
    # 得到预测边框的格式
    m
Traceback (most recent call last): File "tools/extract_clip_feature.py", line 20, in <module> from maskrcnn_benchmark.data import make_data_loader File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/data/__init__.py", line 2, in <module> from .build import make_data_loader, get_dataset_statistics File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/data/build.py", line 12, in <module> from maskrcnn_benchmark.utils.miscellaneous import save_labels File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/utils/miscellaneous.py", line 10, in <module> from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/structures/boxlist_ops.py", line 7, in <module> from maskrcnn_benchmark.layers import nms as _box_nms File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/layers/__init__.py", line 10, in <module> from .nms import nms File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/layers/nms.py", line 3, in <module> from ._utils import _C File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/layers/_utils.py", line 39, in <module> _C = _load_C_extensions() File "/root/.cache/huggingface/forget/lab/shichong/cyy/RECODE/maskrcnn_benchmark/layers/_utils.py", line 35, in _load_C_extensions extra_include_paths=extra_include_paths, File "/opt/conda/envs/recode/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1296, in load keep_intermediates=keep_intermediates) File "/opt/conda/envs/recode/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1534, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/opt/conda/envs/recode/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1936, in _import_module_from_library module = importlib.util.module_from_spec(spec) ImportError: /root/.cache/torch_extensions/py37_cu117/torchvision/torchvision.so: cannot open shared object file: No such file or directory
最新发布
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值