validator error: Layer 'input' produces an output named 'input' which is also an output produced by the layer '__input'
❓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.
error image

System Information
<watch .mlmodel below information> macOS Catalina 10.15.7 xcode==12.4
<built .mlmodel below information> 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
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")
Looking at your code sample, I'm not able to reproduce this issue.
Could you attach your torch model (i.e. model from your code)? Or tell us how to reproduce it (complete with the value of args, all import statement, and any other necessary code)?
Thank you for commenting ! I made the repo (including making .mlmodel file and network file, etc.), please use it. If you have any questions, please feel free to ask.
any update? I have the same issue.