Object detection databunch


#1

I am trying to use the new fastai library for object detection and I am having problem while creating the databunch.
I have a csv file having image names and bounding box coordinates like this(image_name,bbox_coordinates)
tree.png 78 446 83 422
I tried to do something like this
src = (ImageItemList.from_csv(path, ‘bb.csv’, folder=‘images’, suffix=’’)
.random_split_by_pct(0.2)
.label_from_df(label_delim=’ '))
data =(src.transform(get_transforms(), tfm_y=True, size=(120,160))
.databunch(bs=16, collate_fn=bb_pad_collate)
.normalize(imagenet_stats))
But getting an error like this:

Exception Traceback (most recent call last)
/new_data/gpu/sanketg/anaconda3/envs/pytorch1/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
537 x = ds[0]
–> 538 try: x.apply_tfms(tfms, **kwargs)
539 except Exception as e:

/new_data/gpu/sanketg/anaconda3/envs/pytorch1/lib/python3.6/site-packages/fastai/core.py in apply_tfms(self, tfms, **kwargs)
156 “Subclass this method if you want to apply data augmentation with tfms to this ItemBase.”
–> 157 if tfms: raise Exception(f"Not implemented: you can’t apply transforms to this type of item ({self.class.name})")
158 return self

Exception: Not implemented: you can’t apply transforms to this type of item (MultiCategory)

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
in
1 print(src)
----> 2 data =(src.transform(get_transforms(), tfm_y=True, size=(120,160))
3 .databunch(bs=16, collate_fn=bb_pad_collate)
4 .normalize(imagenet_stats))

/new_data/gpu/sanketg/anaconda3/envs/pytorch1/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, **kwargs)
457 if not tfms: tfms=(None,None)
458 assert is_listy(tfms) and len(tfms) == 2, “Please pass a list of two lists of transforms (train and valid).”
–> 459 self.train.transform(tfms[0], **kwargs)
460 self.valid.transform(tfms[1], **kwargs)
461 if self.test: self.test.transform(tfms[1], **kwargs)

/new_data/gpu/sanketg/anaconda3/envs/pytorch1/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, tfm_y, **kwargs)
663 _check_kwargs(self.x, tfms, **kwargs)
664 if tfm_y is None: tfm_y = self.tfm_y
–> 665 if tfm_y: _check_kwargs(self.y, tfms, **kwargs)
666 self.tfms,self.tfmargs = tfms,kwargs
667 self.tfm_y,self.tfms_y,self.tfmargs_y = tfm_y,tfms,kwargs

/new_data/gpu/sanketg/anaconda3/envs/pytorch1/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
538 try: x.apply_tfms(tfms, **kwargs)
539 except Exception as e:
–> 540 raise Exception(f"It’s not possible to apply those transforms to your dataset:\n {e}")
541
542 class LabelList(Dataset):

Exception: It’s not possible to apply those transforms to your dataset:
Not implemented: you can’t apply transforms to this type of item (MultiCategory)

If someone can tell how to create the databunch for object detection