Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoreML export failure #2007

Closed
kaneZhangRY opened this issue Jan 22, 2021 · 3 comments
Closed

CoreML export failure #2007

kaneZhangRY opened this issue Jan 22, 2021 · 3 comments
Labels
bug Something isn't working Stale

Comments

@kaneZhangRY
Copy link

Environment

  • OS: [Ubuntu]
  • GPU [1080 Ti]

I try to export the CoreML model by the commend: python models/export.py --weights /home/zry/yolov5/runs/exp5/weights/best.pt --img 640 --batch 1

However, it failed. The whole output is as follow

Fusing layers...
Model Summary: 140 layers, 7.24652e+06 parameters, 0 gradients

Starting TorchScript export with torch 1.7.1...
/home/tensor/miniconda3/envs/yolov5/lib/python3.8/site-packages/torch/jit/_trace.py:934: TracerWarning: Encountering a list at the output of the tracer might cause the trace to be incorrect, this is only valid if the container structure does not change based on the module's inputs. Consider using a constant container instead (e.g. for list, use a tuple instead. for dict, use a NamedTuple instead). If you absolutely need this and know the side effects, pass strict=False to trace() to allow this behavior.
module._c._create_method_from_trace(
TorchScript export success, saved as /home/zry/yolov5/runs/exp5/weights/best.torchscript.pt

Starting ONNX export with onnx 1.8.0...
ONNX export success, saved as /home/zry/yolov5/runs/exp5/weights/best.onnx

Starting CoreML export with coremltools 4.0...
Tuple detected at graph output. This will be flattened in the converted model.
Converting graph.
Adding op '1' of type const
Adding op '2' of type const
Adding op '3' of type const
Adding op '4' of type const
Adding op '5' of type const
Adding op '6' of type const
Adding op '7' of type const
Adding op '8' of type const
Adding op '9' of type const
Adding op '10' of type const
Adding op '11' of type const
Adding op '12' of type const
Adding op '13' of type const
Adding op '14' of type const
Adding op '15' of type const
Adding op '16' of type const
Adding op '17' of type const
Adding op '18' of type const
Adding op '19' of type const
Adding op '20' of type const
Adding op '21' of type const
Adding op '22' of type const
Adding op '23' of type const
Adding op '24' of type const
Adding op '25' of type const
Adding op '26' of type const
Adding op '27' of type const
Adding op '28' of type const
Adding op '29' of type const
Adding op '30' of type const
Adding op '31' of type const
Adding op '32' of type const
Adding op '33' of type const
Adding op '34' of type const
Adding op '35' of type const
Adding op '36' of type const
Adding op '37' of type const
Adding op '38' of type const
Adding op '39' of type const
Adding op '40' of type const
Adding op '41' of type const
Adding op '42' of type const
Adding op '43' of type const
Adding op '44' of type const
Adding op '45' of type const
Adding op '46' of type const
Adding op '47' of type const
Adding op '48' of type const
Adding op '49' of type const
Adding op '50' of type const
Adding op '51' of type const
Adding op '52' of type const
Adding op '53' of type const
Adding op '54' of type const
Adding op '55' of type const
Adding op '56' of type const
Adding op '57' of type const
Adding op '58' of type const
Adding op '59' of type const
Adding op '60' of type const
Adding op '61' of type const
Adding op '62' of type const
Adding op '63' of type const
Adding op '64' of type const
Adding op '65' of type const
Adding op '66' of type const
Adding op '67' of type const
Adding op '68' of type const
Adding op '69' of type const
Adding op '70' of type const
Adding op '71' of type const
Adding op '72' of type const
Adding op '73' of type const
Adding op '74' of type const
Adding op '75' of type const
Adding op '76' of type const
Adding op '77' of type const
Adding op '78' of type const
Adding op '79' of type const
Adding op '80' of type const
Adding op '81' of type const
Adding op '82' of type const
Adding op '83' of type const
Adding op '84' of type const
Adding op '85' of type const
Adding op '86' of type const
Adding op '87' of type const
Adding op '88' of type const
Adding op '89' of type const
Adding op '90' of type const
Adding op '91' of type const
Adding op '92' of type const
Adding op '93' of type const
Adding op '94' of type const
Adding op '95' of type const
Adding op '96' of type const
Adding op '97' of type const
Adding op '98' of type const
Adding op '99' of type const
Adding op '100' of type const
Adding op '101' of type const
Adding op '102' of type const
Adding op '103' of type const
Adding op '104' of type const
Adding op '105' of type const
Adding op '106' of type const
Adding op '107' of type const
Adding op '108' of type const
Adding op '109' of type const
Adding op '110' of type const
Adding op '111' of type const
Adding op '112' of type const
Adding op '113' of type const
Adding op '114' of type const
Adding op '115' of type const
Adding op '116' of type const
Adding op '117' of type const
Adding op '118' of type const
Adding op '119' of type const
Adding op '120' of type const
Adding op '121' of type const
Adding op '122' of type const
Adding op '123' of type const
Adding op '124' of type const
Adding op '125' of type const
Adding op '126' of type const
Adding op '127' of type const
Adding op '128' of type const
Adding op '129' of type const
Adding op '130' of type const
Adding op '131' of type const
Adding op '132' of type const
Adding op '133' of type const
Adding op '134' of type const
Adding op '135' of type const
Adding op '136' of type const
Adding op '137' of type const
Adding op '138' of type const
Adding op '139' of type const
Adding op '140' of type const
Adding op '141' of type const
Adding op '142' of type const
Adding op '143' of type const
Adding op '144' of type const
Adding op '145' of type const
Adding op '146' of type const
Adding op '147' of type const
Adding op '148' of type const
Adding op '149' of type const
Adding op '150' of type const
Adding op '151' of type const
Adding op '152' of type const
Adding op '153' of type const
Adding op '154' of type const
Adding op '155' of type const
Adding op '156' of type const
Converting Frontend ==> MIL Ops: 0%| | 0/932 [00:00<?, ? ops/s]Converting op 157 : constant
Adding op '157' of type const
Converting op 158 : constant
Adding op '158' of type const
Converting op 159 : constant
Adding op '159' of type const
Converting op 160 : constant
Adding op '160' of type const
Converting op 161 : constant
Adding op '161' of type const
Converting op 162 : constant
Adding op '162' of type const
Converting op 163 : constant
Converting op 164 : constant
Adding op '164' of type const
Converting op 165 : constant
Adding op '165' of type const
Converting op 166 : slice
Adding op '166' of type slice_by_index
Adding op '166_begin_0' of type const
Adding op '166_end_0' of type const
Adding op '166_stride_0' of type const
Adding op '166_end_mask_0' of type const
Converting op 167 : slice
Adding op '167' of type slice_by_index
Adding op '167_begin_0' of type const
Adding op '167_end_0' of type const
Adding op '167_stride_0' of type const
Adding op '167_end_mask_0' of type const
Converting op 168 : slice
Adding op '168' of type slice_by_index
Adding op '168_begin_0' of type const
Adding op '168_end_0' of type const
Adding op '168_stride_0' of type const
Adding op '168_end_mask_0' of type const
Converting op 169 : slice
Adding op '169' of type slice_by_index
Adding op '169_begin_0' of type const
Adding op '169_end_0' of type const
Adding op '169_stride_0' of type const
Adding op '169_end_mask_0' of type const
Converting op 170 : slice
Adding op '170' of type slice_by_index
Adding op '170_begin_0' of type const
Adding op '170_end_0' of type const
Adding op '170_stride_0' of type const
Adding op '170_end_mask_0' of type const
Converting op 171 : slice
Adding op '171' of type slice_by_index
Adding op '171_begin_0' of type const
Adding op '171_end_0' of type const
Adding op '171_stride_0' of type const
Adding op '171_end_mask_0' of type const
Converting op 172 : slice
Adding op '172' of type slice_by_index
Adding op '172_begin_0' of type const
Adding op '172_end_0' of type const
Adding op '172_stride_0' of type const
Adding op '172_end_mask_0' of type const
Converting op 173 : slice
Adding op '173' of type slice_by_index
Adding op '173_begin_0' of type const
Adding op '173_end_0' of type const
Adding op '173_stride_0' of type const
Adding op '173_end_mask_0' of type const
Converting op 174 : listconstruct
Converting op input.1 : cat
Adding op 'input.1' of type concat
Adding op 'input.1_interleave_0' of type const
Converting op 176 : listconstruct
Adding op '176' of type const
Converting op 177 : listconstruct
Adding op '177' of type const
Converting op 178 : listconstruct
Adding op '178' of type const
Converting op 179 : listconstruct
Adding op '179' of type const
Converting op x.2 : _convolution
Converting Frontend ==> MIL Ops: 2%|█▉ | 23/932 [00:00<00:00, 1407.90 ops/s]
CoreML export failure: unexpected number of inputs for node x.2 (_convolution): 13

Can anyone help me to correct it?

@kaneZhangRY kaneZhangRY added the bug Something isn't working label Jan 22, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2021

👋 Hello @kaneZhangRY, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@kaneZhangRY thanks for the bug report. We are aware of this. The issue is that coremltools is not compatible with the current PyTorch release. See https://coremltools.readme.io/docs

I would recommend you raise an issue on the coremltools repo, the more feedback on the topic they receive the more likely they may push a compatibility update.
https://github.com/apple/coremltools

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants