Skip to content

ml-stable-diffusion

Converts Stable Diffusion models to Apple's Core ML format and runs image generation on Apple Silicon.

Stars
18k
Forks
1.1k
Licence
MIT
Language
Python
Last update
2 months ago
Type
Library

What it is

This repository from Apple provides tools for running Stable Diffusion, an AI model that generates images from text, using Apple's Core ML framework on Apple Silicon devices. It includes a Python package that converts PyTorch models to Core ML format and generates images through Hugging Face diffusers, plus a Swift package that developers can add to Xcode projects to build image generation into their apps. The README's benchmarks cover iPhone, iPad, and Mac hardware.

  • Convert a PyTorch Stable Diffusion model to Core ML format with the Python package
  • Generate images from a text prompt in Python using Hugging Face diffusers
  • Add image generation to an Xcode project using the StableDiffusion Swift package
  • Compare device latency and diffusion speed using the README benchmark tables as a reference

Great for

  • Developers building image generation features into macOS, iOS, or iPadOS apps
  • Engineers who want to convert Stable Diffusion models to Core ML for on-device inference
  • Researchers testing Core ML deployment of diffusion models on Apple hardware

Not ideal for

  • People who only want to generate images without writing code, since the README describes a developer package and Swift project integration
  • Users on Intel Macs or non-Apple platforms, since the project targets Apple Silicon and Core ML
  • Anyone needing the newest model versions, since the benchmarks are from 2023 and the README does not describe current model support
Step-by-step guide: how to use ml-stable-diffusionInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Clone and build from source

    You'll need: macOS 13.1 or later · Python 3.8 · Xcode 14.3 or later for building the Swift package

    Clone the repository

    git clone https://github.com/apple/ml-stable-diffusion.git
  2. 2

    Run it

    • Review the System Requirements section of the README to confirm your macOS, Python, and Xcode versions
    • Clone the repository and install the Python package as described in the README
    • Convert or download a Core ML Stable Diffusion model
    • Run image generation from Python or add the Swift package to an Xcode project
  3. 3

    Get the most out of it

    • Choose the --compute-unit and --attention-implementation options per device, as the README benchmarks report different best settings for different hardware
    • Use the reduceMemory option on memory-constrained devices, noting the README says it can add latency
    • Review the compression sections of the README to reduce model size and memory use

Downloads

Strengths

  • Official Apple repository with a Python conversion package and a Swift package for apps
  • Includes documented system requirements and performance benchmarks across several devices
  • Released under the MIT license

Trade-offs

  • Requires macOS 13.1 or later, Python 3.8, and coremltools 7.0 for model conversion according to the README's requirements table
  • Benchmark numbers come from 2023 beta and early builds and may not reflect current performance
  • Setup involves developer tooling such as Python, Xcode, and model file handling, so it is not a beginner-friendly app

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.