GitRead 中文社区
首页趋势排行榜原创文章严选周刊
更多资源
新手训练营
精选专题热门话题GitHub 文档资源精选实战指南

yolo-ios-app

用于在您自己的iOS应用程序中运行YOLO的Ultralytics YOLO iOS应用程序源代码

  • 语言Swift
  • 默认分支main
  • 大小1.3 MB
  • 更新1 天前
  • Issues4
在 GitHub 打开
avatarultralytics

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

Ultralytics YOLO iOS 应用源码分析与深度洞悉

项目背景与痛点

在计算机视觉领域,YOLO(You Only Look Once)算法以其实时性和高效性备受瞩目。然而,要在 iOS 应用中实现这一功能并不容易。这不仅需要对算法有深刻理解,还需要熟悉苹果平台的开发环境。

Ultralytics YOLO iOS 应用正是为了解决这一痛点而生。它提供了一个可以直接在用户自己的 iOS 应用中运行 YOLO 的源代码。开发者们可以借此快速地将先进的计算机视觉功能嵌入到自己的应用中,无需从零开始复杂的算法实现和优化。

核心技术揭秘

技术栈与设计思想

Ultralytics YOLO iOS 应用的核心在于将 YOLO 算法集成到 iOS 多媒体框架中。这部分工作涉及到了核心的计算机视觉算法和苹果平台特有的开发工具链。

技术架构

架构图如下,展示了从用户请求到最终处理结果的数据流:

graph TD A[摄像头捕获] --> B[图像预处理] B --> C{"模型推理"} C -->|"YOLO推理"| D[生成边界框] C -->|"生成结果"| E[绘制边界框] E --> F[显示结果]
数据流
  1. 摄像头捕获:启动摄像头,获取实时视频帧。
  2. 图像预处理:对捕获到的图像进行必要的预处理,如缩放、归一化等。
  3. 模型推理:使用 YOLO 模型对图像进行推理,生成目标检测结果。
  4. 生成边界框:根据推理结果绘制边界框,标示出检测到的对象。
  5. 显示结果:将最终结果在屏幕上显示,以便用户查看识别结果。

核心算法实现

Ultralytics YOLO iOS 应用在实现上利用了苹果的 Metal 框架,以确保在移动端的高效性能。利用 Metal Performance Shaders (MPS),模型推理能够在硬件上加速完成,从而达到实时性。

此外,该应用还使用了 Core ML 来封装和管理 YOLO 模型,保证了模型能够无缝集成到现有项目中,并优化了在 Apple 设备上的数据流和性能表现。

功能亮点与差异

独特之处

  1. 无缝集成:开发者可以直接将 YOLO 模型集成到自己的 iOS 应用中,只需引入必要的框架和文件。
  2. 实时性:充分利用 Metal 和 Core ML 的特性能在移动端实现低延迟实时目标检测。
  3. 灵活的配置:支持从简单功能到复杂业务需求的自由定制。

与竞品对比

相比其他实现 YOLO 功能的 iOS 库,如 OpenCV 或 TensorFlow Lite,Ultralytics YOLO iOS 应用提供了更加定制化和优化的解决方案。利用 Apple 专有技术,可以实现更高效、更稳定的目标检测功能。

应用场景与落地建议

场景适用

该应用非常适合在需要实时目标检测的场景中使用,如安全监控、对象跟踪、以及增强现实应用等。通过实时检测到场景中的对象,可以快速生成反馈并作出相应动作。

使用注意事项

  1. 性能问题:高的帧率和实时性检测对设备的 GPU 有较高要求,尤其是在处理高分辨率的图像时。建议对不同性能目标设备做针对性的优化。
  2. 兼容性:确保所使用的 Core ML 版本在目标设备上的兼容性,避免因版本不一致而导致的问题。
  3. 用户隐私:严格遵守苹果相关隐私政策,处理好用户数据的采集和存储问题。

综合评价

优点总结

  1. 实时性:使用 Apple 技术栈实现高性能检测。
  2. 集成度高:易于在现有项目中集成。
  3. 扩展性强:支持根据业务需求灵活定制配置。

缺点总结

  1. 硬件限制:对于老旧或基础配置较低的设备,可能会影响实时性和检测效果。
  2. 版本适配问题:需要对多种 iOS 版本做兼容性处理,以确保在不同设备上正常运行。

总体来说,Ultralytics YOLO iOS 应用是一个非常值得开发者关注的开源项目,它让实时目标检测功能更加贴近应用开发的实际需求,同时也带来一定的挑战。对于使用现代移动平台的开发者来说,掌握这些核心技术和优化方法,对于未来开发相关应用将大有裨益。

