Repository: deepchecks/deepchecks

Issue:
Upgrade gpu torch vision
#### Reference Issues/PRs

Example: Fixes #1234. See also #3456.
Please use keywords (e.g., Fixes) to create link to the issues or pull requests
you resolved, so that they will automatically be closed when your pull request
is merged. See https://github.com/blog/1506-closing-issues-via-pull-requests


#### What does this implement/fix? Explain your changes.


#### Any other comments?



---
Thanks for contributing a pull request! Please ensure you have taken a look at
the contribution guidelines: https://github.com/deepchecks/deepchecks/blob/main/CONTRIBUTING.rst



Discussion:

Resolving patch:
diff --git a/deepchecks/vision/utils/transformations.py b/deepchecks/vision/utils/transformations.py
--- a/deepchecks/vision/utils/transformations.py
+++ b/deepchecks/vision/utils/transformations.py
@@ -10,15 +10,14 @@
 #
 """Module for defining functions related to vision transforms."""
 from copy import copy
-from typing import Sized
+from typing import Sized, Optional
 
 import albumentations
-import imgaug
+import imgaug.augmenters as iaa
 import torch
 
 from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError
 
-
 __all__ = ['get_transforms_handler', 'add_augmentation_in_start', 'un_normalize_batch',
            'ImgaugTransformations', 'AlbumentationsTransformations']
 
@@ -29,24 +28,57 @@ class ImgaugTransformations:
     @classmethod
     def add_augmentation_in_start(cls, aug, transforms):
         """Add given transformations to the start of given transforms object."""
-        if not isinstance(aug, imgaug.augmenters.Augmenter):
+        if not isinstance(aug, iaa.Augmenter):
             raise DeepchecksValueError(f'Transforms is of type imgaug, can\'t add to it type {type(aug).__name__}')
-        return imgaug.augmenters.Sequential([aug, transforms])
+        return iaa.Sequential([aug, transforms])
 
     @classmethod
     def get_test_transformation(cls):
         """Get transformation which is affecting both image data and bbox."""
-        return imgaug.augmenters.Rotate(rotate=(20, 30))
+        return iaa.Rotate(rotate=(20, 30))
 
     @classmethod
-    def get_robustness_augmentations(cls, data_dim):
+    def get_robustness_augmentations(cls, data_dim: Optional[int] = 3):
         """Get default augmentations to use in robustness report check."""
         augmentations = [
-            imgaug.augmenters.MultiplyHueAndSaturation()
+            # Tries to be similar to output of
+            # albumentations.RandomBrightnessContrast
+            # Exact output is difficult
+            iaa.Sequential([
+                iaa.contrast.LinearContrast([0.8, 1.2]),
+                iaa.color.MultiplyBrightness([0.8, 1.2])
+
+            ], name='RandomBrightnessContrast'),
+            # mimics albumentations.ShiftScaleRotate
+            iaa.geometric.Affine(scale=[0.9, 1.1],
+                                 translate_percent=[-0.0625, 0.0625],
+                                 rotate=[-45, 45],
+                                 order=1,
+                                 cval=0,
+                                 mode='reflect',
+                                 name='ShiftScaleRotate')
         ]
         if data_dim == 3:
-            # TODO add RGB augmentations
-            pass
+            augmentations.extend([
+                # mimics h(p=1.0),
+                iaa.WithColorspace(
+                    to_colorspace='HSV',
+                    from_colorspace='RGB',
+                    children=[
+                        # Hue
+                        iaa.WithChannels(0, iaa.Add((-20, 20))),
+                        # Saturation
+                        iaa.WithChannels(1, iaa.Add((-30, 30))),
+                        # Value
+                        iaa.WithChannels(0, iaa.Add((-20, 20))),
+                    ],
+                    name='HueSaturationValue'
+                ),
+                # mimics albumentations.RGBShift
+                iaa.Add(value=[-15, 15],
+                        per_channel=True,
+                        name='RGBShift')
+            ])
         return augmentations
 
 
@@ -71,7 +103,7 @@ def get_test_transformation(cls):
         return albumentations.Rotate(limit=(20, 30), p=1)
 
     @classmethod
-    def get_robustness_augmentations(cls, data_dim):
+    def get_robustness_augmentations(cls, data_dim: Optional[int] = 3):
         """Get default augmentations to use in robustness report check."""
         augmentations = [
             albumentations.RandomBrightnessContrast(p=1.0),
@@ -91,7 +123,7 @@ def get_transforms_handler(transforms):
         raise DeepchecksNotSupportedError('Underlying Dataset instance must have transform field not None')
     elif isinstance(transforms, albumentations.Compose):
         return AlbumentationsTransformations
-    elif isinstance(transforms, imgaug.augmenters.Augmenter):
+    elif isinstance(transforms, iaa.Augmenter):
         return ImgaugTransformations
     else:
         raise DeepchecksNotSupportedError('Currently only imgaug and albumentations are supported')


Test patch: