The whole code is as follows:
import cv2
import time
import torch
import numpy as np
from ptsemseg.models import get_model
from ptsemseg.utils import convert_state_dict

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = get_model({'arch': 'hardnet'}, 3).to(device)
the_model = torch.load("./weights/hardnet_2D_best_model.pkl")
state = convert_state_dict(the_model['model_state'])
model.load_state_dict(state)
model = model.eval()
input_shape = [1, 2, 4, 300, 800]
input_data = torch.randn(input_shape, device='cuda')
scripted_model = torch.jit.trace(model, input_data)
start_time = time.perf_counter()
///The input data was dealt as the same way.
output = scripted_model(torch.from_numpy(input_data).cuda())
elapsed_time = time.perf_counter() - start_time
scripted_model.save("model.pt")


I calculate the output, and the accruracy is only 82.05%.
And the 96.7% is obtained from the pytorch inference with another code.