How to confirm yolov5 .pt in python into Torch Script

dear all:

i have use the following code to confirm model in python into Torch Script. but, when i transfer a yolov5 model, there is a error “Could not get name of python class object”. what is the problem?

import torch
import torchvision

# An instance of your model.
model = torchvision.models.resnet18()

# An example input you would normally provide to your model’s forward() method.
example = torch.rand(1, 3, 224, 224)

# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example)

traced_script_module.save(“traced_resnet_model.pt”)

I think you might be passing an unsupported object to torch.jit as described e.g. in this issue.

thank you. i have found that in the yolo folder, there is a py to transfer the pt model.

i have found that in the yolo folder, there is a py to transfer the pt model.

thank you.