I am working with RSNA kaggle dataset. I am trying to follow class 8 and 9 notebooks. At first I tried to build model with patientIds who has target =1 and with largest bounding boxes. This way, I ensured that each image has at least one bounding box and there are only 4 outputs for each input. Results were awful but still able to use learn.predict(is_test=True) on Kaggle’s dataset.
After making dataset “md” when I checked validation dataset and test dataset. I found that test dataset .
md.val_ds[0][1]

array([ 46., 39., 169., 105.], dtype=float32)
&
md.test_ds[0][1]
> array([0., 0., 0., 0.], dtype=float32)
So far so good!!! I could follow all steps and could obtain predictions on test dataset.
But when I made cvs file with all bounding boxes for given project id in “bbox” column. I found that test dataset was not able to handle it properly. Here is an example with two bounding boxes in one project id (some projectIds have one and some have three bounding boxes).
md.val_ds[0][1]
> array([ 46., 39., 169., 105., 55., 150., 180., 205.], dtype=float32)
However,
md.test_ds[0][1]
> Following output
>
IndexError Traceback (most recent call last)
<ipythoninput9447fe584d9349> in <module>()
> 1 md.test_ds[0][1]
~/fastai/courses/dl2/fastai/dataset.py in __getitem__(self, idx)
201 xs,ys = zip(*[self.get1item(i) for i in range(*idx.indices(self.n))])
202 return np.stack(xs),ys
> 203 return self.get1item(idx)
204
205 def __len__(self): return self.n
~/fastai/courses/dl2/fastai/dataset.py in get1item(self, idx)
195 def get1item(self, idx):
196 x,y = self.get_x(idx),self.get_y(idx)
> 197 return self.get(self.transform, x, y)
198
199 def __getitem__(self, idx):
~/fastai/courses/dl2/fastai/dataset.py in get(self, tfm, x, y)
206
207 def get(self, tfm, x, y):
> 208 return (x,y) if tfm is None else tfm(x,y)
209
210 @abstractmethod
~/fastai/courses/dl2/fastai/transforms.py in __call__(self, im, y)
646 self.tfms.append(ChannelOrder(tfm_y))
647
> 648 def __call__(self, im, y=None): return compose(im, y, self.tfms)
649 def __repr__(self): return str(self.tfms)
650
~/fastai/courses/dl2/fastai/transforms.py in compose(im, y, fns)
621 for fn in fns:
622 #pdb.set_trace()
> 623 im, y =fn(im, y)
624 return im if y is None else (im, y)
625
~/fastai/courses/dl2/fastai/transforms.py in __call__(self, x, y)
233 x,y = ((self.transform(x),y) if self.tfm_y==TfmType.NO
234 else self.transform(x,y) if self.tfm_y in (TfmType.PIXEL, TfmType.CLASS)
> 235 else self.transform_coord(x,y))
236 return x, y
237
~/fastai/courses/dl2/fastai/transforms.py in transform_coord(self, x, ys)
264 def transform_coord(self, x, ys):
265 yp = partition(ys, 4)
> 266 y2 = [self.map_y(y,x) for y in yp]
267 x = self.do_transform(x, False)
268 return x, np.concatenate(y2)
~/fastai/courses/dl2/fastai/transforms.py in <listcomp>(.0)
264 def transform_coord(self, x, ys):
265 yp = partition(ys, 4)
> 266 y2 = [self.map_y(y,x) for y in yp]
267 x = self.do_transform(x, False)
268 return x, np.concatenate(y2)
~/fastai/courses/dl2/fastai/transforms.py in map_y(self, y0, x)
258
259 def map_y(self, y0, x):
> 260 y = CoordTransform.make_square(y0, x)
261 y_tr = self.do_transform(y, True)
262 return to_bb(y_tr)
~/fastai/courses/dl2/fastai/transforms.py in make_square(y, x)
254 y1 = np.zeros((r, c))
255 y = y.astype(np.int)
> 256 y1[y[0]:y[2], y[1]:y[3]] = 1.
257 return y1
258
IndexError: index 2 is out of bounds for axis 0 with size 1
I am suspecting that test Dataset cannot be initialized properly when when training/validation dataset have variable (one, two , three or more) bounding boxes/outputs.
Because of this issue, I can’t use
learn.predict(is_test= True)
Anyone has similar issue?