validator error: Layer 'input' produces an output named 'input' which is also an output produced by the layer '__input'
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
## ❓Question
When I tried to watch the preview of .mlmodel file using Xcode, an error occurred and I could not watch it.
The program was created from [this repository's ESPNetv2](https://github.com/sacmehta/EdgeNets).
## error image

## System Information
macOS Catalina 10.15.7
xcode==12.4
python==3.7.10
torch==1.8.0
torchvision==0.9.0
numpy==1.19.5
coremltools==4.1
## Part of the code that created .mlmodel
```python
model = espnetv2_seg(args)
model.eval()
example = torch.rand(1, 3, 640, 480)
traced_script_module = torch.jit.trace(model, example)
mlmodel = ct.convert(
traced_script_module,
inputs=[ct.TensorType(name="input", shape=example.shape)],
)
mlmodel.save('./espnetv2_640_480.mlmodel')
# load the model
mlmodel = ct.models.MLModel("espnetv2_640_480.mlmodel")
labels_json = {"labels": ["obstacle", "background"]}
mlmodel.user_defined_metadata["com.apple.coreml.model.preview.type"] = "imageSegmenter"
mlmodel.user_defined_metadata['com.apple.coreml.model.preview.params'] = json.dumps(labels_json)
mlmodel.save("espnet_640_480_with_metadata.mlmodel")
```
Contributor guide
Research direction
Start with the shown ct.convert call and the traced ESPNetv2 model, then inspect the saved espnetv2_640_480.mlmodel in Xcode. Investigate why both the input and __input layers produce an output named input. Done means identifying whether the generated model can be corrected so Xcode previews it without the validator error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100