'How can I convert pytorch model to core ml model?
I trained a model and got an output named model_final.pth.
I loaded the model as below.
#load model
model = torch.load('/content/drive/MyDrive/model/model_final.pth')
And I followed the below steps.
#load sample image
input_image = Image.open("/content/drive/MyDrive/model/g0079.jpg")
display(input_image)
to_tensor = transforms.ToTensor()
input_tensor = to_tensor(input_image)
input_batch = input_tensor.unsqueeze(0)
Then when I run the code below I get an error.
#First attempt at tracing
trace = torch.jit.trace(model, input_batch)
Error:
Why am I getting this error? What do you think I should do?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

