Hi,
I’m trying to create a Databunch for Regression of Bounding Boxes, trying to adapt the code in the Lesson 3 for Head Pose detection. I assume the problem is the same but having 4 labels (ymax, xmax, ymin, xmin) instead of 2. But I’m having an error on label_from_df() function and cannot figure out what’s happening.
My initial attempt is:
data = (PointsItemList.from_df(df, path=path)
.split_by_rand_pct()
.label_from_df()
.transform(get_transform(do_flip=False), tfm_y=True, size=224)
.databunch())
I’ve splitted the different steps to search for the error:
p1 = PointsItemList.from_df(df, path=path); p1
PointsItemList (119 items)
Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640)`
Path: sudoku-data/train
Being path the Path of the image’s folder, and df a dataframe with two columns, the image filename in the first one, and the bbox values in the second, separated by whitespaces.
p2 = p1.split_by_rand_pct(); p2
ItemLists;
Train: PointsItemList (96 items)
Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640)
Path: sudoku-data/train;
Valid: PointsItemList (23 items)
Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640),Image (3, 480, 640)
Path: sudoku-data/train;
Test: None
Till here seems to work fine. But in the third step:
p3 = p2.label_from_df(cols=[1])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-22-3a5ae1f01b6b> in <module>()
----> 1 p3 = p2.label_from_df()
4 frames
/usr/local/lib/python3.6/dist-packages/fastai/vision/data.py in __init__(self, ds)
391 class PointsProcessor(PreProcessor):
392 "`PreProcessor` that stores the number of targets for point regression."
--> 393 def __init__(self, ds:ItemList): self.c = len(ds.items[0].reshape(-1))
394 def process(self, ds:ItemList): ds.c = self.c
395
AttributeError: 'str' object has no attribute 'reshape'
Any idea why this is happening?
Thanks in advance,
Higi