Skip to content

Commit

Permalink
Merge branch 'main' into kill-circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier authored May 24, 2023
2 parents 7d2bed7 + 285500d commit 0dff39f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 55 deletions.
5 changes: 2 additions & 3 deletions .github/scripts/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then
# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG and PNG libraries
# installed by default that interfere with our build. We uninstall them here and use the one from conda below.
IMAGE_LIBS=$(brew list | grep -E "jpeg|png")
echo "${IMAGE_LIBS}"
for lib in "${IMAGE_LIBS}"; do
brew uninstall --ignore-dependencies --force "${lib}" || true
for lib in $IMAGE_LIBS; do
brew uninstall --ignore-dependencies --force "${lib}"
done
echo '::endgroup::'
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prototype-tests-linux-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- python-version: "3.8"
runner: linux.g5.4xlarge.nvidia.gpu
gpu-arch-type: cuda
gpu-arch-version: "11.7"
gpu-arch-version: "11.8"
fail-fast: false
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- python-version: 3.8
runner: linux.g5.4xlarge.nvidia.gpu
gpu-arch-type: cuda
gpu-arch-version: "11.7"
gpu-arch-version: "11.8"
fail-fast: false
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- python-version: "3.8"
runner: windows.g5.4xlarge.nvidia.gpu
gpu-arch-type: cuda
gpu-arch-version: "11.7"
gpu-arch-version: "11.8"
fail-fast: false
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
with:
Expand Down
109 changes: 64 additions & 45 deletions gallery/plot_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):


####################################
# Geometric Transforms
# --------------------
# Geometric image transformation refers to the process of altering the geometric properties of an image,
# such as its shape, size, orientation, or position.
# It involves applying mathematical operations to the image pixels or coordinates to achieve the desired transformation.
#
# Pad
# ---
# ~~~
# The :class:`~torchvision.transforms.Pad` transform
# (see also :func:`~torchvision.transforms.functional.pad`)
# fills image borders with some pixel values.
# pads all image borders with some pixel values.
padded_imgs = [T.Pad(padding=padding)(orig_img) for padding in (3, 10, 30, 50)]
plot(padded_imgs)

####################################
# Resize
# ------
# ~~~~~~
# The :class:`~torchvision.transforms.Resize` transform
# (see also :func:`~torchvision.transforms.functional.resize`)
# resizes an image.
Expand All @@ -70,7 +76,7 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):

####################################
# CenterCrop
# ----------
# ~~~~~~~~~~
# The :class:`~torchvision.transforms.CenterCrop` transform
# (see also :func:`~torchvision.transforms.functional.center_crop`)
# crops the given image at the center.
Expand All @@ -79,46 +85,13 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):

####################################
# FiveCrop
# --------
# ~~~~~~~~
# The :class:`~torchvision.transforms.FiveCrop` transform
# (see also :func:`~torchvision.transforms.functional.five_crop`)
# crops the given image into four corners and the central crop.
(top_left, top_right, bottom_left, bottom_right, center) = T.FiveCrop(size=(100, 100))(orig_img)
plot([top_left, top_right, bottom_left, bottom_right, center])

####################################
# Grayscale
# ---------
# The :class:`~torchvision.transforms.Grayscale` transform
# (see also :func:`~torchvision.transforms.functional.to_grayscale`)
# converts an image to grayscale
gray_img = T.Grayscale()(orig_img)
plot([gray_img], cmap='gray')

####################################
# Random transforms
# -----------------
# The following transforms are random, which means that the same transfomer
# instance will produce different result each time it transforms a given image.
#
# ColorJitter
# ~~~~~~~~~~~
# The :class:`~torchvision.transforms.ColorJitter` transform
# randomly changes the brightness, saturation, and other properties of an image.
jitter = T.ColorJitter(brightness=.5, hue=.3)
jitted_imgs = [jitter(orig_img) for _ in range(4)]
plot(jitted_imgs)

####################################
# GaussianBlur
# ~~~~~~~~~~~~
# The :class:`~torchvision.transforms.GaussianBlur` transform
# (see also :func:`~torchvision.transforms.functional.gaussian_blur`)
# performs gaussian blur transform on an image.
blurrer = T.GaussianBlur(kernel_size=(5, 9), sigma=(0.1, 5))
blurred_imgs = [blurrer(orig_img) for _ in range(4)]
plot(blurred_imgs)

####################################
# RandomPerspective
# ~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -181,6 +154,45 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):
resized_crops = [resize_cropper(orig_img) for _ in range(4)]
plot(resized_crops)

