Hi, Can i know that if I don not use the Dataset and Dataloader, I just load the image like a list and do the transforms etc. Will the test result be affected?
The definition of a TestLoader is a must?
Cause in my code, the training and validation accuracy could reade 95% but when i inference only one image, the accuracy is like only 10%.
Any idea?
Here is a snap of my testing code
for img_name in img_list:
        img_path = os.path.join(test_dir, img_name)
        img_arr = cv2.imread(img_path,1)
        img_tensor = torch.from_numpy(img_arr)
        compose_img = transforms.Compose([transforms.ToPILImage(),
                                         transforms.Resize((112,112),interpolation=Image.NEAREST),
                                         transforms.ToTensor(),
                                         transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
        img_tensor = compose_img(img_tensor)
        print('Predicting image: ' + img_name)
        with torch.no_grad():
            img_tensor = img_tensor.unsqueeze(0)

            output = model(img_tensor)
            m = nn.Softmax(dim = 1)
            output_a = m(output)
            preds = torch.argmax(output_a.data, 1)
            print(preds)