I’m trying to use data_block with bboxes similar to Coco. I used the code in the docs and fed the data into a learner. When I run it, I get
22
23 if not loss_func: return to_detach(out), yb[0].detach()
---> 24 loss = loss_func(out, *yb)
25
26 if opt is not None:
TypeError: __call__() takes 3 positional arguments but 4 were given
coco = untar_data(URLs.COCO_TINY)
images, lbl_bbox = get_annotations(coco/'train.json')
img2bbox = dict(zip(images, lbl_bbox))
get_y_func = lambda o:img2bbox[o.name]
data = (ObjectItemList.from_folder(coco)
#Where are the images? -> in coco
.random_split_by_pct()
#How to split in train/valid? -> randomly with the default 20% in valid
.label_from_func(get_y_func)
#How to find the labels? -> use get_y_func
.transform(get_transforms(), tfm_y=True)
#Data augmentation? -> Standard transforms with tfm_y=True
.databunch(bs=16, collate_fn=bb_pad_collate))
#Finally we convert to a DataBunch and we use bb_pad_collate
learn = create_cnn(data, models.resnet34)
learn.lr_find()
Not sure what I’m doing wrong. Any help would be appreciated.
Were you able to create a loss function that takes into account multi object detection?
I am using @radek’s awesome fluke detection notebook but I have trouble making it work with multiple objects.
This is the loss function he uses for single objects:
Hi, I have the same problems with COCO dataset. I tried the suggested loss function but it doesn’t work because it’s been used in a context with just one label. What I got is a mismatch between tensors. @astein did you manage to implement a working custom loss function?