内容更新时间:7月10日。 编辑团队负责选题与抽样审核,详见 编辑准则。

相关仓库

jaywcjlove/awesome-mac avatar
awesome-macjaywcjlove
21 小时前
118.2k
10.2k
2.0k

本项目致力于收集高质量的 macOS 软件,并按不同类别系统化整理,以便于搜索和使用。

appappleapplication+17
Swift
99.4 MB
1
详情
swiftlang/swift avatar
swiftswiftlang
12 小时前
70.5k
10.9k
9.6k

Swift 编程语言

Swift
1.3 GB
0
详情
vsouza/awesome-ios avatar
awesome-iosvsouza
8月28日
53.9k
6.8k
10

一份精选的优秀 iOS 生态系统列表,包含 Objective-C 和 Swift 项目

apple-swiftarkitawesome+10
Swift
16.8 MB
0
详情
apple/container avatar
containerapple
21 小时前
51.1k
1.8k
594

一款在 Mac 上使用轻量级虚拟机创建和运行 Linux 容器的工具。它使用 Swift 编写,并针对 Apple silicon 进行了优化。

Swift
10.4 MB
0
详情
iina/iina avatar
iinaiina
20 小时前
47.1k
2.9k
1.9k

适用于 macOS 的现代视频播放器。

hacktoberfestmacosmpv+3
Swift
246.3 MB
0
详情
exelban/stats avatar
statsexelban
5 小时前
43.3k
1.6k
20

菜单栏中的 macOS 系统监视器

batterybluetoothclock+11
Swift
59.9 MB
0
详情
Alamofire/Alamofire avatar
AlamofireAlamofire
1 周前
42.4k
7.6k
44

Swift 中优雅的 HTTP 网络

alamofirecarthagecertificate-pinning+12
Swift
44.7 MB
0
详情
permissionlesstech/bitchat avatar
bitchatpermissionlesstech
2 天前
37.1k
5.9k
175

蓝牙 mesh 聊天,IRC 氛围

bluetoothbluetooth-ledecentralized+7
Swift
126.8 MB
0
详情

关于

GitHub 原始描述(英文)

Ultralytics YOLO iOS App source code for running YOLO in your own iOS apps 🌟

aiappapp-storecoremlinstance-segmentationiosmlobject-detectionreal-timeswiftultralyticsxcodeyoloyolo11yolo26yolov8
  • GNU Affero General Public License v3.0
  • 531 Stars
  • 106 Forks
  • 5 Watching

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
748
价值分
350
活跃状态
活跃
GitHub

语言占比

Python
Ruby
Shell
Swift

