You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am following this in order to learn how to use a custom mapper.
So at the moment I just copy the example in the documentation
def custom_mapper(dataset_dict):
dataset_dict = copy.deepcopy(dataset_dict) # it will be modified by code below
# can use other ways to read image
image = utils.read_image(dataset_dict["file_name"], format="BGR")
# See "Data Augmentation" tutorial for details usage
auginput = T.AugInput(image)
transform = T.Resize((800, 800))(auginput)
image = torch.from_numpy(auginput.image.transpose(2, 0, 1))
annos = [
utils.transform_instance_annotations(annotation, [transform], image.shape[1:])
for annotation in dataset_dict.pop("annotations")
]
return {
# create the format that the model expects
"image": image,
"instances": utils.annotations_to_instances(annos, image.shape[1:])
}
And then, follwing this i overwrited the build_{train,test}_loader method
I can see information of my dataset whether i print the {train,test}_dataloader variable. So all seems right.
Then i get this error when start to train
w, h = d["width"], d["height"]
KeyError: 'width'
Of course this does not work because instance.py creates a Instance as:
def __str__(self) -> str:
s = self.__class__.__name__ + "("
s += "num_instances={}, ".format(len(self))
s += "image_height={}, ".format(self._image_size[0])
s += "image_width={}, ".format(self._image_size[1])
s += "fields=[{}])".format(", ".join((f"{k}: {v}" for k, v in self._fields.items())))
return s
So, need also create a custom Instance where image_width == width and image_height == height ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am following this in order to learn how to use a custom mapper.
So at the moment I just copy the example in the documentation
And then, follwing this i overwrited the build_{train,test}_loader method
I can see information of my dataset whether i print the {train,test}_dataloader variable. So all seems right.
Then i get this error when start to train
Of course this does not work because instance.py creates a Instance as:
So, need also create a custom Instance where image_width == width and image_height == height ?
Beta Was this translation helpful? Give feedback.
All reactions