I have the following situation. I trained a unet_learner for a superresolution task, and then exported it with
I want to perform prediction on new images. At the moment, this is the way I proceed :
- I load the learner with
learn = load_learner(model_dir, '1b.pkl')
- My data is image of shape 128*128 with 3 channels. I loop through my list of numpy array of shape
3 * 128 * 128and call
My problem is that this is very slow, since predictions are virtually made with a batch size of 1. I would like to make my predictions on multiple images at once. Let’s say i have
n_img images I want to predict, I would like to be able to call a function
predict2 on an array of shape
n_img * 3 * 128 * 128 that would return a tensor or a numpy array of the same size by doing predictions on images in parallel.
My reading of this topic : Making predictions in v1 makes me want to put my images in a test_set and use the get_preds method to achieve that. My problem here is that my images are not stored on my disk. I get directly an array of shape
n_img * 3 * 128 * 128, theoretically, I could save this array as images on my disk, and use ImageImageList.from_folder to load those images but this seems pretty convoluted (and unnecessary and therefore slower).
So I guess my questions are the following :
- How can I make an ImageImageList from a array of shape
n_img * 3 * 128 * 128without saving this array to my disk ?
- Or if possible in a different manner, how can I get a prediction on an array of shape
n_img * 3 * 128 * 128that computes prediction in parallel and not 1 by 1.