Add test dataset after creating learner, and batch speedup

I’m probably missing something simple here. I’d like to do batch prediction on a dataset, but don’t want to recreate the learn object or use load_learner every time I switch the test dataset. For example, I have small test datasets continually coming in that I want to do batch predictions on in real-time, so don’t want to waste time reloading the model before each run.

So is there a way I can just add the test dataset to the learner after the fact and then use get_preds on it?


Also, I was comparing the speeds of predict and pred_batch, and it seems like pred_batch isn’t any faster per input image. Is that expected behavior? And should I expect get_preds to be faster per image than a loop of pred_batch or predict?

Here’s the similar speed I’ve observed with predict and pred_batch:

47

Have you tried to set test_ds and test_dl to [] and then call add_test?

Did not notice that method and I think it’s probably what I’m looking for, thanks!