Skip to content

Commit 8a72b87

Browse files
committed
Merge branch 'master' of https://github.com/pytorch/vision into rand_gauss_blur_patch
2 parents 38f3c9c + 1b41525 commit 8a72b87

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

+2149
-866
lines changed

.circleci/config.yml

Lines changed: 451 additions & 153 deletions
Large diffs are not rendered by default.

.circleci/config.yml.in

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ jobs:
212212
binary_macos_wheel:
213213
<<: *binary_common
214214
macos:
215-
xcode: "9.0"
215+
xcode: "9.4.1"
216216
steps:
217217
- checkout_merge
218218
- run:
@@ -234,7 +234,7 @@ jobs:
234234
binary_macos_conda:
235235
<<: *binary_common
236236
macos:
237-
xcode: "9.0"
237+
xcode: "9.4.1"
238238
steps:
239239
- checkout_merge
240240
- run:
@@ -551,6 +551,76 @@ jobs:
551551
- store_test_results:
552552
path: test-results
553553

554+
cmake_linux_cpu:
555+
<<: *binary_common
556+
docker:
557+
- image: "pytorch/manylinux-cuda102"
558+
resource_class: 2xlarge+
559+
steps:
560+
- checkout_merge
561+
- run:
562+
name: Setup conda
563+
command: .circleci/unittest/linux/scripts/setup_env.sh
564+
- run: packaging/build_cmake.sh
565+
566+
cmake_linux_gpu:
567+
<<: *binary_common
568+
machine:
569+
image: ubuntu-1604-cuda-10.1:201909-23
570+
resource_class: gpu.small
571+
environment:
572+
PYTHON_VERSION: << parameters.python_version >>
573+
PYTORCH_VERSION: << parameters.pytorch_version >>
574+
UNICODE_ABI: << parameters.unicode_abi >>
575+
CU_VERSION: << parameters.cu_version >>
576+
steps:
577+
- checkout_merge
578+
- run:
579+
name: Setup conda
580+
command: docker run -e CU_VERSION -e PYTHON_VERSION -e UNICODE_ABI -e PYTORCH_VERSION -t --gpus all -v $PWD:$PWD -w $PWD << parameters.wheel_docker_image >> .circleci/unittest/linux/scripts/setup_env.sh
581+
- run:
582+
name: Build torchvision C++ distribution and test
583+
command: docker run -e CU_VERSION -e PYTHON_VERSION -e UNICODE_ABI -e PYTORCH_VERSION -t --gpus all -v $PWD:$PWD -w $PWD << parameters.wheel_docker_image >> packaging/build_cmake.sh
584+
585+
cmake_macos_cpu:
586+
<<: *binary_common
587+
macos:
588+
xcode: "9.0"
589+
steps:
590+
- checkout_merge
591+
- run:
592+
command: |
593+
curl -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
594+
sh conda.sh -b
595+
source $HOME/miniconda3/bin/activate
596+
conda install -yq conda-build cmake
597+
packaging/build_cmake.sh
598+
599+
cmake_windows_cpu:
600+
<<: *binary_common
601+
executor:
602+
name: windows-cpu
603+
steps:
604+
- checkout_merge
605+
- run:
606+
command: |
607+
set -ex
608+
source packaging/windows/internal/vc_install_helper.sh
609+
packaging/build_cmake.sh
610+
611+
cmake_windows_gpu:
612+
<<: *binary_common
613+
executor:
614+
name: windows-gpu
615+
steps:
616+
- checkout_merge
617+
- run:
618+
command: |
619+
set -ex
620+
source packaging/windows/internal/vc_install_helper.sh
621+
packaging/windows/internal/cuda_install.bat
622+
packaging/build_cmake.sh
623+
554624
workflows:
555625
build:
556626
{%- if True %}
@@ -564,6 +634,11 @@ workflows:
564634
unittest:
565635
jobs:
566636
{{ unittest_workflows() }}
637+
638+
cmake:
639+
jobs:
640+
{{ cmake_workflows() }}
641+
567642
nightly:
568643
{%- endif %}
569644
jobs:

