October 2, 2020, 1:22pm
After I have trained a model, I want to use the model to get predictions on a (large) number of unlabeled images. How would I go about doing this? I can do it with learn.get_preds() but this expects a dataloader. How do I create a test dataloader with no “y” and no loss?
October 2, 2020, 1:36pm
You should be able to do learn.predict(image).
October 2, 2020, 2:15pm
No, that gives me a prediction for a single image. I want to get predictions for a large amount of images at the same time (so a for loop is out of the question).
I know I can do a pytorch dataloader on my own, but I want to use fastai’s transforms.
October 3, 2020, 11:47am
There was another thread about speed of predictions. Trying to reproduce that here:
dl = learn.dls.test_dl(images)
inp, preds,_,dec_preds = learn.get_preds(dl=dl, with_input=True, with_decoded=True)
full_list = learn.dls.decode_batch((*tuplify(inp),*tuplify(dec_preds)), max_n=9)
And my code for inference:
preds= [ pred for pred in full_list]
‘images’ are the ‘Path’ to the test images
9 is the number of records. You could give more.