0

I'm trying to test the different kind of augmentation,
but when I gave option with RandomCrop it gives loss value NaN or infinity.

Here is my random augmentation optims

def mapper2(dataset_dict):
    dataset_dict = copy.deepcopy(dataset_dict)  # it will be modified by code below
    image = utils.read_image(dataset_dict["file_name"], format="BGR")    
    transform_list = [
                     T.RandomFlip(prob=0.5, horizontal=True, vertical=False), 
                     T.ResizeShortestEdge(short_edge_length=(640, 672, 704, 736, 768, 800), max_size=1333, sample_style='choice')

                     ,T.RandomCrop('relative_range', (0.9, 0.9))
                      ]
    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"] = instances
    return dataset_dict
  1. Will this code apply augmentation randomly to any input batch images

  2. And why it explode the loss when I gave RandomCrop ?

    FloatingPointError: Predicted boxes or scores contain Inf/NaN. Training has diverged.

1 Answers1

0
  1. No. it will randomflip an image with the possibility of 50% for every image. It will resize and randomcrop every image 100%.
  2. It explodes likely because it resizes the image and than it crops this same image which I can image can lead to problems sometimes. It is better to just use 1 resize or crop argument
Rivered
  • 741
  • 7
  • 27