diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7c73e8f9266..57df2c27410 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,30 +30,49 @@ clear and has sufficient instructions to be able to reproduce the issue. ## Development installation -### Install PyTorch Nightly + +### Dependencies + +Start by installing the **nightly** build of PyTorch following the [official +instructions](https://pytorch.org/get-started/locally/). + +**Optionally**, install `libpng` and `libjpeg-turbo` if you want to enable +support for +native encoding / decoding of PNG and JPEG formats in +[torchvision.io](https://pytorch.org/vision/stable/io.html#image): ```bash -conda install pytorch -c pytorch-nightly -# or with pip (see https://pytorch.org/get-started/locally/) -# pip install numpy -# pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html +conda install libpng libjpeg-turbo -c pytorch ``` -### Install Torchvision +Note: you can use the `TORCHVISION_INCLUDE` and `TORCHVISION_LIBRARY` +environment variables to tell the build system where to find those libraries if +they are in specific locations. Take a look at +[setup.py](https://github.com/pytorch/vision/blob/main/setup.py) for more +details. + +### Clone and install torchvision ```bash git clone https://github.com/pytorch/vision.git cd vision -python setup.py develop +python setup.py develop # use install instead of develop if you don't care about development. # or, for OSX # MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop -# for C++ debugging, please use DEBUG=1 +# for C++ debugging, use DEBUG=1 # DEBUG=1 python setup.py develop -pip install flake8 typing mypy pytest pytest-mock scipy ``` -You may also have to install `libpng-dev` and `libjpeg-turbo8-dev` libraries: -```bash -conda install libpng jpeg + +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. + +We don't officially support building from source using `pip`, but _if_ you do, you'll need to use the +`--no-build-isolation` flag. + +Other development dependencies include: + +``` +pip install flake8 typing mypy pytest pytest-mock scipy ``` ## Development Process @@ -192,7 +211,7 @@ Please refer to the guidelines in [Contributing to Torchvision - Models](https:/ ### New dataset -More details on how to add a new dataset will be provided later. Please, do not send any PR with a new dataset without discussing +Please, do not send any PR with a new dataset without discussing it in an issue as, most likely, it will not be accepted. ### Pull Request diff --git a/README.md b/README.md index 948f23a1d52..dd29290a032 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,14 @@ vision. ## Installation -We recommend Anaconda as Python package management system. Please refer to [pytorch.org](https://pytorch.org/) for the -detail of PyTorch (`torch`) installation. The following is the corresponding `torchvision` versions and supported Python +Please refer to the [official +instructions](https://pytorch.org/get-started/locally/) to install the stable +versions of `torch` and `torchvision` on your system. + +To build source, refer to our [contributing +page](https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md#development-installation). + +The following is the corresponding `torchvision` versions and supported Python versions. | `torch` | `torchvision` | Python | @@ -39,55 +45,18 @@ versions. -Anaconda: - -``` -conda install torchvision -c pytorch -``` - -pip: - -``` -pip install torchvision -``` +## Image Backends -From source: - -``` -python setup.py install -# or, for OSX -# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install -``` - -We don't officially support building from source using `pip`, but _if_ you do, you'll need to use the -`--no-build-isolation` flag. In case building TorchVision from source fails, install the nightly version of PyTorch -following the linked guide on the -[contributing page](https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md#development-installation) and retry the -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. +Torchvision currently supports the following image backends: -## Image Backend +- torch tensors +- PIL images: + - [Pillow](https://python-pillow.org/) + - [Pillow-SIMD](https://github.com/uploadcare/pillow-simd) - a **much faster** drop-in replacement for Pillow with SIMD. -Torchvision currently supports the following image backends: +Read more in in our [docs](https://pytorch.org/vision/stable/transforms.html). -- [Pillow](https://python-pillow.org/) (default) -- [Pillow-SIMD](https://github.com/uploadcare/pillow-simd) - a **much faster** drop-in replacement for Pillow with SIMD. - If installed will be used as the default. -- [accimage](https://github.com/pytorch/accimage) - if installed can be activated by calling - `torchvision.set_image_backend('accimage')` -- [libpng](http://www.libpng.org/pub/png/libpng.html) - can be installed via conda `conda install libpng` or any of the - package managers for debian-based and RHEL-based Linux distributions. -- [libjpeg](http://ijg.org/) - can be installed via conda `conda install jpeg` or any of the package managers for - debian-based and RHEL-based Linux distributions. [libjpeg-turbo](https://libjpeg-turbo.org/) can be used as well. - -**Notes:** `libpng` and `libjpeg` are optional dependencies. If any of them is available on the system, -torchvision will provide encoding/decoding image functionalities from `torchvision.io.image`. -When building torchvision from source, `libpng` and `libjpeg` can be found on the standard library locations. -Otherwise, please use `TORCHVISION_INCLUDE` and `TORCHVISION_LIBRARY` environment variables to set up include and library paths. - -## Video Backend +## [UNSTABLE] Video Backend Torchvision currently supports the following video backends: diff --git a/docs/source/io.rst b/docs/source/io.rst index 258a1ee16dc..1da9bb6882a 100644 --- a/docs/source/io.rst +++ b/docs/source/io.rst @@ -1,11 +1,37 @@ -Reading/Writing images and videos -================================= +Decoding / Encoding images and videos +===================================== .. currentmodule:: torchvision.io The :mod:`torchvision.io` package provides functions for performing IO -operations. They are currently specific to reading and writing video and -images. +operations. They are currently specific to reading and writing images and +videos. + +Images +------ + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + read_image + decode_image + encode_jpeg + decode_jpeg + write_jpeg + encode_png + decode_png + write_png + read_file + write_file + +.. autosummary:: + :toctree: generated/ + :template: class.rst + + ImageReadMode + + Video ----- @@ -20,7 +46,7 @@ Video Fine-grained video API ----------------------- +^^^^^^^^^^^^^^^^^^^^^^ In addition to the :mod:`read_video` function, we provide a high-performance lower-level API for more fine-grained control compared to the :mod:`read_video` function. @@ -61,28 +87,3 @@ Example of inspecting a video: # the constructor we select a default video stream, but # in practice, we can set whichever stream we would like video.set_current_stream("video:0") - - -Image ------ - -.. autosummary:: - :toctree: generated/ - :template: class.rst - - ImageReadMode - -.. autosummary:: - :toctree: generated/ - :template: function.rst - - read_image - decode_image - encode_jpeg - decode_jpeg - write_jpeg - encode_png - decode_png - write_png - read_file - write_file