coremltools icon indicating copy to clipboard operation
coremltools copied to clipboard

validator error: Layer 'input' produces an output named 'input' which is also an output produced by the layer '__input'

Open oki5656 opened this issue 4 years ago • 3 comments

❓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

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")

oki5656 avatar Jul 26 '21 14:07 oki5656

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)?

TobyRoseman avatar Jul 28 '21 23:07 TobyRoseman

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.

oki5656 avatar Jul 29 '21 07:07 oki5656

any update? I have the same issue.

franva avatar Apr 02 '22 06:04 franva