TypeError: reshape(): argument 'input' (position 1) must be Tensor, not numpy.ndarray
I am a high school student who doesn't having much experience in using PyTorch and LIME. I'm having a lot of trouble with my image shape. Initially my image shape was (3,224,224), however the LIME algorithm only works with images that are in this shape(...,...,3). As a result, I tried transposing the image earlier. It seemed that I made some more progress by doing that, however, now I am getting a different error. Here is some of my code to understand what I have been doing before the error came up.
def get_preprocess_transform():    
transf = transforms.Compose([
  #  transforms.ToPILImage(), #had to convert image to PIL as error was showing up two cells below about needing it in pil
    transforms.Resize(input_size),
    transforms.CenterCrop(input_size),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
    
])    

return transf    

preprocess_transform = get_preprocess_transform() ## use your data_transform but in a method version

def batch_predict(image):
    model_ft.eval()
    batch = torch.reshape(image,(1,3,224,224))
    print(type(batch))
    
    
    
    logits = model_ft(batch)
    probs = F.softmax(logits, dim=1)
    return probs.detach().cpu().numpy()


print(img_t.shape)
img_t = torch.reshape(img_t,(1,3,224,224))
test_pred = batch_predict(img_t)
test_pred.squeeze().argmax()

img_t = np.ones((3, 224, 224))
np.transpose(img_t, (2,1,0)).shape

img_x = np.transpose(img_t, (2, 1, 0))
print(img_x.shape)

from lime import lime_image

explainer = lime_image.LimeImageExplainer()
explanation = explainer.explain_instance(img_x, ## pass your image, do not transform
                                        batch_predict, # classification function
                                        top_labels=5, 
                                        hide_color=0, 
                                        num_samples=1000)

Here is the error message that comes from the &quot;explainer cell&quot;

use this command to convert numpy.ndarray to tensor
img = torch.from_numpy(img).float() #use appropriate name of variable 
