By the way, when I used resnet for classification training, I found that the training output accuracy could reach 99%, but the inference was different every time.
I was careful and quickly discovered the problem: I trained with GPU, and of course I saved the GPU model. The inference does use the CPU directly, so the model loading error is certainly wrong.
solve:
torch.load("path to model", map_location="cpu")