{"id":15628927,"url":"https://github.com/tucan9389/objectdetection-coreml","last_synced_at":"2025-10-29T23:17:39.301Z","repository":{"id":43600057,"uuid":"168563766","full_name":"tucan9389/ObjectDetection-CoreML","owner":"tucan9389","description":"An example running Object Detection using Core ML (YOLOv8, YOLOv5, YOLOv3, MobileNetV2+SSDLite)","archived":false,"fork":false,"pushed_at":"2023-07-01T13:39:41.000Z","size":4820,"stargazers_count":307,"open_issues_count":10,"forks_count":54,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T11:04:40.193Z","etag":null,"topics":["coreml","object-detection","ssd-mobilenet","yolov3","yolov3-tiny","yolov5","yolov8"],"latest_commit_sha":null,"homepage":"https://github.com/motlabs/awesome-ml-demos-with-ios","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tucan9389.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-31T17:13:24.000Z","updated_at":"2025-03-22T09:42:12.000Z","dependencies_parsed_at":"2024-01-29T16:58:24.144Z","dependency_job_id":"f4399965-01bd-4f03-8135-4da5eb591900","html_url":"https://github.com/tucan9389/ObjectDetection-CoreML","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tucan9389%2FObjectDetection-CoreML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tucan9389%2FObjectDetection-CoreML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tucan9389%2FObjectDetection-CoreML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tucan9389%2FObjectDetection-CoreML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tucan9389","download_url":"https://codeload.github.com/tucan9389/ObjectDetection-CoreML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657276,"owners_count":20974344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coreml","object-detection","ssd-mobilenet","yolov3","yolov3-tiny","yolov5","yolov8"],"created_at":"2024-10-03T10:24:50.333Z","updated_at":"2025-10-29T23:17:39.216Z","avatar_url":"https://github.com/tucan9389.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObjectDetection-CoreML\n\n\u003e supporting models: [`YOLOv8`](https://github.com/ultralytics/yolov5), [`YOLOv5`](https://github.com/ultralytics/yolov5), [`YOLOv3`](https://github.com/ultralytics/yolov3), `MobileNetV2+SSDLite`\n\n![platform-ios](https://img.shields.io/badge/platform-ios-lightgrey.svg)\n![swift-version](https://img.shields.io/badge/swift-4.2-red.svg)\n![lisence](https://img.shields.io/badge/license-MIT-black.svg)\n\nThis project is Object Detection on iOS with Core ML.\u003cbr\u003eIf you are interested in iOS + Machine Learning, visit [here](https://github.com/motlabs/iOS-Proejcts-with-ML-Models) you can see various DEMOs.\u003cbr\u003e![SSDMobileNetV2-DEMO](https://user-images.githubusercontent.com/37643248/188248210-2c02790b-6231-4549-8211-e3edcccba9e8.gif)\n\n## Requirements\n\n- Xcode 10.3+\n- iOS 13.0+\n- Swift 4.2\n\n## How To Build and Run the Project\n\n### 1. Clone the project\n\n```shell\ngit clone https://github.com/tucan9389/ObjectDetection-CoreML\n```\n\n### 2. Prepare Core ML model\n\n- You can download COCO models or another model from [here](#model-size-minimum-ios-version-download-link)\n\n\u003e Or if you want to make and use model with custom dataset,\n\u003e 1. follow [roboflow tutorial from scratch](https://blog.roboflow.com/how-to-train-yolov5-on-a-custom-dataset/) or [yolov5 repo's tutorial](https://github.com/ultralytics/yolov5/issues/12)\n\u003e 2. and convert the `.pt` model to `.mlmodel` model with [our issue](https://github.com/tucan9389/ObjectDetection-CoreML/issues/6#issuecomment-1235192089).\n\n### 3. Add the model to the project\n\nBy default, the project uses the `yolov8s` model. If you want to use another model, you can replace the model file in the project.\n\n\u003cimg width=\"1305\" alt=\"Screen Shot 2022-09-03 at 9 48 43 AM\" src=\"https://user-images.githubusercontent.com/37643248/188249381-391d494d-47f0-4bd7-b70b-88809a2d7f04.png\"\u003e\n\n\u003cimg width=\"560\" alt=\"Screen Shot 2022-09-03 at 9 46 19 AM\" src=\"https://user-images.githubusercontent.com/37643248/188249388-6b29075b-0d02-4421-addd-e8b830613728.png\"\u003e\n\n### 4. Set model name properly in `ViewController.swift`\n\n\u003cimg width=\"640\" alt=\"image\" src=\"https://user-images.githubusercontent.com/37643248/188249496-20ba838c-7f0f-4457-adac-2fa11344c7de.png\"\u003e\n\n### 5. Build and Run\n\n## How To Run with your own model\n\n### 1. Convert your model to Core ML\n\n\u003e At this moment(23.04.08), there is error when converting yolov8 models to Core ML. Once https://github.com/ultralytics/ultralytics/pull/1791 is merged, you can use the following steps. (Or you can use [this PR](https://github.com/ultralytics/ultralytics/pull/1898) alternatively.)\n\n#### Pre-requirements\n\n```shell\npip install ultralytics\npip install coremltools\n```\n\n#### Option 1) With shell\n\n```shell\nyolo export model=yolov8n.pt format=coreml nms\n```\n\n\n#### Option 2) With python script\n\n```python\n# mian.py\nfrom ultralytics import YOLO\n\nif __name__ == '__main__':\n    model = YOLO(\"yolov8n.pt\", task='detect')  # load a pretrained model\n    model.overrides['nms'] = True\n    success = model.export(format=\"coreml\")  # export the model to CoreML format\n```\n\n```shell\n# in terminal\npython main.py\n# then you can see the `.mlpackage` or `.mlmodel` file in your current directory\n# (btw you can check your current directory with `pwd` command)\n```\n\n### 2. Follow the steps above from Step 3\n\n## Models\n\n### Model Matadata\n\n\u003cimg width=\"640\" alt=\"image\" src=\"https://user-images.githubusercontent.com/37643248/230690729-ed084be1-f6d6-42a3-b72a-3b5987143bbc.png\"\u003e\n\n\n### Model Size, Minimum iOS Version, Download Link\n\nModel | Size\u003cbr\u003e(MB) | Minimum\u003cbr\u003eiOS Version | Download\u003cbr\u003eLink | Trained Dataset\n:---- | ----: | :----: | ---- | --- | \nyolov8n.mlmodel | 12.7 | iOS14 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov8-models/yolov8n.mlpackage.zip)\nyolov8s.mlmodel | 44.7 | iOS14 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov8-models/yolov8s.mlpackage.zip)\nyolov8m.mlmodel | 52.1 | iOS14 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov8-models/yolov8m.mlpackage.zip)\nyolov8l.mlmodel | 87.8 | iOS14 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov8-models/yolov8l.mlpackage.zip)\nyolov8x.mlmodel | 272.9 | iOS14 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov8-models/yolov8x.mlpackage.zip)\nyolov5n.mlmodel | 7.52 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5n.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5s.mlmodel | 28.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5s.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5m.mlmodel | 81.2 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5m.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5l.mlmodel | 178.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5l.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5x.mlmodel | 331.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5x.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5n6.mlmodel | 12.8 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5n6.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5s6.mlmodel | 48.5 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5s6.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5m6.mlmodel | 137.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5m6.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5l6.mlmodel | 293.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5l6.mlmodel) | [COCO](#trained-dataset-infos)\nyolov5x6.mlmodel | 537.0 | iOS13 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov5-models/yolov5x6.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3.mlmodel | 248.4 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3FP16.mlmodel | 124.2 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3FP16.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3Int8LUT.mlmodel | 62.2 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3Int8LUT.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3Tiny.mlmodel | 35.5 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3Tiny.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3TinyFP16.mlmodel | 17.8 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3TinyFP16.mlmodel) | [COCO](#trained-dataset-infos)\nYOLOv3TinyInt8LUT.mlmodel | 8.9 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/yolov3-models/YOLOv3TinyInt8LUT.mlmodel) | [COCO](#trained-dataset-infos)\nMobileNetV2_SSDLite.mlmodel | 9.3 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/etc-models/MobileNetV2_SSDLite.mlmodel) | [COCO](#trained-dataset-infos)\nObjectDetector.mlmodel | 63.7 | iOS12 | [Link](https://github.com/tucan9389/ObjectDetection-CoreML/releases/download/etc-models/ObjectDetector.mlmodel) | [6 Label Dataset](#trained-dataset-infos)\n\n#### Trained Dataset Infos\n\n\u003cdetails\u003e\n  \u003csummary\u003eCOCO Dataset\u003c/summary\u003e\n\n- https://github.com/ultralytics/yolov5/blob/9da6d0f9f5bc37fa386b7b82d2a963f94650949a/data/coco.yaml#L17-L97\n  \n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e6 Label Dataset(Apple's DEMO) \u003c/summary\u003e\n\n- Bagel\n- Banana\n- Coffee\n- Croissant\n- Egg\n- Waffle\n  \n\u003c/details\u003e\n\n## Performance\n\n\u003e Build Setting:\u003cbr\u003e\n\u003e Xcoede \u003e Build Settings \u003e Apple Clang - Code Generation \u003e Optimization Level \u003e Fastest [-O3]\n\n\u003cimg width=\"560\" alt=\"Screen Shot 2022-09-05 at 4 31 08 PM\" src=\"https://user-images.githubusercontent.com/37643248/188393214-d2e822a6-73b2-4971-a46d-27cdbfc8c61c.png\"\u003e\n\n### Infernece Time (ms)\n\n| Model vs. Device    | 14\u003cbr\u003ePro | 13\u003cbr\u003ePro | 12\u003cbr\u003ePro | 11\u003cbr\u003ePro | XS | XS\u003cbr\u003eMax | XR | X | 7+ | 7 |\n| :---- | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: |\n| yolov8n             | 15\n| yolov8s             | 29\n| yolov8m             | 37\n| yolov8l             | 45\n| yolov8x             | 51\n| yolov5n             |  |  | 24 |  |  |  |  |  |  |  |\n| yolov5s             |  |  | 29 |  |  |  |  |  |  |  |\n| yolov5m             |  |  | 39 |  |  |  |  |  |  |  |\n| yolov5l             |  |  | 38 |  |  |  |  |  |  |  |\n| yolov5x             |  |  | 69 |  |  |  |  |  |  |  |\n| yolov5n6            |  |  | 24 |  |  |  |  |  |  |  |\n| yolov5s6            |  |  | 34 |  |  |  |  |  |  |  |\n| yolov5m6            |  |  | 39 |  |  |  |  |  |  |  |\n| yolov5l6            |  |  | 41 |  |  |  |  |  |  |  |\n| yolov5x6            |  |  | 57 |  |  |  |  |  |  |  |\n| YOLOv3              |  |  | 45 | 83 | 108 | 93 | 100 | 356 | 569 | 561 | \n| YOLOv3FP16          |  |  | 44 | 84 | 104 | 89 | 101 | 348 | 572 | 565 | \n| YOLOv3Int8LUT       |  |  | 53 | 86 | 101 | 92 | 100 | 337 | 575 | 572 | \n| YOLOv3Tiny          |  |  | 36 | 44 | 46 | 41 | 47 | 106 | 165 | 168 | \n| YOLOv3TinyFP16      |  |  | 33 | 44 | 51 | 41 | 44 | 103 | 165 | 167 | \n| YOLOv3TinyInt8LUT   |  |  | 39 | 44 | 45 | 39 | 39 | 106 | 160 | 161 | \n| MobileNetV2_SSDLite |  |  | 17 | 18 | 31 | 31 | 31 | 109 | 141 | 134 | \n| ObjectDetector      |  |  | 13 | 18 | 24 | 26 | 23 | 63 | 86 | 84 | \n\n### Total Time (ms)\n\n| Model vs. Device    | 14\u003cbr\u003ePro | 13\u003cbr\u003ePro | 12\u003cbr\u003ePro | | 11\u003cbr\u003ePro | XS | XS\u003cbr\u003eMax | XR | X | 7+ | 7 |\n| :---- | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | \n| yolov8n             | 15\n| yolov8s             | 31\n| yolov8m             | 39\n| yolov8l             | 47\n| yolov8x             | 52\n| yolov5n             |  |  | 26 |  |  |  |  |  |  |  |\n| yolov5s             |  |  | 31 |  |  |  |  |  |  |  |\n| yolov5m             |  |  | 41 |  |  |  |  |  |  |  |\n| yolov5l             |  |  | 39 |  |  |  |  |  |  |  |\n| yolov5x             |  |  | 72 |  |  |  |  |  |  |  |\n| yolov5n6            |  |  | 25 |  |  |  |  |  |  |  |\n| yolov5s6            |  |  | 36 |  |  |  |  |  |  |  |\n| yolov5m6            |  |  | 41 |  |  |  |  |  |  |  |\n| yolov5l6            |  |  | 42 |  |  |  |  |  |  |  |\n| yolov5x6            |  |  | 59 |  |  |  |  |  |  |  |\n| YOLOv3              |  |  | 46 | 84 | 108 | 93 | 100 | 357 | 569 | 561 | \n| YOLOv3FP16          |  |  | 45 | 85 | 104 | 89 | 101 | 348 | 572 | 565 | \n| YOLOv3Int8LUT       |  |  | 54 | 86 | 102 | 92 | 102 | 338 | 576 | 573 | \n| YOLOv3Tiny          |  |  | 37 | 45 | 46 | 42 | 48 | 106 | 166 | 169 | \n| YOLOv3TinyFP16      |  |  | 35 | 45 | 51 | 41 | 44 | 104 | 165 | 167 | \n| YOLOv3TinyInt8LUT   |  |  | 41 | 45 | 45 | 39 | 40 | 107 | 160 | 161 | \n| MobileNetV2_SSDLite |  |  | 19 | 19 | 32 | 31 | 32 | 109 | 142 | 134 | \n| ObjectDetector      |  |  | 14 | 18 | 25 | 26 | 23 | 64 | 87 | 85 | \n\n### FPS\n\n| Model vs. Device    | 14\u003cbr\u003ePro | 13\u003cbr\u003ePro | 12\u003cbr\u003ePro | | 11\u003cbr\u003ePro | XS | XS\u003cbr\u003eMax | XR | X | 7+ | 7 |\n| :---- | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: | \n| yolov8n             | 38\n| yolov8s             | 14\n| yolov8m             | 14\n| yolov8l             | 14\n| yolov8x             | 13\n| yolov5n             |  |  | 19 |  |  |  |  |  |  |  |\n| yolov5s             |  |  | 14 |  |  |  |  |  |  |  |\n| yolov5m             |  |  | 13 |  |  |  |  |  |  |  |\n| yolov5l             |  |  | 14 |  |  |  |  |  |  |  |\n| yolov5x             |  |  | 7 |  |  |  |  |  |  |  |\n| yolov5n6            |  |  | 19 |  |  |  |  |  |  |  |\n| yolov5s6            |  |  | 14 |  |  |  |  |  |  |  |\n| yolov5m6            |  |  | 13 |  |  |  |  |  |  |  |\n| yolov5l6            |  |  | 14 |  |  |  |  |  |  |  |\n| yolov5x6            |  |  | 13 |  |  |  |  |  |  |  |\n| YOLOv3              |  |  | 12 | 9 | 8 | 10 | 9 | 2 | 1 | 1 | \n| YOLOv3FP16          |  |  | 13 | 9 | 9 | 10 | 8 | 2 | 1 | 1 | \n| YOLOv3Int8LUT       |  |  | 14 | 9 | 9 | 10 | 9 | 2 | 1 | 1 | \n| YOLOv3Tiny          |  |  | 14 | 14 | 21 | 22 | 20 | 8 | 5 | 5 | \n| YOLOv3TinyFP16      |  |  | 14 | 14 | 19 | 23 | 21 | 9 | 5 | 5 | \n| YOLOv3TinyInt8LUT   |  |  | 11 | 14 | 21 | 24 | 23 | 8 | 5 | 5 | \n| MobileNetV2_SSDLite |  |  | 19 | 29 | 23 | 23 | 23 | 8 | 6 | 6 | \n| ObjectDetector      |  |  | 17 | 29 | 23 | 23 | 24 | 14 | 10 | 11 | \n\n## See also\n\n- [motlabs/awesome-ml-demos-with-ios](https://github.com/motlabs/awesome-ml-demos-with-ios)\u003cbr\u003e\n  : The challenge using machine learning model created from tensorflow on iOS\n- [Machine Learning - Models - Apple Developer](https://developer.apple.com/machine-learning/models)\n- [hollance/coreml-survival-guide](https://github.com/hollance/coreml-survival-guide)\n- [vonholst/SSDMobileNet_CoreML](https://github.com/vonholst/SSDMobileNet_CoreML)\u003cbr\u003e\n  : iOS project for object detection(SSDMobileNet V1) using Core ML.\n- [ultralytics/ultralytics](https://github.com/ultralytics/ultralytics)\u003cbr\u003e\n  : YOLOv8 repository\n- [ultralytics/yolov5](https://github.com/ultralytics/yolov5)\u003cbr\u003e\n  : YOLOv5 repository\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftucan9389%2Fobjectdetection-coreml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftucan9389%2Fobjectdetection-coreml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftucan9389%2Fobjectdetection-coreml/lists"}