Example #1
0
def assert_transforms(cfg):
    for transforms in [cfg.DATA.TRAIN.TRANSFORMS, cfg.DATA.TEST.TRANSFORMS]:
        for transform in transforms:
            if "transform_type" in transform:
                assert transform["transform_type"] in [None, "augly"]

                if transform["transform_type"] == "augly":
                    assert is_augly_available(), "Please pip install augly."
Example #2
0
    def _build_augly_transform(self, args):
        assert is_augly_available(), "Please pip install augly."

        # the name should be available in augly.image
        # if users specify the transform name in snake case,
        # we need to convert it to title case.
        name = args["name"]

        if not hasattr(imaugs, name):
            # Try converting name to title case.
            name = name.title().replace("_", "")

        assert hasattr(imaugs, name), f"{name} isn't a registered tranform for augly."

        # Delete superfluous keys.
        del args["name"]
        del args["transform_type"]

        return getattr(imaugs, name)(**args)
Example #3
0
# Copyright (c) Facebook, Inc. and its affiliates.

# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Any, Dict

from classy_vision.dataset.transforms import (
    build_transform as build_classy_transform,
    register_transform,
)
from classy_vision.dataset.transforms.classy_transform import ClassyTransform
from vissl.utils.misc import is_augly_available

if is_augly_available():
    import augly.image as imaugs  # NOQA

# Below the transforms that require passing the labels as well. This is specifc
# to SSL only where we automatically generate the labels for training. All other
# transforms (including torchvision) require passing image only as input.
_TRANSFORMS_WITH_LABELS = ["ImgRotatePil", "ShuffleImgPatches"]
_TRANSFORMS_WITH_COPIES = [
    "ImgReplicatePil",
    "ImgPilToPatchesAndImage",
    "ImgPilToMultiCrop",
]
_TRANSFORMS_WITH_GROUPING = ["ImgPilMultiCropRandomApply"]
_TRANSFORMS_WITH_OVERWRITE_ENTIRE_BATCH = ["OneHotEncode"]

DEFAULT_TRANSFORM_TYPES = {
    "TRANSFORMS_WITH_LABELS": _TRANSFORMS_WITH_LABELS,
Example #4
0
 def wrapped_test(*args, **kwargs):
     if is_augly_available():
         return test_function(*args, **kwargs)