From 043d1d4124510275a57f9b45b190e885a31bc547 Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Mon, 8 Jan 2024 17:17:50 -0800 Subject: [PATCH 01/12] Added pathlib support to datasets/utils.py --- test/test_datasets_utils.py | 26 +++++++++++++++++++----- torchvision/datasets/utils.py | 38 ++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/test/test_datasets_utils.py b/test/test_datasets_utils.py index 4e30dfab2cc..fa346b09f5d 100644 --- a/test/test_datasets_utils.py +++ b/test/test_datasets_utils.py @@ -58,8 +58,11 @@ def test_get_redirect_url_max_hops_exceeded(self, mocker): assert mock.call_count == 1 assert mock.call_args[0][0].full_url == url - def test_check_md5(self): + @pytest.mark.parametrize("use_pathlib", (True, False)) + def test_check_md5(self, use_pathlib): fpath = TEST_FILE + if use_pathlib: + fpath = pathlib.Path(fpath) correct_md5 = "9c0bb82894bb3af7f7675ef2b3b6dcdc" false_md5 = "" assert utils.check_md5(fpath, correct_md5) @@ -116,7 +119,8 @@ def test_detect_file_type_incompatible(self, file): utils._detect_file_type(file) @pytest.mark.parametrize("extension", [".bz2", ".gz", ".xz"]) - def test_decompress(self, extension, tmpdir): + @pytest.mark.parametrize("use_pathlib", (True, False)) + def test_decompress(self, extension, tmpdir, use_pathlib): def create_compressed(root, content="this is the content"): file = os.path.join(root, "file") compressed = f"{file}{extension}" @@ -128,6 +132,8 @@ def create_compressed(root, content="this is the content"): return compressed, file, content compressed, file, content = create_compressed(tmpdir) + if use_pathlib: + compressed = pathlib.Path(compressed) utils._decompress(compressed) @@ -140,7 +146,8 @@ def test_decompress_no_compression(self): with pytest.raises(RuntimeError): utils._decompress("foo.tar") - def test_decompress_remove_finished(self, tmpdir): + @pytest.mark.parametrize("use_pathlib", (True, False)) + def test_decompress_remove_finished(self, tmpdir, use_pathlib): def create_compressed(root, content="this is the content"): file = os.path.join(root, "file") compressed = f"{file}.gz" @@ -151,6 +158,9 @@ def create_compressed(root, content="this is the content"): return compressed, file, content compressed, file, content = create_compressed(tmpdir) + if use_pathlib: + compressed = pathlib.Path(compressed) + tmpdir = pathlib.Path(tmpdir) utils.extract_archive(compressed, tmpdir, remove_finished=True) @@ -167,7 +177,8 @@ def test_extract_archive_defer_to_decompress(self, extension, remove_finished, m mocked.assert_called_once_with(file, filename, remove_finished=remove_finished) - def test_extract_zip(self, tmpdir): + @pytest.mark.parametrize("use_pathlib", (True, False)) + def test_extract_zip(self, tmpdir, use_pathlib): def create_archive(root, content="this is the content"): file = os.path.join(root, "dst.txt") archive = os.path.join(root, "archive.zip") @@ -177,6 +188,8 @@ def create_archive(root, content="this is the content"): return archive, file, content + if use_pathlib: + tmpdir = pathlib.Path(tmpdir) archive, file, content = create_archive(tmpdir) utils.extract_archive(archive, tmpdir) @@ -189,7 +202,8 @@ def create_archive(root, content="this is the content"): @pytest.mark.parametrize( "extension, mode", [(".tar", "w"), (".tar.gz", "w:gz"), (".tgz", "w:gz"), (".tar.xz", "w:xz")] ) - def test_extract_tar(self, extension, mode, tmpdir): + @pytest.mark.parametrize("use_pathlib", (True, False)) + def test_extract_tar(self, extension, mode, tmpdir, use_pathlib): def create_archive(root, extension, mode, content="this is the content"): src = os.path.join(root, "src.txt") dst = os.path.join(root, "dst.txt") @@ -203,6 +217,8 @@ def create_archive(root, extension, mode, content="this is the content"): return archive, dst, content + if use_pathlib: + tmpdir = pathlib.Path(tmpdir) archive, file, content = create_archive(tmpdir, extension, mode) utils.extract_archive(archive, tmpdir) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index f52622281f0..80744b52dc8 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -30,7 +30,7 @@ def _save_response_content( content: Iterator[bytes], - destination: str, + destination: Union[str, pathlib.Path], length: Optional[int] = None, ) -> None: with open(destination, "wb") as fh, tqdm(total=length) as pbar: @@ -43,12 +43,12 @@ def _save_response_content( pbar.update(len(chunk)) -def _urlretrieve(url: str, filename: str, chunk_size: int = 1024 * 32) -> None: +def _urlretrieve(url: str, filename: Union[str, pathlib.Path], chunk_size: int = 1024 * 32) -> None: with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": USER_AGENT})) as response: _save_response_content(iter(lambda: response.read(chunk_size), b""), filename, length=response.length) -def calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str: +def calculate_md5(fpath: Union[str, pathlib.Path], chunk_size: int = 1024 * 1024) -> str: # Setting the `usedforsecurity` flag does not change anything about the functionality, but indicates that we are # not using the MD5 checksum for cryptography. This enables its usage in restricted environments like FIPS. Without # it torchvision.datasets is unusable in these environments since we perform a MD5 check everywhere. @@ -62,11 +62,11 @@ def calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str: return md5.hexdigest() -def check_md5(fpath: str, md5: str, **kwargs: Any) -> bool: +def check_md5(fpath: Union[str, pathlib.Path], md5: str, **kwargs: Any) -> bool: return md5 == calculate_md5(fpath, **kwargs) -def check_integrity(fpath: str, md5: Optional[str] = None) -> bool: +def check_integrity(fpath: Union[str, pathlib.Path], md5: Optional[str] = None) -> bool: if not os.path.isfile(fpath): return False if md5 is None: @@ -106,7 +106,7 @@ def _get_google_drive_file_id(url: str) -> Optional[str]: def download_url( url: str, root: Union[str, pathlib.Path], - filename: Optional[str] = None, + filename: Optional[Union[str, pathlib.Path]] = None, md5: Optional[str] = None, max_redirect_hops: int = 3, ) -> None: @@ -159,7 +159,7 @@ def download_url( raise RuntimeError("File not found or corrupted.") -def list_dir(root: str, prefix: bool = False) -> List[str]: +def list_dir(root: Union[str, pathlib.Path], prefix: bool = False) -> List[str]: """List all directories at a given root Args: @@ -174,7 +174,7 @@ def list_dir(root: str, prefix: bool = False) -> List[str]: return directories -def list_files(root: str, suffix: str, prefix: bool = False) -> List[str]: +def list_files(root: Union[str, pathlib.Path], suffix: str, prefix: bool = False) -> List[str]: """List all files ending with a suffix at a given root Args: @@ -312,7 +312,7 @@ def _extract_zip(from_path: str, to_path: str, compression: Optional[str]) -> No } -def _detect_file_type(file: str) -> Tuple[str, Optional[str], Optional[str]]: +def _detect_file_type(file: Union[str, pathlib.Path]) -> Tuple[str, Optional[str], Optional[str]]: """Detect the archive type and/or compression of a file. Args: @@ -355,7 +355,11 @@ def _detect_file_type(file: str) -> Tuple[str, Optional[str], Optional[str]]: raise RuntimeError(f"Unknown compression or archive type: '{suffix}'.\nKnown suffixes are: '{valid_suffixes}'.") -def _decompress(from_path: str, to_path: Optional[str] = None, remove_finished: bool = False) -> str: +def _decompress( + from_path: Union[str, pathlib.Path], + to_path: Optional[Union[str, pathlib.Path]] = None, + remove_finished: bool = False, +) -> str: r"""Decompress a file. The compression is automatically detected from the file name. @@ -373,7 +377,7 @@ def _decompress(from_path: str, to_path: Optional[str] = None, remove_finished: raise RuntimeError(f"Couldn't detect a compression from suffix {suffix}.") if to_path is None: - to_path = from_path.replace(suffix, archive_type if archive_type is not None else "") + to_path = pathlib.Path(os.fspath(from_path).replace(suffix, archive_type if archive_type is not None else "")) # We don't need to check for a missing key here, since this was already done in _detect_file_type() compressed_file_opener = _COMPRESSED_FILE_OPENERS[compression] @@ -387,7 +391,9 @@ def _decompress(from_path: str, to_path: Optional[str] = None, remove_finished: return to_path -def extract_archive(from_path: str, to_path: Optional[str] = None, remove_finished: bool = False) -> str: +def extract_archive( + from_path: Union[str, pathlib.Path], to_path: Optional[str] = None, remove_finished: bool = False +) -> str: """Extract an archive. The archive type and a possible compression is automatically detected from the file name. If the file is compressed @@ -425,9 +431,9 @@ def extract_archive(from_path: str, to_path: Optional[str] = None, remove_finish def download_and_extract_archive( url: str, - download_root: str, - extract_root: Optional[str] = None, - filename: Optional[str] = None, + download_root: Union[str, pathlib.Path], + extract_root: Optional[Union[str, pathlib.Path]] = None, + filename: Optional[Union[str, pathlib.Path]] = None, md5: Optional[str] = None, remove_finished: bool = False, ) -> None: @@ -479,7 +485,7 @@ def verify_str_arg( return value -def _read_pfm(file_name: str, slice_channels: int = 2) -> np.ndarray: +def _read_pfm(file_name: Union[str, pathlib.Path], slice_channels: int = 2) -> np.ndarray: """Read file in .pfm format. Might contain either 1 or 3 channels of data. Args: From 5085a0c17e196c70cd8ba395fe2001eefef9b40c Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Mon, 8 Jan 2024 17:28:17 -0800 Subject: [PATCH 02/12] Formatting --- torchvision/datasets/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 80744b52dc8..91317dc010e 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -208,7 +208,10 @@ def _extract_gdrive_api_response(response, chunk_size: int = 32 * 1024) -> Tuple def download_file_from_google_drive( - file_id: str, root: Union[str, pathlib.Path], filename: Optional[str] = None, md5: Optional[str] = None + file_id: str, + root: Union[str, pathlib.Path], + filename: Optional[Union[str, pathlib.Path]] = None, + md5: Optional[str] = None, ): """Download a Google Drive file from and place it in root. From d1388ab7167b713b6ee5750037378cf03410b66f Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Mon, 8 Jan 2024 17:59:37 -0800 Subject: [PATCH 03/12] Formatting --- torchvision/datasets/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 91317dc010e..e09c4e37129 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -395,8 +395,10 @@ def _decompress( def extract_archive( - from_path: Union[str, pathlib.Path], to_path: Optional[str] = None, remove_finished: bool = False -) -> str: + from_path: Union[str, pathlib.Path], + to_path: Optional[Union[str, pathlib.Path]] = None, + remove_finished: bool = False, +) -> Union[str, pathlib.Path]: """Extract an archive. The archive type and a possible compression is automatically detected from the file name. If the file is compressed From 4c2242e36ccb8c6d820b459eef7651aaa6eb0e91 Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Tue, 9 Jan 2024 07:13:40 -0800 Subject: [PATCH 04/12] Use pathlib types for return values --- torchvision/datasets/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index e09c4e37129..a0a6cd435d7 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -362,7 +362,7 @@ def _decompress( from_path: Union[str, pathlib.Path], to_path: Optional[Union[str, pathlib.Path]] = None, remove_finished: bool = False, -) -> str: +) -> pathlib.Path: r"""Decompress a file. The compression is automatically detected from the file name. @@ -391,14 +391,14 @@ def _decompress( if remove_finished: os.remove(from_path) - return to_path + return pathlib.Path(to_path) def extract_archive( from_path: Union[str, pathlib.Path], to_path: Optional[Union[str, pathlib.Path]] = None, remove_finished: bool = False, -) -> Union[str, pathlib.Path]: +) -> pathlib.Path: """Extract an archive. The archive type and a possible compression is automatically detected from the file name. If the file is compressed @@ -431,7 +431,7 @@ def extract_archive( if remove_finished: os.remove(from_path) - return to_path + return pathlib.Path(to_path) def download_and_extract_archive( From 7f04e1303d546e5349a8de16c1677b37b10d8978 Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Tue, 9 Jan 2024 07:29:07 -0800 Subject: [PATCH 05/12] Fmt --- torchvision/datasets/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index a0a6cd435d7..4de5636af69 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -281,7 +281,9 @@ def download_file_from_google_drive( ) -def _extract_tar(from_path: str, to_path: str, compression: Optional[str]) -> None: +def _extract_tar( + from_path: Union[str, pathlib.Path], to_path: Union[str, pathlib.Path], compression: Optional[str] +) -> None: with tarfile.open(from_path, f"r:{compression[1:]}" if compression else "r") as tar: tar.extractall(to_path) @@ -292,7 +294,9 @@ def _extract_tar(from_path: str, to_path: str, compression: Optional[str]) -> No } -def _extract_zip(from_path: str, to_path: str, compression: Optional[str]) -> None: +def _extract_zip( + from_path: Union[str, pathlib.Path], to_path: Union[str, pathlib.Path], compression: Optional[str] +) -> None: with zipfile.ZipFile( from_path, "r", compression=_ZIP_COMPRESSION_MAP[compression] if compression else zipfile.ZIP_STORED ) as zip: From bba410c1e4f7652a3329fc79756284ec1def6fa5 Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Tue, 9 Jan 2024 08:04:37 -0800 Subject: [PATCH 06/12] Types for archive extractors --- torchvision/datasets/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 4de5636af69..ebdd7d8950e 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -303,7 +303,7 @@ def _extract_zip( zip.extractall(to_path) -_ARCHIVE_EXTRACTORS: Dict[str, Callable[[str, str, Optional[str]], None]] = { +_ARCHIVE_EXTRACTORS: Dict[str, Callable[[Union[str, pathlib.Path], Union[str, pathlib.Path], Optional[str]], None]] = { ".tar": _extract_tar, ".zip": _extract_zip, } From fa880c8e552d56d0a358e0d283dcf1ba20db514f Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Sat, 13 Jan 2024 16:12:40 -0800 Subject: [PATCH 07/12] fmt --- test/test_datasets_utils.py | 9 ++++++++- torchvision/datasets/utils.py | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/test_datasets_utils.py b/test/test_datasets_utils.py index fa346b09f5d..461688405d7 100644 --- a/test/test_datasets_utils.py +++ b/test/test_datasets_utils.py @@ -158,13 +158,20 @@ def create_compressed(root, content="this is the content"): return compressed, file, content compressed, file, content = create_compressed(tmpdir) + print(f"{type(compressed)=}") if use_pathlib: compressed = pathlib.Path(compressed) tmpdir = pathlib.Path(tmpdir) - utils.extract_archive(compressed, tmpdir, remove_finished=True) + extracted_dir = utils.extract_archive(compressed, tmpdir, remove_finished=True) assert not os.path.exists(compressed) + if use_pathlib: + assert isinstance(extracted_dir, pathlib.Path) + assert isinstance(compressed, pathlib.Path) + else: + assert isinstance(extracted_dir, str) + assert isinstance(compressed, str) @pytest.mark.parametrize("extension", [".gz", ".xz"]) @pytest.mark.parametrize("remove_finished", [True, False]) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index ebdd7d8950e..b87d7868299 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -402,7 +402,7 @@ def extract_archive( from_path: Union[str, pathlib.Path], to_path: Optional[Union[str, pathlib.Path]] = None, remove_finished: bool = False, -) -> pathlib.Path: +) -> Union[str, pathlib.Path]: """Extract an archive. The archive type and a possible compression is automatically detected from the file name. If the file is compressed @@ -417,16 +417,24 @@ def extract_archive( Returns: (str): Path to the directory the file was extracted to. """ + + def path_or_str(ret_path: pathlib.Path) -> Union[str, pathlib.Path]: + if isinstance(from_path, str): + return os.fspath(ret_path) + else: + return ret_path + if to_path is None: to_path = os.path.dirname(from_path) suffix, archive_type, compression = _detect_file_type(from_path) if not archive_type: - return _decompress( + ret_path = _decompress( from_path, os.path.join(to_path, os.path.basename(from_path).replace(suffix, "")), remove_finished=remove_finished, ) + return path_or_str(ret_path) # We don't need to check for a missing key here, since this was already done in _detect_file_type() extractor = _ARCHIVE_EXTRACTORS[archive_type] @@ -435,7 +443,7 @@ def extract_archive( if remove_finished: os.remove(from_path) - return pathlib.Path(to_path) + return path_or_str(to_path) def download_and_extract_archive( From f6b53a3725c73ab29a3a924cee95bd2808cc02bc Mon Sep 17 00:00:00 2001 From: Ahmad Sharif Date: Sat, 13 Jan 2024 16:23:39 -0800 Subject: [PATCH 08/12] types --- torchvision/datasets/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index b87d7868299..4d3f0d5a947 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -443,7 +443,7 @@ def path_or_str(ret_path: pathlib.Path) -> Union[str, pathlib.Path]: if remove_finished: os.remove(from_path) - return path_or_str(to_path) + return path_or_str(pathlib.Path(to_path)) def download_and_extract_archive( From 1e7f49c4b6b854137a0a618ec9ef0b5b8300e610 Mon Sep 17 00:00:00 2001 From: TilmannR Date: Thu, 11 Jan 2024 12:19:42 +0100 Subject: [PATCH 09/12] Fix typo in models docs (#8202) --- docs/source/models/ssdlite.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/models/ssdlite.rst b/docs/source/models/ssdlite.rst index bac1575c966..630576006a2 100644 --- a/docs/source/models/ssdlite.rst +++ b/docs/source/models/ssdlite.rst @@ -6,7 +6,7 @@ SSDlite The SSDLite model is based on the `SSD: Single Shot MultiBox Detector `__, `Searching for MobileNetV3 `__ and `MobileNetV2: Inverted Residuals and Linear -Bottlenecks __` papers. +Bottlenecks `__ papers. .. betastatus:: detection module From 122b3f1585f67049425d971fcfb407d59361b694 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Thu, 11 Jan 2024 15:47:04 -0800 Subject: [PATCH 10/12] Remove AWS credentials on workflows (#8205) --- .github/workflows/build-wheels-aarch64-linux.yml | 7 ++++--- .github/workflows/build-wheels-linux.yml | 7 ++++--- .github/workflows/build-wheels-m1.yml | 7 ++++--- .github/workflows/build-wheels-macos.yml | 7 ++++--- .github/workflows/build-wheels-windows.yml | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-wheels-aarch64-linux.yml b/.github/workflows/build-wheels-aarch64-linux.yml index 035800e9366..05c83991d5b 100644 --- a/.github/workflows/build-wheels-aarch64-linux.yml +++ b/.github/workflows/build-wheels-aarch64-linux.yml @@ -13,6 +13,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main @@ -48,6 +52,3 @@ jobs: trigger-event: ${{ github.event_name }} architecture: aarch64 setup-miniconda: false - secrets: - AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} - AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build-wheels-linux.yml b/.github/workflows/build-wheels-linux.yml index e997d648ec2..cd98fd2620a 100644 --- a/.github/workflows/build-wheels-linux.yml +++ b/.github/workflows/build-wheels-linux.yml @@ -13,6 +13,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main @@ -45,6 +49,3 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - secrets: - AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} - AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build-wheels-m1.yml b/.github/workflows/build-wheels-m1.yml index 66c7687acc9..adffb4ce9f2 100644 --- a/.github/workflows/build-wheels-m1.yml +++ b/.github/workflows/build-wheels-m1.yml @@ -13,6 +13,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main @@ -46,6 +50,3 @@ jobs: runner-type: macos-m1-12 smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - secrets: - AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} - AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build-wheels-macos.yml b/.github/workflows/build-wheels-macos.yml index 6c5ebc0fc37..4c3820ddf13 100644 --- a/.github/workflows/build-wheels-macos.yml +++ b/.github/workflows/build-wheels-macos.yml @@ -13,6 +13,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main @@ -46,6 +50,3 @@ jobs: runner-type: macos-12 smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - secrets: - AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} - AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/build-wheels-windows.yml b/.github/workflows/build-wheels-windows.yml index 3d818ece538..818d9f78b08 100644 --- a/.github/workflows/build-wheels-windows.yml +++ b/.github/workflows/build-wheels-windows.yml @@ -13,6 +13,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main @@ -47,6 +51,3 @@ jobs: package-name: ${{ matrix.package-name }} smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} - secrets: - AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} - AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} From 71dba932112989d2c4c042df8b502ab8aecde31b Mon Sep 17 00:00:00 2001 From: anthony-cabacungan <110057249+anthony-cabacungan@users.noreply.github.com> Date: Mon, 15 Jan 2024 02:50:03 -0800 Subject: [PATCH 11/12] Fixed typos (#8208) --- torchvision/datasets/caltech.py | 4 ++-- torchvision/datasets/celeba.py | 2 +- torchvision/datasets/cifar.py | 2 +- torchvision/datasets/clevr.py | 2 +- torchvision/datasets/coco.py | 4 ++-- torchvision/datasets/country211.py | 2 +- torchvision/datasets/dtd.py | 2 +- torchvision/datasets/eurosat.py | 2 +- torchvision/datasets/fakedata.py | 2 +- torchvision/datasets/fer2013.py | 2 +- torchvision/datasets/fgvc_aircraft.py | 2 +- torchvision/datasets/flowers102.py | 2 +- torchvision/datasets/folder.py | 2 +- torchvision/datasets/food101.py | 2 +- torchvision/datasets/gtsrb.py | 2 +- torchvision/datasets/imagenet.py | 2 +- torchvision/datasets/imagenette.py | 2 +- torchvision/datasets/inaturalist.py | 2 +- torchvision/datasets/kinetics.py | 2 +- torchvision/datasets/lfw.py | 4 ++-- torchvision/datasets/lsun.py | 2 +- torchvision/datasets/mnist.py | 10 +++++----- torchvision/datasets/moving_mnist.py | 2 +- torchvision/datasets/omniglot.py | 2 +- torchvision/datasets/oxford_iiit_pet.py | 2 +- torchvision/datasets/pcam.py | 2 +- torchvision/datasets/phototour.py | 2 +- torchvision/datasets/places365.py | 2 +- torchvision/datasets/rendered_sst2.py | 2 +- torchvision/datasets/semeion.py | 2 +- torchvision/datasets/stanford_cars.py | 2 +- torchvision/datasets/stl10.py | 2 +- torchvision/datasets/sun397.py | 2 +- torchvision/datasets/svhn.py | 2 +- torchvision/datasets/ucf101.py | 2 +- torchvision/datasets/usps.py | 2 +- torchvision/datasets/vision.py | 2 +- torchvision/datasets/voc.py | 4 ++-- torchvision/datasets/widerface.py | 2 +- 39 files changed, 47 insertions(+), 47 deletions(-) diff --git a/torchvision/datasets/caltech.py b/torchvision/datasets/caltech.py index 3a9635dfe09..17f274d0113 100644 --- a/torchvision/datasets/caltech.py +++ b/torchvision/datasets/caltech.py @@ -23,7 +23,7 @@ class Caltech101(VisionDataset): target types. ``category`` represents the target class, and ``annotation`` is a list of points from a hand-generated outline. Defaults to ``category``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -151,7 +151,7 @@ class Caltech256(VisionDataset): Args: root (string): Root directory of dataset where directory ``caltech256`` exists or will be saved to if download is set to True. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/celeba.py b/torchvision/datasets/celeba.py index d055f92f194..9136452f31a 100644 --- a/torchvision/datasets/celeba.py +++ b/torchvision/datasets/celeba.py @@ -31,7 +31,7 @@ class CelebA(VisionDataset): Defaults to ``attr``. If empty, ``None`` will be returned as target. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.PILToTensor`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/cifar.py b/torchvision/datasets/cifar.py index a2c4a7dc4c2..4df0306634e 100644 --- a/torchvision/datasets/cifar.py +++ b/torchvision/datasets/cifar.py @@ -17,7 +17,7 @@ class CIFAR10(VisionDataset): ``cifar-10-batches-py`` exists or will be saved to if download is set to True. train (bool, optional): If True, creates dataset from training set, otherwise creates from test set. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/clevr.py b/torchvision/datasets/clevr.py index 94e261e3355..f9ee63558fd 100644 --- a/torchvision/datasets/clevr.py +++ b/torchvision/datasets/clevr.py @@ -18,7 +18,7 @@ class CLEVRClassification(VisionDataset): root (string): Root directory of dataset where directory ``root/clevr`` exists or will be saved to if download is set to True. split (string, optional): The dataset split, supports ``"train"`` (default), ``"val"``, or ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in them target and transforms it. download (bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If diff --git a/torchvision/datasets/coco.py b/torchvision/datasets/coco.py index f53aba16e5f..7fda9667938 100644 --- a/torchvision/datasets/coco.py +++ b/torchvision/datasets/coco.py @@ -14,7 +14,7 @@ class CocoDetection(VisionDataset): Args: root (string): Root directory where images are downloaded to. annFile (string): Path to json annotation file. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.PILToTensor`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -65,7 +65,7 @@ class CocoCaptions(CocoDetection): Args: root (string): Root directory where images are downloaded to. annFile (string): Path to json annotation file. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.PILToTensor`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/country211.py b/torchvision/datasets/country211.py index 59598fd44e2..906fdfb2065 100644 --- a/torchvision/datasets/country211.py +++ b/torchvision/datasets/country211.py @@ -16,7 +16,7 @@ class Country211(ImageFolder): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), ``"valid"`` and ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and puts it into diff --git a/torchvision/datasets/dtd.py b/torchvision/datasets/dtd.py index 2b10efe94e2..b4e045e7c20 100644 --- a/torchvision/datasets/dtd.py +++ b/torchvision/datasets/dtd.py @@ -21,7 +21,7 @@ class DTD(VisionDataset): The partition only changes which split each image belongs to. Thus, regardless of the selected partition, combining all splits will result in all images. - transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and diff --git a/torchvision/datasets/eurosat.py b/torchvision/datasets/eurosat.py index bec6df5312d..2ae8c073202 100644 --- a/torchvision/datasets/eurosat.py +++ b/torchvision/datasets/eurosat.py @@ -10,7 +10,7 @@ class EuroSAT(ImageFolder): Args: root (string): Root directory of dataset where ``root/eurosat`` exists. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/fakedata.py b/torchvision/datasets/fakedata.py index 5b2d01db2e8..af26a8579e5 100644 --- a/torchvision/datasets/fakedata.py +++ b/torchvision/datasets/fakedata.py @@ -13,7 +13,7 @@ class FakeData(VisionDataset): size (int, optional): Size of the dataset. Default: 1000 images image_size(tuple, optional): Size if the returned images. Default: (3, 224, 224) num_classes(int, optional): Number of classes in the dataset. Default: 10 - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/fer2013.py b/torchvision/datasets/fer2013.py index bcd20c1e4a2..90bf5f304cd 100644 --- a/torchvision/datasets/fer2013.py +++ b/torchvision/datasets/fer2013.py @@ -17,7 +17,7 @@ class FER2013(VisionDataset): root (string): Root directory of dataset where directory ``root/fer2013`` exists. split (string, optional): The dataset split, supports ``"train"`` (default), or ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. """ diff --git a/torchvision/datasets/fgvc_aircraft.py b/torchvision/datasets/fgvc_aircraft.py index aa705b305d8..e4b071712c3 100644 --- a/torchvision/datasets/fgvc_aircraft.py +++ b/torchvision/datasets/fgvc_aircraft.py @@ -28,7 +28,7 @@ class FGVCAircraft(VisionDataset): ``trainval`` and ``test``. annotation_level (str, optional): The annotation level, supports ``variant``, ``family`` and ``manufacturer``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/flowers102.py b/torchvision/datasets/flowers102.py index fdaf2ddb4d1..41966f336d2 100644 --- a/torchvision/datasets/flowers102.py +++ b/torchvision/datasets/flowers102.py @@ -24,7 +24,7 @@ class Flowers102(VisionDataset): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), ``"val"``, or ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If true, downloads the dataset from the internet and diff --git a/torchvision/datasets/folder.py b/torchvision/datasets/folder.py index 40d5e26d242..49519233810 100644 --- a/torchvision/datasets/folder.py +++ b/torchvision/datasets/folder.py @@ -284,7 +284,7 @@ class ImageFolder(DatasetFolder): Args: root (string): Root directory path. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/food101.py b/torchvision/datasets/food101.py index d2557a82736..fa38abd7238 100644 --- a/torchvision/datasets/food101.py +++ b/torchvision/datasets/food101.py @@ -21,7 +21,7 @@ class Food101(VisionDataset): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default) and ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and diff --git a/torchvision/datasets/gtsrb.py b/torchvision/datasets/gtsrb.py index f99a688586d..ec746fbf686 100644 --- a/torchvision/datasets/gtsrb.py +++ b/torchvision/datasets/gtsrb.py @@ -15,7 +15,7 @@ class GTSRB(VisionDataset): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), or ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and diff --git a/torchvision/datasets/imagenet.py b/torchvision/datasets/imagenet.py index 9734d34ba88..290ae8f157f 100644 --- a/torchvision/datasets/imagenet.py +++ b/torchvision/datasets/imagenet.py @@ -30,7 +30,7 @@ class ImageNet(ImageFolder): Args: root (string): Root directory of the ImageNet Dataset. split (string, optional): The dataset split, supports ``train``, or ``val``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/imagenette.py b/torchvision/datasets/imagenette.py index a6353d066db..bf0835ce0ab 100644 --- a/torchvision/datasets/imagenette.py +++ b/torchvision/datasets/imagenette.py @@ -17,7 +17,7 @@ class Imagenette(VisionDataset): size (string, optional): The image size. Supports ``"full"`` (default), ``"320px"``, and ``"160px"``. download (bool, optional): If ``True``, downloads the dataset components and places them in ``root``. Already downloaded archives are not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version, e.g. ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/inaturalist.py b/torchvision/datasets/inaturalist.py index 50b32ef0f4a..84d6907b485 100644 --- a/torchvision/datasets/inaturalist.py +++ b/torchvision/datasets/inaturalist.py @@ -54,7 +54,7 @@ class INaturalist(VisionDataset): Can also be a list to output a tuple with all specified target types. Defaults to ``full``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/kinetics.py b/torchvision/datasets/kinetics.py index 16804c401f1..a5fda53aa90 100644 --- a/torchvision/datasets/kinetics.py +++ b/torchvision/datasets/kinetics.py @@ -56,7 +56,7 @@ class Kinetics(VisionDataset): split (str): split of the dataset to consider; supports ``"train"`` (default) ``"val"`` ``"test"`` frame_rate (float): If omitted, interpolate different frame rate for each clip. step_between_clips (int): number of frames between each clip - transform (callable, optional): A function/transform that takes in a TxHxWxC video + transform (callable, optional): A function/transform that takes in a TxHxWxC video and returns a transformed version. download (bool): Download the official version of the dataset to root folder. num_workers (int): Use multiple workers for VideoClips creation diff --git a/torchvision/datasets/lfw.py b/torchvision/datasets/lfw.py index 7a5aa45aa4d..f46c4e4c872 100644 --- a/torchvision/datasets/lfw.py +++ b/torchvision/datasets/lfw.py @@ -101,7 +101,7 @@ class LFWPeople(_LFW): ``10fold`` (default). image_set (str, optional): Type of image funneling to use, ``original``, ``funneled`` or ``deepfunneled``. Defaults to ``funneled``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomRotation`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -183,7 +183,7 @@ class LFWPairs(_LFW): ``10fold``. Defaults to ``10fold``. image_set (str, optional): Type of image funneling to use, ``original``, ``funneled`` or ``deepfunneled``. Defaults to ``funneled``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomRotation`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/lsun.py b/torchvision/datasets/lsun.py index a936351cdcc..6fab66ff11e 100644 --- a/torchvision/datasets/lsun.py +++ b/torchvision/datasets/lsun.py @@ -63,7 +63,7 @@ class LSUN(VisionDataset): root (string): Root directory for the database files. classes (string or list): One of {'train', 'val', 'test'} or a list of categories to load. e,g. ['bedroom_train', 'church_outdoor_train']. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/mnist.py b/torchvision/datasets/mnist.py index a8bc457020d..fce8583985c 100644 --- a/torchvision/datasets/mnist.py +++ b/torchvision/datasets/mnist.py @@ -27,7 +27,7 @@ class MNIST(VisionDataset): download (bool, optional): If True, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -210,7 +210,7 @@ class FashionMNIST(MNIST): download (bool, optional): If True, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -238,7 +238,7 @@ class KMNIST(MNIST): download (bool, optional): If True, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -269,7 +269,7 @@ class EMNIST(MNIST): download (bool, optional): If True, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -360,7 +360,7 @@ class QMNIST(MNIST): the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. transform (callable, optional): A function/transform that - takes in an PIL image and returns a transformed + takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/moving_mnist.py b/torchvision/datasets/moving_mnist.py index ac5a2b1503d..9dea36e4223 100644 --- a/torchvision/datasets/moving_mnist.py +++ b/torchvision/datasets/moving_mnist.py @@ -17,7 +17,7 @@ class MovingMNIST(VisionDataset): split_ratio (int, optional): The split ratio of number of frames. If ``split="train"``, the first split frames ``data[:, :split_ratio]`` is returned. If ``split="test"``, the last split frames ``data[:, split_ratio:]`` is returned. If ``split=None``, this parameter is ignored and the all frames data is returned. - transform (callable, optional): A function/transform that takes in an torch Tensor + transform (callable, optional): A function/transform that takes in a torch Tensor and returns a transformed version. E.g, ``transforms.RandomCrop`` download (bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not diff --git a/torchvision/datasets/omniglot.py b/torchvision/datasets/omniglot.py index 41d18c1bdd5..42717529a47 100644 --- a/torchvision/datasets/omniglot.py +++ b/torchvision/datasets/omniglot.py @@ -15,7 +15,7 @@ class Omniglot(VisionDataset): ``omniglot-py`` exists. background (bool, optional): If True, creates dataset from the "background" set, otherwise creates from the "evaluation" set. This terminology is defined by the authors. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/oxford_iiit_pet.py b/torchvision/datasets/oxford_iiit_pet.py index 667ee13717d..e4022251a8d 100644 --- a/torchvision/datasets/oxford_iiit_pet.py +++ b/torchvision/datasets/oxford_iiit_pet.py @@ -23,7 +23,7 @@ class OxfordIIITPet(VisionDataset): If empty, ``None`` will be returned as target. - transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and puts it into diff --git a/torchvision/datasets/pcam.py b/torchvision/datasets/pcam.py index c21f66186ce..4c63edec1d5 100644 --- a/torchvision/datasets/pcam.py +++ b/torchvision/datasets/pcam.py @@ -20,7 +20,7 @@ class PCAM(VisionDataset): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), ``"test"`` or ``"val"``. - transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and puts it into ``root/pcam``. If diff --git a/torchvision/datasets/phototour.py b/torchvision/datasets/phototour.py index cfcedf78cab..5c7dd6b66da 100644 --- a/torchvision/datasets/phototour.py +++ b/torchvision/datasets/phototour.py @@ -26,7 +26,7 @@ class PhotoTour(VisionDataset): Args: root (string): Root directory where images are. name (string): Name of the dataset to load. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. download (bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not diff --git a/torchvision/datasets/places365.py b/torchvision/datasets/places365.py index 5c97202a2e6..b98fc5e33b4 100644 --- a/torchvision/datasets/places365.py +++ b/torchvision/datasets/places365.py @@ -19,7 +19,7 @@ class Places365(VisionDataset): high resolution ones. download (bool, optional): If ``True``, downloads the dataset components and places them in ``root``. Already downloaded archives are not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/rendered_sst2.py b/torchvision/datasets/rendered_sst2.py index 58ea2f9cfe9..6fa09b677bb 100644 --- a/torchvision/datasets/rendered_sst2.py +++ b/torchvision/datasets/rendered_sst2.py @@ -22,7 +22,7 @@ class RenderedSST2(VisionDataset): Args: root (string): Root directory of the dataset. split (string, optional): The dataset split, supports ``"train"`` (default), `"val"` and ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If True, downloads the dataset from the internet and diff --git a/torchvision/datasets/semeion.py b/torchvision/datasets/semeion.py index c47703afbde..0703d267ad5 100644 --- a/torchvision/datasets/semeion.py +++ b/torchvision/datasets/semeion.py @@ -14,7 +14,7 @@ class SEMEION(VisionDataset): Args: root (string): Root directory of dataset where directory ``semeion.py`` exists. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/stanford_cars.py b/torchvision/datasets/stanford_cars.py index 3e9430ef214..2b169965e70 100644 --- a/torchvision/datasets/stanford_cars.py +++ b/torchvision/datasets/stanford_cars.py @@ -21,7 +21,7 @@ class StanfordCars(VisionDataset): Args: root (string): Root directory of dataset split (string, optional): The dataset split, supports ``"train"`` (default) or ``"test"``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/stl10.py b/torchvision/datasets/stl10.py index f47d0c32a2c..fbfd6650a97 100644 --- a/torchvision/datasets/stl10.py +++ b/torchvision/datasets/stl10.py @@ -19,7 +19,7 @@ class STL10(VisionDataset): folds (int, optional): One of {0-9} or None. For training, loads one of the 10 pre-defined folds of 1k samples for the standard evaluation procedure. If no value is passed, loads the 5k samples. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/sun397.py b/torchvision/datasets/sun397.py index 0a1ffef9b98..a32644b940c 100644 --- a/torchvision/datasets/sun397.py +++ b/torchvision/datasets/sun397.py @@ -15,7 +15,7 @@ class SUN397(VisionDataset): Args: root (string): Root directory of the dataset. - transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop``. target_transform (callable, optional): A function/transform that takes in the target and transforms it. download (bool, optional): If true, downloads the dataset from the internet and diff --git a/torchvision/datasets/svhn.py b/torchvision/datasets/svhn.py index 8a0d70b8fd0..ece384e2daa 100644 --- a/torchvision/datasets/svhn.py +++ b/torchvision/datasets/svhn.py @@ -22,7 +22,7 @@ class SVHN(VisionDataset): root (string): Root directory of the dataset where the data is stored. split (string): One of {'train', 'test', 'extra'}. Accordingly dataset is selected. 'extra' is Extra training set. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/ucf101.py b/torchvision/datasets/ucf101.py index 60e83e158a3..7dece183060 100644 --- a/torchvision/datasets/ucf101.py +++ b/torchvision/datasets/ucf101.py @@ -36,7 +36,7 @@ class UCF101(VisionDataset): fold (int, optional): which fold to use. Should be between 1 and 3. train (bool, optional): if ``True``, creates a dataset from the train split, otherwise from the ``test`` split. - transform (callable, optional): A function/transform that takes in a TxHxWxC video + transform (callable, optional): A function/transform that takes in a TxHxWxC video and returns a transformed version. output_format (str, optional): The format of the output video tensors (before transforms). Can be either "THWC" (default) or "TCHW". diff --git a/torchvision/datasets/usps.py b/torchvision/datasets/usps.py index d61d8c30368..25f54d57cc9 100644 --- a/torchvision/datasets/usps.py +++ b/torchvision/datasets/usps.py @@ -18,7 +18,7 @@ class USPS(VisionDataset): root (string): Root directory of dataset to store``USPS`` data files. train (bool, optional): If True, creates dataset from ``usps.bz2``, otherwise from ``usps.t.bz2``. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/vision.py b/torchvision/datasets/vision.py index 43e8c55529e..82debfc881f 100644 --- a/torchvision/datasets/vision.py +++ b/torchvision/datasets/vision.py @@ -15,7 +15,7 @@ class VisionDataset(data.Dataset): root (string, optional): Root directory of dataset. Only used for `__repr__`. transforms (callable, optional): A function/transforms that takes in an image and a label and returns the transformed versions of both. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/voc.py b/torchvision/datasets/voc.py index dc29bca5766..cf76b8e5926 100644 --- a/torchvision/datasets/voc.py +++ b/torchvision/datasets/voc.py @@ -128,7 +128,7 @@ class VOCSegmentation(_VOCBase): download (bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again. - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. @@ -173,7 +173,7 @@ class VOCDetection(_VOCBase): puts it in root directory. If dataset is already downloaded, it is not downloaded again. (default: alphabetic indexing of VOC's 20 classes). - transform (callable, optional): A function/transform that takes in an PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, required): A function/transform that takes in the target and transforms it. diff --git a/torchvision/datasets/widerface.py b/torchvision/datasets/widerface.py index aa520455ef1..96c5dee8c1f 100644 --- a/torchvision/datasets/widerface.py +++ b/torchvision/datasets/widerface.py @@ -26,7 +26,7 @@ class WIDERFace(VisionDataset): └── WIDER_test ('WIDER_test.zip' if compressed) split (string): The dataset split to use. One of {``train``, ``val``, ``test``}. Defaults to ``train``. - transform (callable, optional): A function/transform that takes in a PIL image + transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. From 919783f89d577e68fea5ad722e9e93b4a5a47e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Mon, 15 Jan 2024 15:10:38 +0100 Subject: [PATCH 12/12] Fix build with ffmpeg 6.0 (#8096) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Böszörményi Co-authored-by: Nicolas Hug --- torchvision/csrc/io/decoder/stream.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/torchvision/csrc/io/decoder/stream.cpp b/torchvision/csrc/io/decoder/stream.cpp index 0d625ef211c..8c914050587 100644 --- a/torchvision/csrc/io/decoder/stream.cpp +++ b/torchvision/csrc/io/decoder/stream.cpp @@ -63,15 +63,8 @@ int Stream::openCodec(std::vector* metadata, int num_threads) { codecCtx_->thread_count = num_threads; } else { // otherwise set sensible defaults - // with the special case for the different MPEG4 codecs - // that don't have threading context functions - if (codecCtx_->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY) { - codecCtx_->thread_type = FF_THREAD_FRAME; - codecCtx_->thread_count = 2; - } else { - codecCtx_->thread_count = 8; - codecCtx_->thread_type = FF_THREAD_SLICE; - } + codecCtx_->thread_count = 8; + codecCtx_->thread_type = FF_THREAD_SLICE; } int ret;