MIL program object is not persisted between saving and loading a MLModel object
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
```python
import coremltools as ct
import numpy as np
import torch
# Create simple torch model and convert to mlprogram
x = torch.rand(10)
m_torch = torch.jit.trace(torch.nn.Linear(10, 2), x)
m1 = ct.convert(m_torch, inputs=[ct.TensorType(shape=x.shape)], convert_to="mlprogram")
# Model is valid; can get predictions.
print(m1.predict({'input': x}))
# MIL is present.
print(m1._get_mil_internal())
# Save Core ML model to disk and read it.
path = '/tmp/test.mlpackage'
m1.save(path)
m2 = ct.models.MLModel(path)
# MIL is not present!
print(m2._get_mil_internal())
```
Contributor guide
Research direction
Start by reproducing the provided Python example, focusing on MLModel.save, ct.models.MLModel(path), and _get_mil_internal(). Trace how the MIL program is handled across save and load, then add a regression test showing that the loaded model retains the MIL program.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100