Hi !
I’m trying to use the add_test
method from fastai library to make my final predictions on a testset for a kaggle competition, but I can’t make it work. I keep on getting the same error:
/work/stages/schwob/.conda/envs/pytorch/lib/python3.6/site-packages/fastai/data_block.py in add_test(self, items, label)
550 if isinstance(items, ItemList): items = self.valid.x.new(items.items, inner_df=items.inner_df).process()
551 else: items = self.valid.x.new(items).process()
--> 552 self.test = self.valid.new(items, labels)
553 return self
554
/work/stages/schwob/.conda/envs/pytorch/lib/python3.6/site-packages/fastai/data_block.py in new(self, x, y, **kwargs)
616 def new(self, x, y, **kwargs)->'LabelList':
617 if isinstance(x, ItemList):
--> 618 return self.__class__(x, y, tfms=self.tfms, tfm_y=self.tfm_y, **self.tfmargs)
619 else:
620 return self.new(self.x.new(x, **kwargs), self.y.new(y, **kwargs)).process()
/work/stages/schwob/.conda/envs/pytorch/lib/python3.6/site-packages/fastai/data_block.py in __init__(self, x, y, tfms, tfm_y, **kwargs)
589 self.y.x = x
590 self.item=None
--> 591 self.transform(tfms, **kwargs)
592
593 def __len__(self)->int: return len(self.x) if self.item is None else 1
/work/stages/schwob/.conda/envs/pytorch/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, tfm_y, **kwargs)
709 _check_kwargs(self.x, tfms, **kwargs)
710 if tfm_y is None: tfm_y = self.tfm_y
--> 711 if tfm_y: _check_kwargs(self.y, tfms, **kwargs)
712 self.tfms, self.tfmargs = tfms,kwargs
713 self.tfm_y, self.tfmargs_y = tfm_y,kwargs
/work/stages/schwob/.conda/envs/pytorch/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
581 try: x.apply_tfms(tfms, **kwargs)
582 except Exception as e:
--> 583 raise Exception(f"It's not possible to apply those transforms to your dataset:\n {e}")
584
585 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 (EmptyLabel)
There are several things I don’t understand:
- Why does it adds the test set using the
valid
attribute ? - Why does it try to apply my train transforms to the test set ? I obviously don’t want the same transforms to be applied for my test set (the one I submit) and my training set.
- Even stranger, why does it try to apply it to the label list while obviously it is
None
(it is even specified in the docs that it has to beNone
) ?
My wild guess is that, as I already added a validation set, which contains transforms to be applied to labels as well (cropping for instance), it tries to apply it to the test set as it uses valid
attribute. So I guess it all comes down to my first question. Is there a way to avoid using valid
and its transforms ?
Thanks in advance !