Custom Mapper tutorial does not work
See original GitHub issue📚 Documentation Issue or not clear
Hello, I am following this in order to replycate how to use a custom mapper.
So if 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
class MyTrainer(DefaultTrainer):
@classmethod
def build_train_loader(cls, cfg):
train_dataloader = build_detection_train_loader(cfg, mapper=custom_mapper)
return train_dataloader
@classmethod
def build_test_loader(cls, cfg):
test_dataloader = build_detection_train_loader(cfg, mapper=custom_mapper)
return test_dataloader
I get this error when start to train
w, h = d["width"], d["height"]
KeyError: 'width'
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Custom Mapper with MapStruct
In this article, we'll learn how to use custom mapper with the MapStruct library. The MapStruct library is used for mapping between Java...
Read more >MapStruct - Custom Mapping
MapStruct - Custom Mapping, We can add custom methods as well to the Mapper created ... Open project mapping as updated in Basic...
Read more >One-Stop Guide to Mapping with MapStruct
Sometimes we would like to implement a specific mapping manually by defining our logic while transforming from one object to another. For that, ......
Read more >Guide to MapStruct in Java - Advanced Mapping Library
In this article, we'll go through many examples of using MapStruct for Advanced Java Mapping, exception handling and MapStruct annotations.
Read more >Custom Mappers - Legion Programming System
A common problem encountered when writing code for large distributed and ... Custom mappers can either extend the DefaultMapper class or implement the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@narenakash
Yes, if you check the documentation, it says
# create the format that the model expects
In my case, it is faster 50, so the input model format acording to the documentation also needs:“height”, “width”:
@mjack3 I’m also facing the same issue. Could you share how you solved it?
Thanks in advance.