I have the below code where I'm using default augmentation during training of Detectron 2
but the problem is that there are very few augmentations that are useful to me.
Want to whether it is the right way to do it and also, how could I Look at the augmented image result if I want to see what's happening?
import detectron2.data.transforms as T
from detectron2.data import detection_utils as utils
def custom_mapper(dataset_dict):
dataset_dict = copy.deepcopy(dataset_dict)
image = utils.read_image(dataset_dict["file_name"], format="BGR")
transform_list = [T.RandomBrightness(0.8, 1.2),
T.RandomContrast(0.8, 1.2),
T.RandomSaturation(0.8, 1.2),
]
image, transforms = T.apply_transform_gens(transform_list, image)
dataset_dict["image"] = torch.as_tensor(image.transpose(2, 0, 1).astype("float32"))
annos = [
utils.transform_instance_annotations(obj, transforms, image.shape[:2])
for obj in dataset_dict.pop("annotations")
if obj.get("iscrowd", 0) == 0
]
instances = utils.annotations_to_instances(annos, image.shape[:2])
dataset_dict["instances"] = utils.filter_empty_instances(instances)
return dataset_dict
But the problem is that
- I want to build my custom augmentation or use albumentations for the purpose.
- I don't want to use all of the augmentations every time and there's no probability in the above transformations that I have used. So a way around would be to use something like
OneOf
on individual or a group.
from How to use Custom (or albumentation) augmentations on Detectron 2?
No comments:
Post a Comment