Skip to content

Adding a CoreML Export Script to Enhance Community Resources#1782

Open
malfihasan wants to merge 1 commit intoMegvii-BaseDetection:mainfrom
malfihasan:export_coreml
Open

Adding a CoreML Export Script to Enhance Community Resources#1782
malfihasan wants to merge 1 commit intoMegvii-BaseDetection:mainfrom
malfihasan:export_coreml

Conversation

@malfihasan
Copy link
Copy Markdown

I have been working on a CoreML project as a personal endeavor. I believe it could be beneficial to the community, so I am adding a coreml_export.py script for everyone's use. The script is added to tools/coreml_export.py.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 7, 2024

CLA assistant check
All committers have signed the CLA.

Comment thread tools/export_coreml.py
nms_spec = ct.proto.Model_pb2.Model()
nms_spec.specificationVersion = 5
for i in range(2):
decoder_output = _model._spec.description.output[i].SerializeToString()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_model._spec.description change spec.description.output

Comment thread tools/export_coreml.py
import os
from loguru import logger
import sys
import torch
Copy link
Copy Markdown

@mbotsu mbotsu Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add import torch.nn as nn

Comment thread tools/export_coreml.py
import torch
from yolox.exp import get_exp
from yolox.models.network_blocks import SiLU
from yolox.utils import replace_modules
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contains unused imports

Comment thread tools/export_coreml.py
parser.add_argument("opts", nargs=argparse.REMAINDER, help="Modify config options using the command-line")
parser.add_argument("--decode_in_inference", action="store_true", help="Decode in inference or not")
parser.add_argument("--class_name", type=str, default=None, help="Class name for the object")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are unused arguments

  • dynamic
  • no-onnxsim
  • decode_in_inference

@mbotsu
Copy link
Copy Markdown

mbotsu commented Jun 13, 2024

Hi.

Thanks to PR I was able to convert to CoreML.
When I ran it, I found a bug in the code and unnecessary arguments and imports.

As an additional request, I think it would be even better if the device defaults to CPU and optionally GPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants