Skip to content

How can I convert pre-trained model to coreml to use it on ios application?  #62

@sarojraut

Description

@sarojraut

I am using coremltools to do so.

import coremltools as ct
 import torch
 import torch.nn as nn

 model = torch.load('/Users/sarojraut/Downloads/side.pth',map_location=torch.device('cpu'))
 example_input = torch.rand(1, 3, 224, 224) 

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

But I get error

Traceback (most recent call last):
 File "<pyshell#34>", line 1, in <module>
 traced_model = torch.jit.trace(model, dummy_input)
 File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-   packages/torch/jit/_trace.py", line 846, in trace
 name = _qualified_name(func)
 File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site- packages/torch/_jit_internal.py", line 1145, in _qualified_name
 raise RuntimeError("Could not get name of python class object")
 RuntimeError: Could not get name of python class object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions