How do I predict a batch of images without labels

I am a beginner and using fastai ‘1.0.41’ but @jeremy suggestions approach does not work for the Unet Learner. I am bit confuse about it and these are problems:

  • The LabelLists.loadempty reads the state x_cls which is not available the exported file from Unet Learner

~/anaconda3/envs/fastaiV1/lib/python3.7/site-packages/fastai/data_block.py in load_state(cls, state)
600 def load_state(cls, state:dict) → ‘LabelList’:
601 “Create a LabelList from state.”
→ 602 x = state[‘x_cls’](, path=state[‘path’], processor=state[‘x_proc’], ignore_empty=True)

If I read it normally by

state = pickle.load(open(PATH/‘export.pkl’, ‘rb’))

Then the state’s keys are

dict_keys([‘opt_func’, ‘loss_func’, ‘metrics’, ‘true_wd’, ‘bn_wd’, ‘wd’, ‘train_bn’, ‘model_dir’, ‘callback_fns’, ‘cb_state’, ‘model’, ‘data’, ‘cls’])

  • That problem could be from the Unet model description as there are no classes.
  • Then, I read the docs and start to use a Data_block API which is really impressive. But the second problem is from the label_empty() function.
  • I want to create a general way to get ‘test’ images, without label, in the tensor shape with batch, normalized by imagenet_stats. This is the code

data = (ImageItemList.from_folder(path_img)
.no_split()
.label_empty()
.add_test_folder(‘test’)
.transform(get_transforms(), size=64)
.databunch()
.normalize(imagenet_stats))

  • But

~/anaconda3/envs/fastaiV1/lib/python3.7/site-packages/fastai/data_block.py in _inner(*args, **kwargs)
420 assert isinstance(self.train, LabelList)
421 kwargs[‘label_cls’] = self.train.y.class
→ 422 self.valid = fv(*args, **kwargs)
423 self.class = LabelLists
424 self.process()

TypeError: label_empty() got an unexpected keyword argument ‘label_cls’

  • This may be come from no validation set but I have no idea to fix it.

It is a long reply but hope we can find a way to fix this for Unet learner.