I'm trying to instantiate a composition of transformers.
In native Python this looks like this:
import albumentations as A
transforms = A.Compose([
A.Rotate(limit=10),
A.ToGray(p=1),
])
print(transforms)
output:
Compose([
Rotate(always_apply=False, p=0.5, limit=(-10, 10), interpolation=1, border_mode=4, value=None, mask_value=None),
ToGray(always_apply=False, p=1),
], p=1.0, bbox_params=None, keypoint_params=None, additional_targets={})
I'm trying to instantiate the same transformation with Hydra, but for some reason, the recursive instantiation is failed and only the list of transforms is instantiated but not the outer (A.Compose) function.
from omegaconf import OmegaConf
import hydra
conf = OmegaConf.create({"compose": {"_traget_": "albumentations.Compose", "_recursive_": True, "transforms": [{"_target_": "albumentations.Rotate", "limit": 10}, {"_target_": "albumentations.ToGray", "p": 1}]}})
print(OmegaConf.to_yaml(conf))
output:
compose:
_traget_: albumentations.Compose
_recursive_: true
transforms:
- _target_: albumentations.Rotate
limit: 10
- _target_: albumentations.ToGray
p: 1
But instantiation is failed:
print(hydra.utils.instantiate(conf.compose))
output:
{'_traget_': 'albumentations.Compose', 'transforms': [Rotate(always_apply=False, p=0.5, limit=(-10, 10), interpolation=1, border_mode=4, value=None, mask_value=None), ToGray(always_apply=False, p=1)]}