Use this script :
requirements : pytorch 1.5 and torchvision 0.6.0 use this command conda install pytorch torchvision cudatoolkit=10.1 -c pytorch-nightly
import torch
import torchvision

model = torchvision.models.detection.keypointrcnn_resnet50_fpn(pretrained=True)
model.eval()
example = torch.rand(1, 3, 800, 800)
traced_script_module = torch.jit.script(model, example)
traced_script_module.save("/home/parth/Desktop/model4.pt")