I try to use “torch.jit.trace” to script EDVR(https://github.com/xinntao/EDVR) model as follows:
import models.modules.EDVR_arch as EDVR_arch
device = torch.device('cuda')

model_path = '../experiments/pretrained_models/train_perceptual_loss_420600_G.pth'
N_in = 5
predeblur, HR_in = True, True
model = EDVR_arch.EDVR(64, N_in, 8, 5, 10, predeblur=predeblur, HR_in=HR_in, w_TSA=False) 
model.load_state_dict(torch.load(model_path), strict=True)
model.eval()
model = model.to(device)
example = torch.rand((1, 5, 3, 512, 512), device='cuda:0')
torch_script_model = torch.jit.trace(model, example)
torch_script_model.save('edvr.pt')

EDVR  use c++ extension to implement deformable convolutional networks