accimage

PIL:Python Image Library是Python自带的图片处理库,其保存的图像文件可以叫作PIL_image,是一种特殊结构。在Pytorch中,开发团队为了解决图像处理的性能瓶颈问题,改写而来PIL_image类,简化了一些信息,就成了acc_image这个类。简化的accimage对象除了数据以外的无效成员,可以优化空间和处理速度。
在这里插入图片描述
accimage模仿PIL API,利用Intel IPP加速图像加载器和预处理器,可用作torchvision的后端,已经实现Image.resizeImage.cropImage.transpose等函数。
在这里插入图片描述

ACCimage使用的是Intel IPP Library,一般情况下会比Python Image Library块,只不过很少有项目支持。Python Image Library除了基本的数据外,还存了诸如palette、category、pyaccess等很多别的内容。

torchvision的__init__.py文件中:

def set_image_backend(backend):
    """
    Specifies the package used to load images.
    Args:
        backend (string): Name of the image backend. one of {'PIL', 'accimage'}.
            The :mod:`accimage` package uses the Intel IPP library. It is
            generally faster than PIL, but does not support as many operations.
    """
    global _image_backend
    if backend not in ['PIL', 'accimage']:
        raise ValueError("Invalid backend '{}'. Options are 'PIL' and 'accimage'"
                         .format(backend))
    _image_backend = backend

PIL_image中Image类的定义:

class Image(object):
    """
    This class represents an image object.  To create
    :py:class:`~PIL.Image.Image` objects, use the appropriate factory
    functions.  There's hardly ever any reason to call the Image constructor
    directly.
    * :py:func:`~PIL.Image.open`
    * :py:func:`~PIL.Image.new`
    * :py:func:`~PIL.Image.frombytes`
    """
 
    def __init__(self):
        # FIXME: take "new" parameters / other image?
        # FIXME: turn mode and size into delegating properties?
        self.im = None
        self.mode = ""
        self._size = (0, 0)
        self.palette = None
        self.info = {}
        self.category = NORMAL
        self.readonly = 0
        self.pyaccess = None

参考资料
What is accimage? #12
Pytorch 中的accimage
pytorch/accimage

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值