torchvision

特定于计算机视觉的数据集、转换和模型。「Datasets, Transforms and Models specific to Computer Vision」

Github星跟蹤圖

torchvision

torchvision 软件包由流行的数据集、模型架构和用于计算机视觉的常见图像转换组成。

安装

我们建议将 Anaconda 作为 Python 软件包管理系统。 有关 PyTorch(割炬)安装的详细信息,请访问 pytorch.org。 以下是对应的 Torchvision 版本和受支持的 Python 版本。

torch torchvision python
master / nightly master / nightly >=3.6
1.5.0 0.6.0 >=3.5
1.4.0 0.5.0 ==2.7, >=3.5, <=3.8
1.3.1 0.4.2 ==2.7, >=3.5, <=3.7
1.3.0 0.4.1 ==2.7, >=3.5, <=3.7
1.2.0 0.4.0 ==2.7, >=3.5, <=3.7
1.1.0 0.3.0 ==2.7, >=3.5, <=3.7
<=1.0.1 0.2.2 ==2.7, >=3.5, <=3.7
Anaconda:
conda install torchvision -c pytorch
pip:
pip install torchvision
从源安装:
python setup.py install
# or, for OSX
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

默认情况下,如果找到 CUDA 并且 torch.cuda.is_available() 为 true,则构建 GPU 支持。可以通过设置 FORCE_CUDA=1 环境变量来强制构建 GPU 支持,这在构建 docker 映像时非常有用。

图片后端

Torchvision 当前支持以下图像后端:

  • Pillow (默认)
  • Pillow-SIMD -- 用SIMD取代Pillow的快速替代品。如果已安装将用作默认值。
  • accimage -- 如果已安装,则可以通过调用 torchvision.set_image_backend('accimage') 来激活。
  • libpng -- 可以通过 conda conda install libpng 或任何基于 debian 和 RHEL 的 Linux 发行版的软件包管理器进行安装。
  • libjpeg -- 可以通过 conda conda install jpeg 或任何基于debian和RHEL的Linux发行版的软件包管理器来安装。也可以使用 libjpeg-turbo

注意:libpng 和 libjpeg 必须在编译时可用。确保它在标准库位置上可用,否则,请分别在环境变量 TORCHVISION_INCLUDE 和 TORCHVISION_LIBRARY 中添加 include 和库路径。

C++ API

TorchVision 还提供了一个 C++ API,其中包含等效于 python 模型的 C++。

从源安装:
mkdir build
cd build
# Add -DWITH_CUDA=on support for the CUDA if needed
cmake ..
make
make install

安装后,可以通过 TorchVision::TorchVision target 在 cmake(正确配置 CMAKE_PREFIX_PATH)下访问该库:

find_package(TorchVision REQUIRED)
target_link_libraries(my-target PUBLIC TorchVision::TorchVision)

TorchVision 程序包还将自动查找 Torch 程序包,并将其作为依赖项添加到 my-target,因此请确保也可以通过 CMAKE_PREFIX_PATH 进行 cmake。

有关示例设置,请查看 examples/cpp/hello_world。

文档

您可以在pytorch网站上找到API文档:http://pytorch.org/docs/master/torchvision/

贡献

我们感谢所有贡献。如果您打算提供错误修复,请不要做任何进一步讨论。如果您打算贡献新功能,实用程序功能或扩展,请首先打开一个问题并与我们讨论该功能。

数据集免责声明

这是一个实用程序库,可下载并准备公共数据集。我们不托管或分发这些数据集,也不保证其质量或公平性,也不声明您具有使用该数据集的许可。您有责任确定您是否有权在数据集的许可下使用该数据集。

如果您是数据集所有者,并希望更新数据集的任何部分(说明,引用等),或者不希望将数据集包含在此库中,请通过GitHub问题联系。感谢您对ML社区的贡献!


(The first version translated by vz on 2020.07.18)

主要指標

概覽
名稱與所有者pytorch/vision
主編程語言Python
編程語言Python (語言數: 11)
平台Linux, Mac, Windows
許可證BSD 3-Clause "New" or "Revised" License
所有者活动
創建於2016-11-09 23:11:43
推送於2025-04-24 11:35:15
最后一次提交
發布數183
最新版本名稱v0.22.0 (發布於 )
第一版名稱v0.1.5 (發布於 )
用户参与
星數16.8k
關注者數467
派生數7k
提交數4k
已啟用問題?
問題數3447
打開的問題數862
拉請求數4240
打開的拉請求數231
關閉的拉請求數1097
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

torchvision

.. image:: https://travis-ci.org/pytorch/vision.svg?branch=master
:target: https://travis-ci.org/pytorch/vision

.. image:: https://codecov.io/gh/pytorch/vision/branch/master/graph/badge.svg
:target: https://codecov.io/gh/pytorch/vision

.. image:: https://pepy.tech/badge/torchvision
:target: https://pepy.tech/project/torchvision

.. image:: https://img.shields.io/badge/dynamic/json.svg?label=docs&url=https%3A%2F%2Fpypi.org%2Fpypi%2Ftorchvision%2Fjson&query=%24.info.version&colorB=brightgreen&prefix=v
:target: https://pytorch.org/docs/stable/torchvision/index.html

The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision.

Installation

TorchVision requires PyTorch 1.4 or newer.

Anaconda:

.. code:: bash

conda install torchvision -c pytorch

pip:

.. code:: bash

pip install torchvision

From source:

.. code:: bash

python setup.py install
# or, for OSX
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

By default, GPU support is built if CUDA is found and torch.cuda.is_available() is true.
It's possible to force building GPU support by setting FORCE_CUDA=1 environment variable,
which is useful when building a docker image.

Image Backend

Torchvision currently supports the following image backends:

  • Pillow_ (default)

  • Pillow-SIMD_ - a much faster drop-in replacement for Pillow with SIMD. If installed will be used as the default.

  • accimage_ - if installed can be activated by calling :code:torchvision.set_image_backend('accimage')

.. _Pillow : https://python-pillow.org/
.. _Pillow-SIMD : https://github.com/uploadcare/pillow-simd
.. _accimage: https://github.com/pytorch/accimage

C++ API

TorchVision also offers a C++ API that contains C++ equivalent of python models.

Installation From source:

.. code:: bash

mkdir build
cd build
# Add -DWITH_CUDA=on support for the CUDA if needed
cmake ..
make 
make install

Once installed, the library can be accessed in cmake (after properly configuring CMAKE_PREFIX_PATH) via the :code:TorchVision::TorchVision target:

.. code:: rest

find_package(TorchVision REQUIRED)
target_link_libraries(my-target PUBLIC TorchVision::TorchVision)

The TorchVision package will also automatically look for the Torch and pybind11 packages and add them as dependencies to my-target,
so make sure that they are also available to cmake via the CMAKE_PREFIX_PATH.

Documentation

You can find the API documentation on the pytorch website: http://pytorch.org/docs/master/torchvision/

Contributing

We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.

Disclaimer on Datasets

This is a utility library that downloads and prepares public datasets. We do not host or distribute these datasets, vouch for their quality or fairness, or claim that you have license to use the dataset. It is your responsibility to determine whether you have permission to use the dataset under the dataset's license.

If you're a dataset owner and wish to update any part of it (description, citation, etc.), or do not want your dataset to be included in this library, please get in touch through a GitHub issue. Thanks for your contribution to the ML community!