Creating a unet learner for imagebbox dataset

I am trying to train a unet model to identify objects from images that have been annotated as bounding box, however, I am having difficulty in creating the learner and successfully find lr as well as training my model. I receive this error whenI try to rung lr_find as well as fit.one_cycle:
if not loss_func: return to_detach(out), to_detach(yb[0]) loss = loss_func(out, *yb)
TypeError: __call__() takes 3 positional arguments but 4 were given

Please bear with me as I am a rookie :slight_smile:

As a first step I have precessed images for only one label.
Here are the steps I take to create the learner.
I have saved the annotations for the images in a coco file. So my code to extract the annotations and create the label func is:
images, lbl_bbox = get_annotations(coco_dir) img2bbox = dict(zip(images, lbl_bbox)) get_y_func = lambda o:img2bbox[os.path.basename(o)]

I created the databunch as:
src = (ObjectItemList.from_folder(dir) .split_by_rand_pct(seed=42) .label_from_func(get_y_func) .transform(get_transforms(), tfm_y=True, size=128) .databunch(bs=16, collate_fn=bb_pad_collate) .normalize(imagenet_stats) )

I extract the labes as:
codes = np.loadtxt(sample_dir/'codes.txt', dtype=str)

And create the accuracy function as:
name2id = {v:k for k,v in enumerate(codes)} void_code = name2id['void']

`def acc_bbox(input, target):
    target = target.squeeze(1)
    mask = target != void_code
    return (input.argmax(dim=1)[mask]==target[mask]).float().mean()`

Finally I create learner as:
learn = unet_learner(src, models.resnet34, metrics= acc_bbox, wd=1e-2)

But when I run lr_find(learn), I receive the error mentioned in the beginning.
I am guessing that the problem lies in my accuracy func and possibly a need for loss func too, however, I do not know how to create them appropriately.
Can you please help me with this?

A unet learner is for segmentation, which needs a mask of every pixel with its corresponding class. You seem to be wanting to make object detection instead, as you have bounding boxes coordinates. There are plenty of topics in this forum discussing it such as Working notebook for Object Detection.