maskrcnn-benchmark 代码详解之 image_list.py

本文详细解读maskrcnn-benchmark库中的image_list.py,主要介绍ImageList数据类型,它是用来存储图像列表并进行转换的工具。ImageList包含图像列表张量和图像大小列表。此外,代码还支持将不同格式的图像列表转换为ImageList,如Tensor或可迭代张量,并在必要时通过填充0调整图像尺寸。
摘要由CSDN通过智能技术生成

前言

image_list.py主要是用于保存图像列表的数据类型以及将其他保存图像列表的数据类型转换成maskrcnn benchmark所规定的ImageList类型。ImageList的属性包含一个保存图像列表的张量还有一个保存图像大小的列表,其代码为:

class ImageList(object):
    """
    Structure that holds a list of images (of possibly
    varying sizes) as a single tensor.
    This works by padding the images to the same size,
    and storing in a field the original sizes of each image
    用于保存图片(大小可以不同)列表并使之成为一个单一张量的数据结构,
    通过扩充图像到相同的大小来保存原图像的大小
    """

    def __init__(self, tensors, image_sizes):
        """
        Arguments:
            tensors (tensor)
            image_sizes (list[tuple[int, int]])
        """
        # 该数据类型有两个属性,保存图像数据的tensors,和图像各自的大小image_sizes
        self.tensors = tensors
        self.image_sizes = image_sizes

    # 实现转换功能,比如todevice todetype等等
    def to(self, *args, **kwargs):
        cast_tensor &#
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值