I am trying to do the bbox regression (from fastai v2 lesson 8) on PASCAL VOC dataset using the fastai v1 library. I got the csv from lesson 8 fastai v2. It has 2 columns:filenames and bbox. bbox has 4 integers specify the top-left and bottom-right coordinates of bounding box.
I am facing errors in creating the databunch and learn object.
I tried creating the databunch like this:
data = (ObjectItemList.from_df(df=lab_csv, cols='fn', path=path_img)
.random_split_by_pct()
.label_from_func(get_label)
.transform(get_transforms(), tfm_y=True, size=(224,224))
.databunch(bs=32)
).normalize(imagenet_stats)
- lab-csv is the dataframe from csv
- fn is the name of column specifying file names
- path_img is the path of folder containing images
- get_label is a function which returns a torch tensor containing 4 integers of bbox coordinates
I am getting the error:
TypeError: iteration over a 0-d tensor
on line:
.label_from_func(get_label)
How can I fix this error?
Also, I was wondering do I need to explicitly specify the custom head in learn object, or the library will automatically create it because I am using ObjectItemList?
Thanks in advance