carrying Inference on a trained image, jsut predicts the class of the image. For example in my case,

  
      github.com
  
  
    amrit-das/Custom-Model-Training-PyTorch/blob/master/predict.py 4
import torch
import torch.nn as nn
from torchvision.models import resnet18
from torchvision.transforms import transforms
import matplotlib.pyplot as plt
import numpy as np
from torch.autograd import Variable
import torch.functional as F
from PIL import Image
import os
import sys
import argparse

parser = argparse.ArgumentParser(description = 'To Predict from a trained model')
parser.add_argument('-i','--image', dest = 'image_name', required = True, help='Path to the image file')
parser.add_argument('-m','--model', dest = 'model_name', required = True, help='Path to the model')
parser.add_argument('-n','--num_class',dest = 'num_classes', required = True, help='Number of training classes')
args = parser.parse_args()

path_to_model = "./models/"+args.model_name


  This file has been truncated. show original

  
  
    
    
  
  


I read one image at a time. You can easily automate this by writing another script that reads images from a folder one by one, predicts them and then based on the predicted class stores them in a new directory.
I hope I got your question because I was a bit confused first.