####################################
# Photometric Transforms
# ----------------------
# Photometric image transformation refers to the process of modifying the photometric properties of an image,
# such as its brightness, contrast, color, or tone.
# These transformations are applied to change the visual appearance of an image
# while preserving its geometric structure.
#
# Except :class:`~torchvision.transforms.Grayscale`, the following transforms are random,
# which means that the same transform
# instance will produce different result each time it transforms a given image.
#
# Grayscale
# ~~~~~~~~~
# The :class:`~torchvision.transforms.Grayscale` transform
# (see also :func:`~torchvision.transforms.functional.to_grayscale`)
# converts an image to grayscale
gray_img = T.Grayscale()(orig_img)
plot([gray_img], cmap='gray')

####################################
# ColorJitter
# ~~~~~~~~~~~
# The :class:`~torchvision.transforms.ColorJitter` transform
# randomly changes the brightness, contrast, saturation, hue, and other properties of an image.
jitter = T.ColorJitter(brightness=.5, hue=.3)
jitted_imgs = [jitter(orig_img) for _ in range(4)]
plot(jitted_imgs)

####################################
# GaussianBlur
# ~~~~~~~~~~~~
# The :class:`~torchvision.transforms.GaussianBlur` transform
# (see also :func:`~torchvision.transforms.functional.gaussian_blur`)
# performs gaussian blur transform on an image.
blurrer = T.GaussianBlur(kernel_size=(5, 9), sigma=(0.1, 5))
blurred_imgs = [blurrer(orig_img) for _ in range(4)]
plot(blurred_imgs)

####################################
# RandomInvert
# ~~~~~~~~~~~~
Expand Down Expand Up @@ -244,6 +256,11 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):
plot(equalized_imgs)

####################################
# Augmentation Transforms
# -----------------------
# The following transforms are combinations of multiple transforms,
# either geometric or photometric, or both.
#
# AutoAugment
# ~~~~~~~~~~~
# The :class:`~torchvision.transforms.AutoAugment` transform
Expand All @@ -261,34 +278,36 @@ def plot(imgs, with_orig=True, row_title=None, **imshow_kwargs):
####################################
# RandAugment
# ~~~~~~~~~~~
# The :class:`~torchvision.transforms.RandAugment` transform automatically augments the data.
# The :class:`~torchvision.transforms.RandAugment` is an alternate version of AutoAugment.
augmenter = T.RandAugment()
imgs = [augmenter(orig_img) for _ in range(4)]
plot(imgs)

####################################
# TrivialAugmentWide
# ~~~~~~~~~~~~~~~~~~
# The :class:`~torchvision.transforms.TrivialAugmentWide` transform automatically augments the data.
# The :class:`~torchvision.transforms.TrivialAugmentWide` is an alternate implementation of AutoAugment.
# However, instead of transforming an image multiple times, it transforms an image only once
# using a random transform from a given list with a random strength number.
augmenter = T.TrivialAugmentWide()
imgs = [augmenter(orig_img) for _ in range(4)]
plot(imgs)

####################################
# AugMix
# ~~~~~~
# The :class:`~torchvision.transforms.AugMix` transform automatically augments the data.
# The :class:`~torchvision.transforms.AugMix` transform interpolates between augmented versions of an image.
augmenter = T.AugMix()
imgs = [augmenter(orig_img) for _ in range(4)]
plot(imgs)

####################################
# Randomly-applied transforms
# Randomly-applied Transforms
# ---------------------------
#
# Some transforms are randomly-applied given a probability ``p``. That is, the
# transformed image may actually be the same as the original one, even when
# called with the same transformer instance!
# The following transforms are randomly-applied given a probability ``p``. That is, given ``p = 0.5``,
# there is a 50% chance to return the original image, and a 50% chance to return the transformed image,
# even when called with the same transform instance!
#
# RandomHorizontalFlip
# ~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 5 additions & 4 deletions test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,11 @@ def test_classification_model(model_fn, dev):
model_name = model_fn.__name__
if SKIP_BIG_MODEL and is_skippable(model_name, dev):
pytest.skip("Skipped to reduce memory usage. Set env var SKIP_BIG_MODEL=0 to enable test for this model")
if model_name == "vit_h_14" and dev == "cuda":
# TODO: investigate why this fail on CI. It doesn't fail on AWS cluster with CUDA 11.6
# (can't test with later versions ATM)
pytest.xfail("https://github.com/pytorch/vision/issues/7143")
if model_name == "resnet101" and dev == "cuda":
# TODO: Investigate the Failure with CUDA 11.8: https://github.com/pytorch/vision/issues/7618
# TODO: Investigate/followup on previous failure: https://github.com/pytorch/vision/issues/7143
# its not happening on CI with CUDA 11.8 anymore. Follow up is needed if its still not resolved.
pytest.xfail("https://github.com/pytorch/vision/issues/7618")
kwargs = {**defaults, **_model_params.get(model_name, {})}
num_classes = kwargs.get("num_classes")
input_shape = kwargs.pop("input_shape")
Expand Down

0 comments on commit 0dff39f

Please sign in to comment.