Skip to content

Commit 0fe1c54

Browse files
authored
Merge branch 'main' into v2-vs-v1-fixes
2 parents 1e4111a + 37081ee commit 0fe1c54

File tree

79 files changed

+1684
-1218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1684
-1218
lines changed

.github/workflows/docs.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ jobs:
5555
# cores (`-j auto`). Thus, we limit to a single process (`-j 1`) here.
5656
sed -i -e 's/-j auto/-j 1/' Makefile
5757
make html
58+
59+
# Below is an imperfect way for us to add "try on collab" links to all of our gallery examples.
60+
# sphinx-gallery will convert all gallery examples to .ipynb notebooks and stores them in
61+
# build/html/_downloads/<some_hash>/<example_name>.ipynb
62+
# We copy all those ipynb files in a more convenient folder so that we can more easily link to them.
63+
mkdir build/html/_generated_ipynb_notebooks
64+
for file in `find build/html/_downloads`; do
65+
if [[ $file == *.ipynb ]]; then
66+
cp $file build/html/_generated_ipynb_notebooks/
67+
fi
68+
done
5869
5970
cp -r build/html "${RUNNER_ARTIFACT_DIR}"
6071
@@ -111,5 +122,6 @@ jobs:
111122
112123
git config user.name 'pytorchbot'
113124
git config user.email '[email protected]'
125+
git config http.postBuffer 524288000
114126
git commit -m "auto-generating sphinx docs" || true
115127
git push

CONTRIBUTING.md

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ We want to make contributing to this project as easy and transparent as possible
44

55
## TL;DR
66

7-
We appreciate all contributions. If you are interested in contributing to Torchvision, there are many ways to help out.
7+
We appreciate all contributions. If you are interested in contributing to Torchvision, there are many ways to help out.
88
Your contributions may fall into the following categories:
99

10-
- It helps the project if you could
10+
- It helps the project if you could
1111
- Report issues you're facing
12-
- Give a :+1: on issues that others reported and that are relevant to you
12+
- Give a :+1: on issues that others reported and that are relevant to you
1313

1414
- Answering queries on the issue tracker, investigating bugs are very valuable contributions to the project.
1515

16-
- You would like to improve the documentation. This is no less important than improving the library itself!
16+
- You would like to improve the documentation. This is no less important than improving the library itself!
1717
If you find a typo in the documentation, do not hesitate to submit a GitHub pull request.
1818