.circleci/regenerate.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def build_workflows(prefix='', filter_branch=None, upload=False, indentation=6,
2727
for btype in ["wheel", "conda"]:
2828
for os_type in ["linux", "macos", "win"]:
2929
python_versions = PYTHON_VERSIONS
30-
cu_versions = (["cpu", "cu92", "cu101", "cu102"] if os_type == "linux" or os_type == "win" else ["cpu"])
30+
cu_versions_dict = {"linux": ["cpu", "cu92", "cu101", "cu102", "cu110"],
31+
"win": ["cpu", "cu101", "cu102", "cu110"],
32+
"macos": ["cpu"]}
33+
cu_versions = cu_versions_dict[os_type]
3134
for python_version in python_versions:
3235
for cu_version in cu_versions:
3336
for unicode in ([False, True] if btype == "wheel" and python_version == "2.7" else [False]):
@@ -66,6 +69,7 @@ def workflow_pair(btype, os_type, python_version, cu_version, unicode, prefix=''
6669
"cu92": "pytorch/manylinux-cuda92",
6770
"cu101": "pytorch/manylinux-cuda101",
6871
"cu102": "pytorch/manylinux-cuda102",
72+
"cu110": "pytorch/manylinux-cuda110",
6973
}
7074

7175

@@ -181,6 +185,25 @@ def unittest_workflows(indentation=6):
181185
return indent(indentation, jobs)
182186

183187

188+
def cmake_workflows(indentation=6):
189+
jobs = []
190+
python_version = '3.8'
191+
for os_type in ['linux', 'windows', 'macos']:
192+
# Right now CMake builds are failling on Windows (GPU)
193+
device_types = ['cpu', 'gpu'] if os_type == 'linux' else ['cpu']
194+
for device in device_types:
195+
job = {
196+
'name': f'cmake_{os_type}_{device}',
197+
'python_version': python_version
198+
}
199+
200+
job['cu_version'] = 'cu101' if device == 'gpu' else 'cpu'
201+
if device == 'gpu':
202+
job['wheel_docker_image'] = 'pytorch/manylinux-cuda101'
203+
jobs.append({f'cmake_{os_type}_{device}': job})
204+
return indent(indentation, jobs)
205+
206+
184207
if __name__ == "__main__":
185208
d = os.path.dirname(__file__)
186209
env = jinja2.Environment(
@@ -193,4 +216,5 @@ def unittest_workflows(indentation=6):
193216
f.write(env.get_template('config.yml.in').render(
194217
build_workflows=build_workflows,
195218
unittest_workflows=unittest_workflows,
219+
cmake_workflows=cmake_workflows,
196220
))

.circleci/unittest/linux/scripts/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ eval "$(./conda/bin/conda shell.bash hook)"
66
conda activate ./env
77

88
python -m torch.utils.collect_env
9-
pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test
9+
pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test --ignore=test/test_datasets_download.py

.circleci/unittest/windows/scripts/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ dependencies:
1414
- pillow>=4.1.1
1515
- scipy==1.4.1
1616
- av
17+
- dataclasses

.circleci/unittest/windows/scripts/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ eval "$(./conda/Scripts/conda.exe 'shell.bash' 'hook')"
66
conda activate ./env
77

88
python -m torch.utils.collect_env
9-
pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test
9+
pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test --ignore=test/test_datasets_download.py
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Scheduled workflow {{ env.WORKFLOW }}/{{ env.JOB }} failed
3+
labels: bug, module: datasets
4+
---
5+
6+
Oh no, something went wrong in the scheduled workflow {{ env.WORKFLOW }}/{{ env.JOB }}.
7+
Please look into it:
8+
9+
https://github.com/{{ env.REPO }}/actions/runs/{{ env.ID }}
10+
11+
Feel free to close this if this was just a one-off error.

.github/workflows/tests-schedule.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: tests
2+
3+
on:
4+
pull_request:
5+
- "test/test_datasets_download.py"
6+
- ".github/failed_schedule_issue_template.md"
7+
- ".github/workflows/tests-schedule.yml"
8+
9+
schedule:
10+
- cron: "0 9 * * *"
11+
12+
jobs:
13+
download:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Set up python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.6
21+
22+
- name: Upgrade pip
23+
run: python -m pip install --upgrade pip
24+
25+
- name: Install PyTorch from the nightlies
26+
run: |
27+
pip install numpy
28+
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
29+
30+
- name: Install tests requirements
31+
run: pip install pytest pytest-subtests
32+
33+
- name: Run tests
34+
run: pytest test/test_datasets_download.py
35+
36+
- uses: JasonEtco/[email protected]
37+
name: Create issue if download tests failed
38+
if: failure()
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
REPO: ${{ github.repository }}
42+
WORKFLOW: ${{ github.workflow }}
43+
JOB: ${{ github.job }}
44+
ID: ${{ github.run_id }}
45+
with:
46+
filename: .github/failed_schedule_issue_template.md

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
# Useful for debugging any issues with conda
2323
- conda info -a
2424

25-
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytorch scipy -c pytorch-nightly
25+
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION cpuonly pytorch scipy -c pytorch-nightly
2626
- source activate test-environment
2727
- |
2828
if [[ "$IMAGE_BACKEND" == "Pillow-SIMD" ]]; then
@@ -55,7 +55,7 @@ install:
5555
cd -
5656
5757
script:
58-
- pytest --cov-config .coveragerc --cov torchvision --cov $TV_INSTALL_PATH -k 'not TestVideoReader and not TestVideoTransforms and not TestIO' test
58+
- pytest --cov-config .coveragerc --cov torchvision --cov $TV_INSTALL_PATH -k 'not TestVideoReader and not TestVideoTransforms and not TestIO' test --ignore=test/test_datasets_download.py
5959
- pytest test/test_hub.py
6060

6161
after_success:

cmake/TorchVisionConfig.cmake.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ endif()
3131
if(NOT TARGET Python3::Python)
3232
find_package(Python3 COMPONENTS Development)
3333
endif()
34-
target_link_libraries(TorchVision::TorchVision INTERFACE ${TORCH_LIBRARIES} Python3::Python)
34+
35+
set_target_properties(TorchVision::TorchVision PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@" INTERFACE_LINK_LIBRARIES "torch;Python3::Python" )
36+
3537

3638
if(@WITH_CUDA@)
3739
target_compile_definitions(TorchVision::TorchVision INTERFACE WITH_CUDA)

docs/source/models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ to::
104104
mean = torch.mean(torch.tensor(means))
105105
std = torch.mean(torch.tensor(stds))
106106

107-
Unfortunately, the concret `subset` that was used is lost. For more
107+
Unfortunately, the concrete `subset` that was used is lost. For more
108108
information see `this discussion <https://github.com/pytorch/vision/issues/1439>`_
109109
or `these experiments <https://github.com/pytorch/vision/pull/1965>`_.
110110

docs/source/ops.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ torchvision.ops
1010

1111

1212
.. autofunction:: nms
13+
.. autofunction:: batched_nms
14+
.. autofunction:: remove_small_boxes
15+
.. autofunction:: clip_boxes_to_image
16+
.. autofunction:: box_area
17+
.. autofunction:: box_iou
1318
.. autofunction:: roi_align
1419
.. autofunction:: ps_roi_align
1520
.. autofunction:: roi_pool

docs/source/transforms.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@ Functional transforms give fine-grained control over the transformations.
99
This is useful if you have to build a more complex transformation pipeline
1010
(e.g. in the case of segmentation tasks).
1111

12+
All transformations accept PIL Image, Tensor Image or batch of Tensor Images as input. Tensor Image is a tensor with
13+
``(C, H, W)`` shape, where ``C`` is a number of channels, ``H`` and ``W`` are image height and width. Batch of
14+
Tensor Images is a tensor of ``(B, C, H, W)`` shape, where ``B`` is a number of images in the batch. Deterministic or
15+
random transformations applied on the batch of Tensor Images identically transform all the images of the batch.
16+
17+
18+
Scriptable transforms
19+
^^^^^^^^^^^^^^^^^^^^^
20+
21+
In order to script the transformations, please use ``torch.nn.Sequential`` instead of :class:`Compose`.
22+
23+
.. code:: python
24+
25+
transforms = torch.nn.Sequential(
26+
transforms.CenterCrop(10),
27+
transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
28+
)
29+
scripted_transforms = torch.jit.script(transforms)
30+
31+
Make sure to use only scriptable transformations, i.e. that work with ``torch.Tensor`` and does not require
32+
`lambda` functions or ``PIL.Image``.
33+
34+
For any custom transformations to be used with ``torch.jit.script``, they should be derived from ``torch.nn.Module``.
35+
36+
1237
.. autoclass:: Compose
1338

1439
Transforms on PIL Image

examples/cpp/hello_world/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ add_executable(hello-world main.cpp)
1111
# We now need to link the TorchVision library to our executable.
1212
# We can do that by using the TorchVision::TorchVision target,
1313
# which also adds all the necessary torch dependencies.
14+
target_compile_features(hello-world PUBLIC cxx_range_for)
1415
target_link_libraries(hello-world TorchVision::TorchVision)
16+
set_property(TARGET hello-world PROPERTY CXX_STANDARD 14)

examples/cpp/hello_world/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <iostream>
2-
32
#include <torchvision/models/resnet.h>
43

54
int main()
@@ -11,5 +10,14 @@ int main()
1110
auto in = torch::rand({1, 3, 10, 10});
1211
auto out = model->forward(in);
1312

14-
std::cout << out;
13+
std::cout << out.sizes();
14+
15+
if (torch::cuda::is_available()) {
16+
// Move model and inputs to GPU
17+
model->to(torch::kCUDA);
18+
auto gpu_in = in.to(torch::kCUDA);
19+
auto gpu_out = model->forward(gpu_in);
20+
21+
std::cout << gpu_out.sizes();
22+
}
1523
}

mypy.ini

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@ files = torchvision
44
show_error_codes = True
55
pretty = True
66

7-
;[mypy-torchvision.datasets.*]
7+
[mypy-torchvision.io._video_opt.*]
88

9-
;ignore_errors = True
9+
ignore_errors = True
1010

1111
[mypy-torchvision.io.*]
1212

1313
ignore_errors = True
1414

15-
[mypy-torchvision.models.*]
15+
[mypy-torchvision.models.detection.*]
16+
17+
ignore_errors = True
18+
19+
[mypy-torchvision.models.densenet.*]
20+
21+
ignore_errors = True
22+
23+
[mypy-torchvision.models.quantization.*]
1624

1725
ignore_errors = True
1826

@@ -51,3 +59,7 @@ ignore_missing_imports = True
5159
[mypy-accimage.*]
5260

5361
ignore_missing_imports = True
62+
63+
[mypy-av.*]
64+
65+
ignore_missing_imports = True

0 commit comments

Comments
 (0)