Replies: 1 comment
-
I fixed the problem of def custom_mapper(dataset_dict):
# Deep copy dataset dictionary to avoid modifying the original
dataset_dict = dataset_dict.copy()
# Read image
image = utils.read_image(dataset_dict["file_name"], format="BGR")
transform_list = [
T.ResizeShortestEdge(
[640, 672, 704, 736, 768, 800],
max_size=1333,
sample_style='choice'
),
T.RandomBrightness(0.9, 1.1),
T.RandomContrast(0.9, 1.1),
T.RandomSaturation(0.9, 1.1),
T.RandomRotation(angle=[-10, 10], sample_style="range"),
T.RandomLighting(0.7),
T.RandomFlip(prob=0.5),
]
image, transforms = T.apply_transform_gens(transform_list, image)
# Convert image to tensor and normalize
image = torch.as_tensor(image.transpose(2, 0, 1).astype("float32")) / 255.0
# Transform instance annotations
annos = []
for obj in dataset_dict.pop("annotations"):
if not obj.get("iscrowd", 0):
transformed_obj = utils.transform_instance_annotations(obj, transforms, image.shape[1:])
annos.append(transformed_obj)
instances = utils.annotations_to_instances(annos, image.shape[1:])
dataset_dict["instances"] = utils.filter_empty_instances(instances)
# Assign processed image to dataset dictionary
dataset_dict["image"] = image
dataset_dict["annotations"] = annos
return dataset_dict |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was working a data augmentation. Before starting the training, I wanted to visualize the augmented data. The problem I am facing is the
bbox
doesnot appear and some image thesegmentation
are well apply event after some transformation but other image the segmentation is not well apply. From the result I got it seemsRandomBrightness
,RandomContrast
,RandomSaturation
andRandomLighting
are not apply. Here is what I did:Here is some result:
When I apply the following transformation, I get some warning:
Here is the error:
Any help is welcome !!
Beta Was this translation helpful? Give feedback.
All reactions