1919
- If you would like to fix a bug
2020
- please pick one from the [list of open issues labelled as "help wanted"](https://github.com/pytorch/vision/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
2121
- comment on the issue that you want to work on this issue
22-
- send a PR with your fix, see below.
22+
- send a PR with your fix, see below.
2323

2424
- If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.
2525

@@ -30,30 +30,49 @@ clear and has sufficient instructions to be able to reproduce the issue.
3030

3131
## Development installation
3232

33-
### Install PyTorch Nightly
33+
34+
### Dependencies
35+
36+
Start by installing the **nightly** build of PyTorch following the [official
37+
instructions](https://pytorch.org/get-started/locally/).
38+
39+
**Optionally**, install `libpng` and `libjpeg-turbo` if you want to enable
40+
support for
41+
native encoding / decoding of PNG and JPEG formats in
42+
[torchvision.io](https://pytorch.org/vision/stable/io.html#image):
3443

3544
```bash
36-
conda install pytorch -c pytorch-nightly
37-
# or with pip (see https://pytorch.org/get-started/locally/)
38-
# pip install numpy
39-
# pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
45+
conda install libpng libjpeg-turbo -c pytorch
4046
```
4147

42-
### Install Torchvision
48+
Note: you can use the `TORCHVISION_INCLUDE` and `TORCHVISION_LIBRARY`
49+
environment variables to tell the build system where to find those libraries if
50+
they are in specific locations. Take a look at
51+
[setup.py](https://github.com/pytorch/vision/blob/main/setup.py) for more
52+
details.
53+
54+
### Clone and install torchvision
4355

4456
```bash
4557
git clone https://github.com/pytorch/vision.git
4658
cd vision
47-
python setup.py develop
59+
python setup.py develop # use install instead of develop if you don't care about development.
4860
# or, for OSX
4961
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop
50-
# for C++ debugging, please use DEBUG=1
62+
# for C++ debugging, use DEBUG=1
5163
# DEBUG=1 python setup.py develop
52-
pip install flake8 typing mypy pytest pytest-mock scipy
5364
```
54-
You may also have to install `libpng-dev` and `libjpeg-turbo8-dev` libraries:
55-
```bash
56-
conda install libpng jpeg
65+
66+
By default, GPU support is built if CUDA is found and `torch.cuda.is_available()` is true. It's possible to force
67+
building GPU support by setting `FORCE_CUDA=1` environment variable, which is useful when building a docker image.
68+
69+
We don't officially support building from source using `pip`, but _if_ you do, you'll need to use the
70+
`--no-build-isolation` flag.
71+
72+
Other development dependencies include:
73+
74+
```
75+
pip install flake8 typing mypy pytest pytest-mock scipy
5776
```
5877

5978
## Development Process
@@ -66,12 +85,12 @@ If you plan to modify the code or documentation, please follow the steps below:
6685
4. Ensure the test suite passes.
6786
5. Make sure your code passes the formatting checks (see below).
6887

69-
For more details about pull requests,
70-
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
88+
For more details about pull requests,
89+
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
7190

7291
If you would like to contribute a new model, please see [here](#New-architecture-or-improved-model-weights).
7392

74-
If you would like to contribute a new dataset, please see [here](#New-dataset).
93+
If you would like to contribute a new dataset, please see [here](#New-dataset).
7594

7695
### Code formatting and typing
7796

@@ -126,8 +145,8 @@ mypy --config-file mypy.ini
126145

127146
### Unit tests
128147

129-
If you have modified the code by adding a new feature or a bug-fix, please add unit tests for that. To run a specific
130-
test:
148+
If you have modified the code by adding a new feature or a bug-fix, please add unit tests for that. To run a specific
149+
test:
131150
```bash
132151
pytest test/<test-module.py> -vvv -k <test_myfunc>
133152
# e.g. pytest test/test_transforms.py -vvv -k test_center_crop
@@ -136,7 +155,7 @@ pytest test/<test-module.py> -vvv -k <test_myfunc>
136155
If you would like to run all tests:
137156
```bash
138157
pytest test -vvv
139-
```
158+
```
140159

141160
Tests that require internet access should be in
142161
`test/test_internet.py`.
@@ -189,18 +208,18 @@ with "transforms" in their name.
189208
### New architecture or improved model weights
190209

191210
Please refer to the guidelines in [Contributing to Torchvision - Models](https://github.com/pytorch/vision/blob/main/CONTRIBUTING_MODELS.md).
192-
211+
193212
### New dataset
194213

195-
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
214+
Please, do not send any PR with a new dataset without discussing
196215
it in an issue as, most likely, it will not be accepted.
197216

198217
### Pull Request
199218

200-
If all previous checks (flake8, mypy, unit tests) are passing, please send a PR. Submitted PR will pass other tests on
219+
If all previous checks (flake8, mypy, unit tests) are passing, please send a PR. Submitted PR will pass other tests on
201220
different operating systems, python versions and hardware.
202221

203-
For more details about pull requests workflow,
222+
For more details about pull requests workflow,
204223
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
205224

206225
## License

README.md

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ vision.
88

99
## Installation
1010

11-
We recommend Anaconda as Python package management system. Please refer to [pytorch.org](https://pytorch.org/) for the
12-
detail of PyTorch (`torch`) installation. The following is the corresponding `torchvision` versions and supported Python
11+
Please refer to the [official
12+
instructions](https://pytorch.org/get-started/locally/) to install the stable
13+
versions of `torch` and `torchvision` on your system.
14+
15+
To build source, refer to our [contributing
16+
page](https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md#development-installation).
17+
18+
The following is the corresponding `torchvision` versions and supported Python
1319
versions.
1420

1521
| `torch` | `torchvision` | Python |
@@ -39,54 +45,18 @@ versions.
3945

4046
</details>
4147

42-
Anaconda:
43-
44-
```
45-
conda install torchvision -c pytorch
46-
```
47-
48-
pip:
49-
50-
```
51-
pip install torchvision
52-
```
48+
## Image Backends
5349

54-
From source:
55-
56-
```
57-
python setup.py install
58-
# or, for OSX
59-
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
60-
```
61-
62-
We don't officially support building from source using `pip`, but _if_ you do, you'll need to use the
63-
`--no-build-isolation` flag. In case building TorchVision from source fails, install the nightly version of PyTorch
64-
following the linked guide on the
65-
[contributing page](https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md#development-installation) and retry the
66-
install.
67-
68-
By default, GPU support is built if CUDA is found and `torch.cuda.is_available()` is true. It's possible to force
69-
building GPU support by setting `FORCE_CUDA=1` environment variable, which is useful when building a docker image.
50+
Torchvision currently supports the following image backends:
7051

71-
## Image Backend
52+
- torch tensors
53+
- PIL images:
54+
- [Pillow](https://python-pillow.org/)
55+
- [Pillow-SIMD](https://github.com/uploadcare/pillow-simd) - a **much faster** drop-in replacement for Pillow with SIMD.
7256

73-
Torchvision currently supports the following image backends:
57+
Read more in in our [docs](https://pytorch.org/vision/stable/transforms.html).
7458

75-
- [Pillow](https://python-pillow.org/) (default)
76-
- [Pillow-SIMD](https://github.com/uploadcare/pillow-simd) - a **much faster** drop-in replacement for Pillow with SIMD.
77-
If installed will be used as the default.
78-
- [accimage](https://github.com/pytorch/accimage) - if installed can be activated by calling
79-
`torchvision.set_image_backend('accimage')`
80-
- [libpng](http://www.libpng.org/pub/png/libpng.html) - can be installed via conda `conda install libpng` or any of the
81-
package managers for debian-based and RHEL-based Linux distributions.
82-
- [libjpeg](http://ijg.org/) - can be installed via conda `conda install jpeg` or any of the package managers for
83-
debian-based and RHEL-based Linux distributions. [libjpeg-turbo](https://libjpeg-turbo.org/) can be used as well.
84-
85-
**Notes:** `libpng` and `libjpeg` must be available at compilation time in order to be available. Make sure that it is
86-
available on the standard library locations, otherwise, add the include and library paths in the environment variables
87-
`TORCHVISION_INCLUDE` and `TORCHVISION_LIBRARY`, respectively.
88-
89-
## Video Backend
59+
## [UNSTABLE] Video Backend
9060

9161
Torchvision currently supports the following video backends:
9262

cmake/iOS.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
1111
#
1212
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
13-
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
13+
# By default this location is automatically chosen based on the IOS_PLATFORM value above.
1414
# If set manually, it will override the default location and force the user of a particular Developer Platform
1515
#
1616
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
17-
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
17+
# By default this location is automatically chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
1818
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
1919
# If set manually, this will force the use of a specific SDK version
2020

@@ -100,7 +100,7 @@ if(IOS_DEPLOYMENT_TARGET)
100100
set(XCODE_IOS_PLATFORM_VERSION_FLAGS "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
101101
endif()
102102

103-
# Hidden visibilty is required for cxx on iOS
103+
# Hidden visibility is required for cxx on iOS
104104
set(CMAKE_C_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS}")
105105
set(CMAKE_CXX_FLAGS_INIT "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fvisibility-inlines-hidden")
106106

docs/source/conf.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
import pytorch_sphinx_theme
3030
import torchvision
3131
import torchvision.models as M
32+
from sphinx_gallery.sorting import ExplicitOrder
3233
from tabulate import tabulate
3334

3435
sys.path.append(os.path.abspath("."))
3536

36-
torchvision.disable_beta_transforms_warning()
37-
import torchvision.datapoints # Don't remove, otherwise the docs for datapoints aren't linked properly
38-
3937
# -- General configuration ------------------------------------------------
4038

4139
# Required version of sphinx is set from docs/requirements.txt
@@ -58,9 +56,30 @@
5856
"beta_status",
5957
]
6058

59+
# We override sphinx-gallery's example header to prevent sphinx-gallery from
60+
# creating a note at the top of the renderred notebook.
61+
# https://github.com/sphinx-gallery/sphinx-gallery/blob/451ccba1007cc523f39cbcc960ebc21ca39f7b75/sphinx_gallery/gen_rst.py#L1267-L1271
62+
# This is because we also want to add a link to google collab, so we write our own note in each example.
63+
from sphinx_gallery import gen_rst
64+
65+
gen_rst.EXAMPLE_HEADER = """
66+
.. DO NOT EDIT.
67+
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
68+
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
69+
.. "{0}"
70+
.. LINE NUMBERS ARE GIVEN BELOW.
71+
72+
.. rst-class:: sphx-glr-example-title
73+
74+
.. _sphx_glr_{1}:
75+
76+
"""
77+
78+
6179
sphinx_gallery_conf = {
6280
"examples_dirs": "../../gallery/", # path to your example scripts
6381
"gallery_dirs": "auto_examples", # path to where to save gallery generated output
82+
"subsection_order": ExplicitOrder(["../../gallery/v2_transforms", "../../gallery/others"]),
6483
"backreferences_dir": "gen_modules/backreferences",
6584
"doc_module": ("torchvision",),
6685
"remove_config_comments": True,

docs/source/datapoints.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _datapoints:
2+
13
Datapoints
24
==========
35

@@ -6,7 +8,7 @@ Datapoints
68
Datapoints are tensor subclasses which the :mod:`~torchvision.transforms.v2` v2 transforms use under the hood to
79
dispatch their inputs to the appropriate lower-level kernels. Most users do not
810
need to manipulate datapoints directly and can simply rely on dataset wrapping -
9-
see e.g. :ref:`sphx_glr_auto_examples_plot_transforms_v2_e2e.py`.
11+
see e.g. :ref:`sphx_glr_auto_examples_v2_transforms_plot_transforms_v2_e2e.py`.
1012

1113
.. autosummary::
1214
:toctree: generated/

docs/source/datasets.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _datasets:
2+
13
Datasets
24
========
35

0 commit comments

Comments
 (0)