Using a numpy array as input for Fastai

Hope someone can help, I’m very new to Fast-AI.
I have a Numpy array of shape 2000, 250,250,3

Basically 2000 images, each 250 by 250 with RGB bands.

I want to create a dataloader in Fast-AI V2 that reads the numpy array for an image classification. My suspicion is that I need to convert the numpy array to a torch tensor. Is that correct and then what? The labels are in a numpy array with shape 2000,

I have been trying to look at the documentation and even though it’s very thorough I just can’t seem to get what I need. All I could find was bits and pieces for the old version.

Thanks

If you just want to convert your array to tensor, you can do this:

Screen Shot 2021-08-03 at 12.17.31 AM

Based on my experience on DataBlocks and DataLoaders for images, you don’t need to do the (data value)-to-tensor conversion yourself.

Check out an example here if you’re using an external dataset:

The example in the fastbook for a toy dataset is quite straight-forward. But, if you need another example, check this one:

I hope these help.

Maria