Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.pth to .pt torch script conversion support of your model in mobile applications #19

Open
Yogeshvasu opened this issue Mar 19, 2024 · 0 comments

Comments

@Yogeshvasu
Copy link

import torch
import torchvision
from torchvision.models.detection.anchor_utils import AnchorGenerator

Load the pre-trained model from the .pth file

images, targets = next(iterator)
images = list(image.to(device) for image in images)

with torch.no_grad():
model.to(device)
model.eval()
output = model(images)

print("Predictions: \n", output)

traced_model = torch.jit.trace(model, output)

Trace the model using TorchScript

#traced_model = torch.jit.trace(model, example_input)

Save the traced model to a .pt file

traced_model.save('traced_model.pt')

AttributeError: 'str' object has no attribute 'shape'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant