Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Update mixup transform to be compatible with latest pytorch (#753)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #753

Pull Request resolved: fairinternal/ClassyVision#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
  • Loading branch information
lauragustafson authored and facebook-github-bot committed Jul 9, 2021
1 parent 730680d commit 436aaca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions classy_vision/dataset/transforms/mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand Down

0 comments on commit 436aaca

Please sign in to comment.