Release

  • v8.9.23 - Release 8.9.23: keep thresholds across model changes, compile iOS 27 code in CI, fast Debug decode (#344)1 天前
  • v8.9.22 - Release 8.9.22: publish to TestFlight only for new versions (#343)2 天前
  • v8.9.21 - Release 8.9.21: fix external display on iOS 27 and drop duplicated external chrome (#341)2 天前
  • v8.9.20 - Release 8.9.20: make BoundingBoxView public for the Flutter plugin (#340)2 天前
  • v8.9.19 - Release 8.9.19: mirror Ultralytics annotation colors and honor model colors metadata (#339)2 天前

贡献者

glenn-jocherglenn-jocherjohn-rockyjohn-rockyUltralyticsAssistantUltralyticsAssistantasabri97asabri97dependabot[bot]dependabot[bot]pderrengerpderrengerY-T-GY-T-Galaa-elshamoutyalaa-elshamoutypicsalexpicsalexcdeilcdeilfvdefvdeonuralpszronuralpszr

Ultralytics logo

English | 简体中文

🚀 Ultralytics YOLO for iOS: App and Swift Package

Ultralytics Actions CI codecov CocoaPods

Ultralytics Discord Ultralytics Forums Ultralytics Reddit

Ultralytics YOLO for iOS provides on-device real-time inference for object detection, instance segmentation, semantic segmentation, depth estimation, classification, pose estimation, and oriented bounding box detection. The SDK supports both YOLO11 (with Core ML NMS) and YOLO26 models (shipped with nms=False for NMS-free inference). Download the app from the App Store, or integrate the Swift package into your own applications.


Ultralytics YOLO iOS App previews

Apple App store    Get it on Google Play

✨ Features

  • Swift and Core ML throughout, running on the Apple Neural Engine and GPU
  • Opt-in Apple Core AI (.aimodel) models on iOS 27 and later devices; Core ML (.mlpackage) remains the default
  • Camera-rate (~30 FPS) real-time inference on recent iPhones — see docs/performance.md for on-device profiling
  • Native UI following Apple interface guidelines
  • YOLO26 and YOLO11 models supported, including NMS-free and raw outputs
  • No third-party dependencies — pure Swift on Apple’s first-party frameworks
Feature iOS Details
Object Detection ✅ Bounding boxes, labels, and confidence scores
Instance Segmentation ✅ Instance masks with boxes and classes
Semantic Segmentation ✅ Dense per-pixel class maps
Depth Estimation ✅ Dense metric depth maps
Image Classification ✅ Top class predictions and scores
Pose Estimation ✅ Keypoints with boxes and confidence scores
Oriented Bounding Box (OBB) Detection ✅ Rotated boxes and polygon corners

📂 Repository Content

This repository contains two components for running YOLO models on Apple platforms (Edge AI):

Ultralytics YOLO iOS App (Main App)

The primary iOS application allows easy real-time YOLO inference using your device’s camera or image library. The shipped app bundles all seven official nano Core ML models, larger variants download on demand, and you can also test your custom Core ML or opt-in Core AI (.aimodel, iOS 27+ devices) models by adding them to the app project.

Swift Package (YOLO Library)

A lightweight Swift package designed for iOS and iPadOS. It handles model loading, inference, and postprocessing for YOLO models like YOLO26 in your own applications, with a few lines of SwiftUI:

// Perform inference on a UIImage
let result = model(uiImage)
// Use the built-in camera view for real-time inference with a model bundled in your app
var body: some View {
    YOLOCamera(
        modelPathOrName: "yolo26n-seg",
        task: .segment,
        cameraPosition: .back
    )
    .ignoresSafeArea()
}

📦 Official Model Assets

Official models are GitHub release assets, not large files committed to the repositories. The main iOS app downloads the seven nano Core ML assets at build time and bundles them into the app; larger app models, the Swift package’s YOLO(url:) loading, and Flutter package assets download official models on first use and cache them locally.

The main YOLOiOSApp bundles all seven nano models (one per task: detect, segment, semantic, depth, classify, pose, OBB) into the shipped app, including App Store/archive builds. They are downloaded at build time from the GitHub release assets by a Download YOLO Models Xcode build phase that runs scripts/download-models.sh — the .mlpackage files are never committed to the repo (*.mlpackage is gitignored). The step is idempotent and is skipped on GitHub Actions CI, which runs the same script in its own step.

Runtime asset Used by Release
Core ML int8 .mlpackage.zip iOS app, Swift package, Flutter on iOS/macOS yolo-ios-app v8.3.0
Core AI FP16 .aimodel.zip Opt-in: iOS app, Swift package on iOS 27+ yolo-ios-app v8.3.0
LiteRT w8a32 .tflite Flutter on Android yolo-flutter-app v0.6.6

URL patterns:

  • Core ML: https://github.com/ultralytics/yolo-ios-app/releases/download/v8.3.0/<model>.mlpackage.zip
  • Core AI (opt-in): https://github.com/ultralytics/yolo-ios-app/releases/download/v8.3.0/<model>.aimodel.zip
  • LiteRT: https://github.com/ultralytics/yolo-flutter-app/releases/download/v0.6.6/<model>_w8a32.tflite

Core ML (.mlpackage) remains the default. Core AI (.aimodel) is an opt-in for iOS 27 and later devices: pass an .aimodel path or an .aimodel.zip URL. It is not available on earlier iOS versions or in the iOS Simulator. See docs/performance.md for the measured trade-offs. In the iOS app, turn on Settings → Ultralytics YOLO → Core AI Models (iOS 27+) (off by default) and return to the app: it then lists, downloads and loads the Core AI assets instead of the Core ML ones.

let local = YOLO("/path/to/yolo26n.aimodel", task: .detect)
let remote = YOLO(url: URL(string: "https://github.com/ultralytics/yolo-ios-app/releases/download/v8.3.0/yolo26n.aimodel.zip")!, task: .detect)

The iOS app registry is RemoteModels.swift. It enumerates YOLO26 n/s/m/l/x assets for detect, segment, semantic, depth, classify, pose, and OBB and points each model ID at the v8.3.0 release. The Core ML and Core AI columns below are owned by this repo; the LiteRT column summarizes the Flutter repo’s Android export script and release assets.

Property Core ML Core AI LiteRT
Model IDs yolo26{n,s,m,l,x} yolo26{n,s,m,l,x} yolo26{n,s,m,l,x}
Tasks detect, seg, sem, depth, cls, pose, obb detect, seg, sem, depth, cls, pose, obb detect, seg, sem, depth, cls, pose, obb
Format .mlpackage.zip .aimodel.zip .tflite
Runs on iOS 13+, iOS Simulator iOS 27+ devices Android
quantize 8 16 w8a32
imgsz 224 cls; 640 others 224 cls; 640 others 224 cls; 640 others
nms False None None
end2end metadata False cls/sem/depth; True others False False
Calibration exporter default None (FP16) None (dynamic-range)
Preprocessing Vision Swift (letterbox, Accelerate) Android native
Postprocessing Swift Swift (with NMS) Android native

Export scripts require ultralytics>=8.4.142, and >=8.4.155 for Core AI. Core ML assets use nms=False to select the NMS-free head for detect, segment, pose, and OBB. Core AI assets keep the package default raw head (nms=None), which the SDK decodes with its existing Swift NMS: on an iPhone 17 Pro it is about twice as fast in inference as both the Core AI end-to-end head and the Core ML assets (docs/performance.md). Core AI has no NMS operator, so there is no NMS pipeline stage as in Core ML, and the Ultralytics package has no int8 Core AI export, so Core AI assets are FP16 and roughly twice the download size of the int8 Core ML assets. Both formats carry the same Ultralytics metadata keys and values (task, names, imgsz, stride, end2end, …), and the SDK decodes either head by output shape. With useGpu true (hardware acceleration) Core AI places the model across the Neural Engine, GPU and CPU; useGpu false pins it to the CPU. Classification, semantic, and depth retain their native outputs. LiteRT uses nms=None for raw one-to-many outputs with Android-side NMS. nms=True embeds NMS where supported. The end2end metadata field describes the exported graph; use nms to configure exports.

Core ML and Core AI Release Workflow

The published v8.3.0 binary dimensions are recorded above. The export script scripts/export-models.py defines the official exports, int8 Core ML and FP16 Core AI settings, .mlpackage.zip and .aimodel.zip packaging, the optional local app-copy step, and optional GitHub release upload. It exports Core ML by default; add --formats coreai (or --formats coreml coreai) for the opt-in Core AI assets, which needs macOS 26 or later on Apple silicon, ultralytics>=8.4.155 and coreai-torch>=0.4.2. If its export matrix changes, replace the generated assets in v8.3.0 and update this table together.

uv venv --python 3.13 .venv
uv pip install "ultralytics[export-coreml]>=8.4.142"
uv run python scripts/export-models.py

Useful variants:

# Export only nano task models for local validation and copy them into YOLOiOSApp/Models/.
uv run python scripts/export-models.py --sizes n --copy-to-app

# Export and replace all official Core ML assets in the existing release.
uv run python scripts/export-models.py --upload --repo ultralytics/yolo-ios-app --tag v8.3.0

# Export and replace the opt-in Core AI assets (macOS 26 or later on Apple silicon).
uv run python scripts/export-models.py --formats coreai --upload --repo ultralytics/yolo-ios-app --tag v8.3.0

The script exports from checkpoints named yolo26<size><suffix>.pt, for example yolo26n.pt, yolo26s-seg.pt, yolo26m-sem.pt, yolo26l-pose.pt, and yolo26x-obb.pt. Official Core ML assets use nms=False to select NMS-free detect, segment, pose, and OBB outputs, while Core AI assets keep the raw head and the SDK applies its Swift NMS; depth retains its raw dense output. Swift-side postprocessing handles these task outputs (classify and semantic outputs need no NMS decode).

Android LiteRT Counterparts

The Android assets used by the Flutter package are maintained in the Flutter repo, not this iOS repo. Their canonical export script is scripts/export-tflite-models.py in ultralytics/yolo-flutter-app; it exports the matching YOLO26 task/size matrix as w8a32 .tflite assets. This dynamic-range format uses int8 weights and FP32 activations, needs no calibration data, and is published in yolo-flutter-app v0.6.6.

🛠️ Quickstart Guide

New to YOLO on mobile or want to quickly test your custom model? Start with the main YOLOiOSApp. The seven nano task models are bundled at build time, so the app can run offline after installation; larger model sizes download on demand.

  • Ultralytics YOLO iOS App (Main App): The easiest way to experience YOLO inference on iOS.

Ready to integrate YOLO into your own project? Explore the Swift Package and example applications.

  • Swift Package (YOLO Library): Integrate YOLO capabilities into your Swift app.
  • Example Apps: See practical implementations using the YOLO Swift Package.

Add the UltralyticsYOLO package to your app with Swift Package Manager:

.package(url: "https://github.com/ultralytics/yolo-ios-app.git", from: "8.9.22")

Or with CocoaPods:

pod 'UltralyticsYOLO', '~> 8.9'

Then import UltralyticsYOLO and use the YOLO class — see the Swift Package README for full usage. The same UltralyticsYOLO package powers both this native iOS app and the Ultralytics YOLO Flutter plugin, keeping one source of truth across platforms.

Import a custom model from Ultralytics Platform

In Platform, click the QR button on a completed Core ML or Core AI export, then open Ultralytics YOLO, tap the QR button in the bottom toolbar, and point the existing camera preview at the code. While scanning, the camera dims around a viewfinder; tap Cancel or the QR button again to return to inference. Confirm the model name, task, and download size. The app installs the model and adds it to the Custom section of the model picker. The header shows the task, with Custom added for imported models, above the active model name. Tap it to choose a custom import or any official model in one compact list, with size choices grouped into one row per task. The Custom section also provides Scan QR and a help button for the Platform export guide. Tap the trash icon next to a custom model to remove it. The last selected custom model is restored on launch and works offline.

Exports must use batch 1 and static inputs. Core AI requires a supported iOS 27+ device; use Core ML for broader compatibility. Importing a model uses its actual format independently of the official-model Core AI setting. Links authorize one export for 24 hours; anyone with the link can download during that window. Installed models continue working after expiry, and separate exports never overwrite each other even when their names match.

🧪 Testing Procedures

This repository includes comprehensive unit tests for both the YOLO Swift Package and the example applications, ensuring code reliability and stability.

Running Tests

Tests require Core ML model files (.mlpackage), which are not committed to the repository due to their size. To run the package tests with model validation, first run the same downloader used by CI and the app build phase:

bash scripts/download-models.sh

This downloads the seven nano Core ML packages into Tests/YOLOTests/Resources/ and copies them into YOLOiOSApp/Models/<Task>/ for the main app bundle. Tests run on the iOS Simulator, which does not ship Core AI, so they exercise the Core ML backend; the opt-in Core AI backend is validated on an iOS 27 device (docs/performance.md). You can also export or replace these packages with custom Core ML models using the Ultralytics Python library’s export function. If a specific test target supports SKIP_MODEL_TESTS, keeping it set to true skips tests that require loading and running a model.

Test Coverage

  • YOLO Swift Package: Includes tests for core functionalities like model loading, preprocessing, inference, and postprocessing across different tasks.
  • Example Apps: Contains tests verifying UI components, model integration, and real-time inference performance within the sample applications.

Test Documentation

Each test directory (e.g., Tests/YOLOTests) may include a README.md with specific instructions for testing that component, covering:

  • Required model files and where to obtain them.
  • Steps for model conversion and setup.
  • Overview of the testing strategy.
  • Explanation of key test cases.

💡 Contribute

We warmly welcome contributions to our open-source projects! Your support helps us push the boundaries of Artificial Intelligence (AI). Get involved by reviewing our Contributing Guide and sharing your feedback through our Survey. Thank you 🙏 to all our contributors!

Ultralytics open-source contributors

📄 License

Ultralytics provides two licensing options to accommodate diverse use cases:

  • AGPL-3.0 License: An OSI-approved open-source license ideal for academic research, personal projects, and experimentation. It promotes open collaboration and knowledge sharing. See the LICENSE file for the full license text.
  • Enterprise License: Tailored for commercial applications, this license allows the integration of Ultralytics software and AI models into commercial products and services without the open-source requirements of AGPL-3.0. If your scenario involves commercial use, please contact us via Ultralytics Licensing.

📮 Contact

  • For bug reports and feature requests related to this iOS project, please use GitHub Issues.
  • For questions, discussions, and support regarding Ultralytics technologies, join our active Discord community!

Ultralytics GitHub space Ultralytics LinkedIn space Ultralytics Twitter space Ultralytics YouTube space Ultralytics TikTok space Ultralytics BiliBili space Ultralytics Discord

评论

登录 后发表评论
暂无评论
GitRead 中文社区
深度解读 · 趋势洞察 · 价值精选

关于

关于我们联系我们编辑准则收录标准赞赏人员

发现

技术趋势新手训练营资源精选实战指南精选专题热门话题GitHub 文档

条款

隐私政策服务条款网站地图
26.9万收录项目
5.9万中文话题
155精选专题
发现技术价值,连接开源智慧
© 2026 GitRead · GitHub 中文社区 本站与 GitHub, Inc. 无隶属关系;GitHub 是 GitHub, Inc. 的商标。