我正在尝试测试不同类型的增强,
但是当我给出选项时,RandomCrop
它给出了损失值 NaN 或无穷大。
这是我的随机增强优化
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
此代码是否会将增强随机应用于任何输入批处理图像
为什么当我给予时它会爆炸损失
RandomCrop
?FloatingPointError:预测框或分数包含 Inf/NaN。训练有分歧。