Skip to content

Commit 918dd9b

Browse files
committed
Merge branch 'main' into mvitv1
2 parents 61c9894 + 12bb887 commit 918dd9b

Some content is hidden

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

54 files changed

+733
-96
lines changed

.github/workflows/build-m1-binaries.yml

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ on:
77
branches:
88
- nightly
99
- main
10+
- release/*
11+
tags:
12+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
13+
# Release candidate tags look like: v1.11.0-rc1
14+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
1015
workflow_dispatch:
16+
env:
17+
CHANNEL: "nightly"
1118
jobs:
1219
build_wheels:
1320
name: "Build TorchVision M1 wheels"
@@ -18,6 +25,17 @@ jobs:
1825
steps:
1926
- name: Checkout repository
2027
uses: actions/checkout@v2
28+
- name: Set CHANNEL (only for tagged pushes)
29+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
30+
run: |
31+
# reference ends with an RC suffix
32+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
33+
echo "CHANNEL=test" >> "$GITHUB_ENV"
34+
fi
35+
- name: Set Release CHANNEL (for release)
36+
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
37+
run: |
38+
echo "CHANNEL=test" >> "$GITHUB_ENV"
2139
- name: Build TorchVision M1 wheel
2240
shell: arch -arch arm64 bash {0}
2341
env:
@@ -29,10 +47,16 @@ jobs:
2947
export PATH=~/miniconda3/bin:$PATH
3048
set -ex
3149
. packaging/pkg_helpers.bash
32-
setup_build_version
50+
# if we are uploading to test channell, our version consist only of the base: 0.x.x - no date string or suffix added
51+
if [[ $CHANNEL == "test" ]]; then
52+
setup_base_build_version
53+
else
54+
setup_build_version
55+
fi
56+
3357
WHL_NAME=torchvision-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
3458
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg wheel pkg-config
35-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
59+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
3660
conda run -p ${ENV_NAME} python3 -mpip install delocate
3761
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
3862
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
@@ -47,27 +71,89 @@ jobs:
4771
. ~/miniconda3/etc/profile.d/conda.sh
4872
set -ex
4973
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
50-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
74+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
5175
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
5276
# Test torch is importable, by changing cwd and running import commands
5377
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchvision;print('torchvision version is ', torchvision.__version__)"
5478
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torch;import torchvision;print('Is torchvision useable?', all(x is not None for x in [torch.ops.image.decode_png, torch.ops.torchvision.roi_align]))"
5579
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchvision;print(torchvision.io.read_image('${PWD}/gallery/assets/dog1.jpg').shape)"
5680
conda env remove -p ${ENV_NAME}
5781
- name: Upload wheel to GitHub
58-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
5982
uses: actions/upload-artifact@v3
6083
with:
6184
name: torchvision-py${{ matrix.py_vers }}-macos11-m1
6285
path: dist/
6386
- name: Upload wheel to S3
64-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
87+
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
6588
shell: arch -arch arm64 bash {0}
6689
env:
6790
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }}
6891
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }}
69-
CHANNEL: nightly
7092
run: |
7193
for pkg in dist/*; do
7294
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read
7395
done
96+
build_conda:
97+
name: "Build TorchVision M1 conda packages"
98+
runs-on: macos-m1
99+
strategy:
100+
matrix:
101+
py_vers: [ "3.8", "3.9", "3.10" ]
102+
steps:
103+
- name: Checkout repository
104+
uses: actions/checkout@v2
105+
- name: Set CHANNEL (only for tagged pushes)
106+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
107+
run: |
108+
# reference ends with an RC suffix
109+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
110+
echo "CHANNEL=test" >> "$GITHUB_ENV"
111+
fi
112+
- name: Set CHANNEL Release (for release)
113+
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
114+
run: |
115+
echo "CHANNEL=test" >> "$GITHUB_ENV"
116+
- name: Install conda-build and purge previous artifacts
117+
shell: arch -arch arm64 bash {0}
118+
run: |
119+
. ~/miniconda3/etc/profile.d/conda.sh
120+
conda install -yq conda-build
121+
conda build purge-all
122+
123+
- name: Build TorchVision M1 conda package
124+
shell: arch -arch arm64 bash {0}
125+
env:
126+
ENV_NAME: conda-env-${{ github.run_id }}
127+
PYTHON_VERSION: ${{ matrix.py_vers }}
128+
CU_VERSION: cpu
129+
run: |
130+
. ~/miniconda3/etc/profile.d/conda.sh
131+
set -ex
132+
. packaging/pkg_helpers.bash
133+
134+
if [[ $CHANNEL == "test" ]]; then
135+
setup_base_build_version
136+
else
137+
setup_build_version
138+
fi
139+
140+
setup_conda_pytorch_constraint
141+
export SOURCE_ROOT_DIR=$(pwd)
142+
conda build -c defaults $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchvision
143+
mkdir -p dist
144+
cp ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 dist/
145+
- name: Upload package to GitHub
146+
uses: actions/upload-artifact@v3
147+
with:
148+
name: torchvision-py${{ matrix.py_vers }}-macos11-m1-conda
149+
path: dist/
150+
- name: Upload package to conda
151+
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
152+
shell: arch -arch arm64 bash {0}
153+
env:
154+
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
155+
run: |
156+
. ~/miniconda3/etc/profile.d/conda.sh
157+
conda install -yq anaconda-client
158+
set -x
159+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 -u "pytorch-${CHANNEL}" --label main --no-progress --force

.github/workflows/test-m1.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ on:
77
branches:
88
- nightly
99
- main
10+
- release/*
1011
workflow_dispatch:
12+
env:
13+
CHANNEL: "nightly"
1114
jobs:
1215
tests:
1316
name: "Unit-tests on M1"
@@ -19,6 +22,10 @@ jobs:
1922
steps:
2023
- name: Checkout repository
2124
uses: actions/checkout@v2
25+
- name: Set Release CHANNEL (for release)
26+
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
27+
run: |
28+
echo "CHANNEL=test" >> "$GITHUB_ENV"
2229
- name: Install TorchVision
2330
shell: arch -arch arm64 bash {0}
2431
env:
@@ -30,7 +37,7 @@ jobs:
3037
export PATH=~/miniconda3/bin:$PATH
3138
set -ex
3239
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy
33-
conda run -p ${ENV_NAME} python3 -mpip install torch --extra-index-url=https://download.pytorch.org/whl/nightly
40+
conda run -p ${ENV_NAME} python3 -mpip install --pre torch --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
3441
conda run -p ${ENV_NAME} python3 setup.py develop
3542
conda run -p ${ENV_NAME} python3 -mpip install pytest pytest-mock av
3643
- name: Run tests

docs/source/beta_status.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from docutils import nodes
2+
from docutils.parsers.rst import Directive
3+
4+
5+
class BetaStatus(Directive):
6+
has_content = True
7+
8+
def run(self):
9+
api_name = " ".join(self.content)
10+
text = f"The {api_name} is in Beta stage, and backward compatibility is not guaranteed."
11+
return [nodes.warning("", nodes.paragraph("", "", nodes.Text(text)))]
12+
13+
14+
def setup(app):
15+
app.add_directive("betastatus", BetaStatus)
16+
return {
17+
"version": "0.1",
18+
"parallel_read_safe": True,
19+
"parallel_write_safe": True,
20+
}

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# sys.path.insert(0, os.path.abspath('.'))
2222

2323
import os
24+
import sys
2425
import textwrap
2526
from copy import copy
2627
from pathlib import Path
@@ -30,6 +31,7 @@
3031
import torchvision.models as M
3132
from tabulate import tabulate
3233

34+
sys.path.append(os.path.abspath("."))
3335

3436
# -- General configuration ------------------------------------------------
3537

@@ -50,6 +52,7 @@
5052
"sphinx.ext.duration",
5153
"sphinx_gallery.gen_gallery",
5254
"sphinx_copybutton",
55+
"beta_status",
5356
]
5457

5558
sphinx_gallery_conf = {

docs/source/io.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ In addition to the :mod:`read_video` function, we provide a high-performance
2626
lower-level API for more fine-grained control compared to the :mod:`read_video` function.
2727
It does all this whilst fully supporting torchscript.
2828

29+
.. betastatus:: fine-grained video API
30+
2931
.. autosummary::
3032
:toctree: generated/
3133
:template: class.rst

docs/source/models.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ Semantic Segmentation
272272

273273
.. currentmodule:: torchvision.models.segmentation
274274

275+
.. betastatus:: segmentation module
276+
275277
The following semantic segmentation models are available, with or without
276278
pre-trained weights:
277279

@@ -334,6 +336,8 @@ keypoint detection are initialized with the classification models
334336
in torchvision. The models expect a list of ``Tensor[C, H, W]``.
335337
Check the constructor of the models for more information.
336338

339+
.. betastatus:: detection module
340+
337341
Object Detection
338342
----------------
339343

@@ -453,6 +457,8 @@ Video Classification
453457

454458
.. currentmodule:: torchvision.models.video
455459

460+
.. betastatus:: video module
461+
456462
The following video classification models are available, with or without
457463
pre-trained weights:
458464

docs/source/models/deeplabv3.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ DeepLabV3
66
The DeepLabV3 model is based on the `Rethinking Atrous Convolution for Semantic
77
Image Segmentation <https://arxiv.org/abs/1706.05587>`__ paper.
88

9+
.. betastatus:: segmentation module
10+
911

1012
Model builders
1113
--------------

docs/source/models/faster_rcnn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ Faster R-CNN
33

44
.. currentmodule:: torchvision.models.detection
55

6+
67
The Faster R-CNN model is based on the `Faster R-CNN: Towards Real-Time Object Detection
78
with Region Proposal Networks <https://arxiv.org/abs/1506.01497>`__
89
paper.
910

11+
.. betastatus:: detection module
1012

1113
Model builders
1214
--------------

docs/source/models/fcn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The FCN model is based on the `Fully Convolutional Networks for Semantic
77
Segmentation <https://arxiv.org/abs/1411.4038>`__
88
paper.
99

10+
.. betastatus:: segmentation module
11+
1012

1113
Model builders
1214
--------------

docs/source/models/fcos.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ FCOS
66
The RetinaNet model is based on the `FCOS: Fully Convolutional One-Stage Object Detection
77
<https://arxiv.org/abs/1904.01355>`__ paper.
88

9+
.. betastatus:: detection module
10+
911
Model builders
1012
--------------
1113

docs/source/models/keypoint_rcnn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Keypoint R-CNN
66
The Keypoint R-CNN model is based on the `Mask R-CNN
77
<https://arxiv.org/abs/1703.06870>`__ paper.
88

9+
.. betastatus:: detection module
10+
911

1012
Model builders
1113
--------------

docs/source/models/lraspp.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LRASPP
55

66
The LRASPP model is based on the `Searching for MobileNetV3 <https://arxiv.org/abs/1905.02244>`_ paper.
77

8+
.. betastatus:: segmentation module
9+
810
Model builders
911
--------------
1012

docs/source/models/mask_rcnn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Mask R-CNN
66
The Mask R-CNN model is based on the `Mask R-CNN <https://arxiv.org/abs/1703.06870>`__
77
paper.
88

9+
.. betastatus:: detection module
10+
911

1012
Model builders
1113
--------------

docs/source/models/resnext.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ more details about this class.
2323

2424
resnext50_32x4d
2525
resnext101_32x8d
26+
resnext101_64x4d

docs/source/models/retinanet.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ RetinaNet
66
The RetinaNet model is based on the `Focal Loss for Dense Object Detection
77
<https://arxiv.org/abs/1708.02002>`__ paper.
88

9+
.. betastatus:: detection module
10+
911
Model builders
1012
--------------
1113

docs/source/models/ssd.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ SSD
66
The SSD model is based on the `SSD: Single Shot MultiBox Detector
77
<https://arxiv.org/abs/1512.02325>`__ paper.
88

9+
.. betastatus:: detection module
10+
911

1012
Model builders
1113
--------------

docs/source/models/ssdlite.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The SSDLite model is based on the `SSD: Single Shot MultiBox Detector
88
<https://arxiv.org/abs/1905.02244>`__ and `MobileNetV2: Inverted Residuals and Linear
99
Bottlenecks <https://arxiv.org/abs/1801.04381>__` papers.
1010

11+
.. betastatus:: detection module
1112

1213
Model builders
1314
--------------

docs/source/models/video_resnet.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Video ResNet
66
The VideoResNet model is based on the `A Closer Look at Spatiotemporal
77
Convolutions for Action Recognition <https://arxiv.org/abs/1711.11248>`__ paper.
88

9+
.. betastatus:: video module
10+
911

1012
Model builders
1113
--------------

gallery/plot_optical_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def preprocess(img1_batch, img2_batch):
180180
# # Note: it would be faster to predict batches of flows instead of individual flows
181181
# img1, img2 = preprocess(img1, img2)
182182

183-
# list_of_flows = model(img1.to(device), img1.to(device))
183+
# list_of_flows = model(img1.to(device), img2.to(device))
184184
# predicted_flow = list_of_flows[-1][0]
185185
# flow_img = flow_to_image(predicted_flow).to("cpu")
186186
# output_folder = "/tmp/" # Update this to the folder of your choice

gallery/plot_transforms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):
149149
affine_imgs = [affine_transfomer(orig_img) for _ in range(4)]
150150
plot(affine_imgs)
151151

152+
####################################
153+
# ElasticTransform
154+
# ~~~~~~~~~~~~~~~~
155+
# The :class:`~torchvision.transforms.ElasticTransform` transform
156+
# (see also :func:`~torchvision.transforms.functional.elastic_transform`)
157+
# Randomly transforms the morphology of objects in images and produces a
158+
# see-through-water-like effect.
159+
elastic_transformer = T.ElasticTransform(alpha=250.0)
160+
transformed_imgs = [elastic_transformer(orig_img) for _ in range(2)]
161+
plot(transformed_imgs)
162+
152163
####################################
153164
# RandomCrop
154165
# ~~~~~~~~~~

0 commit comments

Comments
 (0)