Thanks for you reply!

This is part of my code. I load only one image, and just calculate the timing for forward pass.

def test_image(test_path):
    device = torch.device("cuda")
    #test_path: "./CarDataset/data/test/00001.jpg"
    input = cv2.imread(test_path)
    original = input

    input = cv2.cvtColor(input, cv2.COLOR_BGR2RGB)
    input = Image.fromarray(input)

    mean, std = [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
    normalize = transforms.Normalize(mean=mean, std=std)

    transform_test = transforms.Compose([
        transforms.Resize((224, 224)),
        transforms.ToTensor(),
        normalize
        ])

    input = transform_test(input)
    input = torch.unsqueeze(input, 0)
    input = input.to(device)

    model = models.resnet34()
    num_ftrs = model.fc.in_features
    model.fc = nn.Linear(num_ftrs, 196)
    model.load_state_dict(torch.load(model_path)["state_dict"])

    model.to(device)
    model.eval()

    start = time.time()
    output = model(input)
    end = time.time()
    print("processing time: ", (end-start)*1000, "ms")

    _, pred = torch.max(output, 1)
    
    text = str(pred.data.item())
    input = input.squeeze(0).permute(1,2,0).cpu().numpy()

    cv2.putText(original, text, (10,50), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
    cv2.imshow(test_path, original)

    cv2.waitKey(0)


Could you give me some suggestions about how to avoid overfitting? This is the optimizer I used during training.

    criterion = nn.CrossEntropyLoss().cuda()
    optimizer = torch.optim.SGD(model.parameters(), 0.01,
                                momentum=0.9,
                                nesterov=False,
                                weight_decay=1e-4)
    sched = torch.optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode='max', patience=10)

Thanks again!