How do you save fastai.torch_core.TensorImage to disk

I am unable to save a TensorImage to disk at the moment.

for file in get_image_files(TestingPath):
    im = PILImage.create(file)
    [preds,targ,asd] = learner.predict(im)
    OutName = file.stem+".png" 

But it doesn’t work.

AttributeError                            Traceback (most recent call last)
<ipython-input-95-cfb5c6ec0c2f> in <module>
     16     [preds,targ,asd] = learner.predict(im)
     17     OutName = file.stem+".png"
---> 18

AttributeError: 'TensorImage' object has no attribute 'save'

I take it there’s no save for the torch_core.TensorImage class.
So, how would I go about saving this?

You’d do, OutName) as it’s really a tensor object by that point

You’d bring it back in with torch.load(OutName)

Also do note: it’s a tensor, not a PILImage. So you should save it as .pt. (Hence the name TensorImage)

How would I have to modify this to save it as a png?

I have now just converted my tensor to a NumPy array and then saved it that way. I had to transpose because the channels worked differently (?). Thank you for your help!!