Swift package for native Stable Diffusion inference on Apple devices
Top 62.9% on sourcepulse
Native Diffusion enables local Stable Diffusion inference on iOS and macOS using Swift and Apple's MPSGraph framework, eliminating the need for Python environments. It offers a simple, flexible API for developers targeting Apple platforms, allowing for image generation and image-to-image transformations with minimal setup.
How It Works
This project leverages MPSGraph, Apple's Metal Performance Shaders Graph API, to execute Stable Diffusion models natively on Apple silicon. It converts standard .ckpt
model files into a memory-optimized format, utilizing FP16 tensors and operator fusion for efficient execution. This approach aims for performance comparable to or exceeding cloud-based solutions while ensuring a seamless, zero-dependency user experience on end-user devices.
Quick Start & Requirements
https://github.com/mortenjust/native-diffusion
to Xcode's Swift Package Manager.torch
, typing_extensions
, numpy
, Pillow
, requests
, and pytorch_lightning
is required for model conversion.maple-convert.py
) is provided to convert .ckpt
files to the native format.Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
2 years ago
1 day