From 436aaca6155cb67820fda04000320819e2ce7025 Mon Sep 17 00:00:00 2001 From: Laura Gustafson Date: Fri, 9 Jul 2021 10:16:42 -0700 Subject: [PATCH] Update mixup transform to be compatible with latest pytorch (#753) Summary: Pull Request resolved: https://github.com/facebookresearch/ClassyVision/pull/753 Pull Request resolved: https://github.com/fairinternal/ClassyVision/pull/97 `torch.clip` is an alias for `torch.clamp`, see https://pytorch.org/docs/stable/generated/torch.clip.html?highlight=clip#torch.clip and `torch.clip` is no longer in the latest pytorch version Updated `fairscale` dependency to resolve cpu/gpu test circleci failures: https://app.circleci.com/pipelines/github/facebookresearch/ClassyVision/2201/workflows/e3b37369-677c-4a08-8b4b-5c5c217c5560/jobs/4322 Reviewed By: mannatsingh Differential Revision: D29520476 fbshipit-source-id: 584f079762bc4c6de644cc7595232109b364b4db --- .circleci/config.yml | 18 +++++++++--------- classy_vision/dataset/transforms/mixup.py | 8 ++++---- setup.py | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a89dd9e463..6060087352 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -130,9 +130,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v7-cpu-dependencies-{{ checksum "requirements.txt" }} + - v9-cpu-dependencies-{{ checksum "requirements.txt" }} # fallback to using the latest cache if no exact match is found - - v7-cpu-dependencies- + - v9-cpu-dependencies- - <<: *install_dev_dep @@ -143,7 +143,7 @@ jobs: - save_cache: paths: - ~/venv - key: v7-cpu-dependencies-{{ checksum "requirements.txt" }} + key: v9-cpu-dependencies-{{ checksum "requirements.txt" }} - <<: *run_tests @@ -183,9 +183,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v4-gpu-dependencies-{{ checksum "requirements.txt" }} + - v6-gpu-dependencies-{{ checksum "requirements.txt" }} # fallback to using the latest cache if no exact match is found - - v4-gpu-dependencies- + - v6-gpu-dependencies- - <<: *install_dev_dep @@ -198,7 +198,7 @@ jobs: - save_cache: paths: - ~/venv - key: v4-gpu-dependencies-{{ checksum "requirements.txt" }} + key: v6-gpu-dependencies-{{ checksum "requirements.txt" }} - <<: *run_tests @@ -222,9 +222,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v2-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} + - v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} # fallback to using the latest cache if no exact match is found - - v2-gpu-bc-dependencies- + - v3-gpu-bc-dependencies- - <<: *install_dev_dep @@ -237,7 +237,7 @@ jobs: - save_cache: paths: - ~/venv - key: v2-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} + key: v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} - <<: *run_tests diff --git a/classy_vision/dataset/transforms/mixup.py b/classy_vision/dataset/transforms/mixup.py index 803e7df9ad..dbff0450b1 100644 --- a/classy_vision/dataset/transforms/mixup.py +++ b/classy_vision/dataset/transforms/mixup.py @@ -64,10 +64,10 @@ def rand_bbox(img_shape, lam, margin=0.0, count=1): margin_y, margin_x = int(margin * cut_h), int(margin * cut_w) cy = torch.randint(0 + margin_y, img_h - margin_y, (count,)) cx = torch.randint(0 + margin_x, img_w - margin_x, (count,)) - yl = torch.clip(cy - cut_h // 2, 0, img_h) - yh = torch.clip(cy + cut_h // 2, 0, img_h) - xl = torch.clip(cx - cut_w // 2, 0, img_w) - xh = torch.clip(cx + cut_w // 2, 0, img_w) + yl = torch.clamp(cy - cut_h // 2, 0, img_h) + yh = torch.clamp(cy + cut_h // 2, 0, img_h) + xl = torch.clamp(cx - cut_w // 2, 0, img_w) + xh = torch.clamp(cx + cut_w // 2, 0, img_w) return yl, yh, xl, xh diff --git a/setup.py b/setup.py index 16ae803817..3465e236d3 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ "nbconvert==6.0.7", "pre-commit", "parameterized", - "fairscale==0.1.6", + "fairscale==0.3.7", ] }, package_data={"classy_vision": ["configs/*.json", "templates"]},