{"id":13905048,"url":"https://github.com/andrei-zgirvaci/expo-stable-diffusion","last_synced_at":"2025-06-24T07:10:55.943Z","repository":{"id":185548274,"uuid":"673697360","full_name":"andrei-zgirvaci/expo-stable-diffusion","owner":"andrei-zgirvaci","description":"Run Stable Diffusion using Core ML on iOS within your Expo \u0026 React Native App","archived":false,"fork":false,"pushed_at":"2024-05-30T16:20:50.000Z","size":803,"stargazers_count":205,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-10T00:28:44.777Z","etag":null,"topics":["ai","ane","apple","apple-silicon","coreml","expo","expo-modules","ios","ipad","ipados","iphone","neural-engine","react-native","stable-diffusion","swift"],"latest_commit_sha":null,"homepage":"https://andreizgirvaci.com/blog/how-to-create-ai-generated-images-on-ios-in-react-native-using-stable-diffusion","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrei-zgirvaci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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,"publiccode":null,"codemeta":null},"funding":{"github":"andrei-zgirvaci"}},"created_at":"2023-08-02T08:11:06.000Z","updated_at":"2025-06-03T07:51:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"d07312b9-b049-473b-8741-9e7557960fe2","html_url":"https://github.com/andrei-zgirvaci/expo-stable-diffusion","commit_stats":null,"previous_names":["andrei-zgirvaci/expo-stable-diffusion"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/andrei-zgirvaci/expo-stable-diffusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-zgirvaci%2Fexpo-stable-diffusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-zgirvaci%2Fexpo-stable-diffusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-zgirvaci%2Fexpo-stable-diffusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-zgirvaci%2Fexpo-stable-diffusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrei-zgirvaci","download_url":"https://codeload.github.com/andrei-zgirvaci/expo-stable-diffusion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrei-zgirvaci%2Fexpo-stable-diffusion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261624969,"owners_count":23186121,"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":["ai","ane","apple","apple-silicon","coreml","expo","expo-modules","ios","ipad","ipados","iphone","neural-engine","react-native","stable-diffusion","swift"],"created_at":"2024-08-06T23:01:09.053Z","updated_at":"2025-06-24T07:10:55.903Z","avatar_url":"https://github.com/andrei-zgirvaci.png","language":"Swift","funding_links":["https://github.com/sponsors/andrei-zgirvaci","https://ko-fi.com/andrei_zgirvaci"],"categories":["HarmonyOS","Swift"],"sub_categories":["Windows Manager"],"readme":"# expo-stable-diffusion\n\n![GitHub last commit](https://img.shields.io/github/last-commit/andrei-zgirvaci/expo-stable-diffusion)\n![npm](https://img.shields.io/npm/v/expo-stable-diffusion)\n![GitHub issues](https://img.shields.io/github/issues/andrei-zgirvaci/expo-stable-diffusion)\n![GitHub stars](https://img.shields.io/github/stars/andrei-zgirvaci/expo-stable-diffusion)\n[![GitHub Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/andrei-zgirvaci)\n\n**_Have you ever wondered if it's possible to generate images using Stable Diffusion natively on your iPhone or iPad while taking advantage of Core ML in an Expo and React Native app?_**\n\nWell, now you can!\n\n![](https://i.imgur.com/1KaxBff.jpg)\n\n\u003e 💡 [Read The Full Detailed Guide](https://andreizgirvaci.com/blog/how-to-create-ai-generated-images-on-ios-in-react-native-using-stable-diffusion)\n\n## Good to Know\n\n\u003e ❗️ `expo-stable-diffusion` currently only works on iOS due to the platform's ability to run Stable Diffusion models on [Apple Neural Engine](https://github.com/hollance/neural-engine)!\n\n\u003e ❗️ This package is not included in the **Expo Go**. You will have to use a [Development Build](https://docs.expo.dev/develop/development-builds/introduction) or build it locally using Xcode!\n\n## Getting Started\n\nStart by installing the `expo-stable-diffusion` module into your Expo managed project:\n\n```bash\nnpx expo install expo-stable-diffusion\n```\n\n## Configuration\n\n### Update iOS Deployment Target\n\nIn order for the project to build successfully, you have to set the iOS Deployment Target to `16.2`. You can achieve this by installing the `expo-build-properties` plugin:\n\n```bash\nnpx expo install expo-build-properties\n```\n\nConfigure the plugin by adding the following to your `app.json`:\n\n```json\n{\n  \"expo\": {\n    \"plugins\": [\n      [\n        \"expo-build-properties\",\n        {\n          \"ios\": {\n            \"deploymentTarget\": \"16.2\"\n          }\n        }\n      ]\n    ]\n  }\n}\n```\n\n### Enable Increased Memory Limit\n\nTo prevent memory issues, add the [Increased Memory Limit](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_increased-memory-limit) capability to your iOS project. Add the following to your `app.json`:\n\n```json\n{\n  \"expo\": {\n    \"ios\": {\n      \"entitlements\": {\n        \"com.apple.developer.kernel.increased-memory-limit\": true\n      }\n    }\n  }\n}\n```\n\n### Build Your iOS App\n\n```bash\nnpx expo prebuild --clean --platform ios\nnpx expo run:ios\n```\n\n## Usage\n\nAfter installation and configuration, you can start generating images using `expo-stable-diffusion`. Here's a basic example:\n\n```typescript\nimport * as FileSystem from 'expo-file-system';\nimport * as ExpoStableDiffusion from 'expo-stable-diffusion';\n\nconst MODEL_PATH = FileSystem.documentDirectory + 'Model/stable-diffusion-2-1';\nconst SAVE_PATH = FileSystem.documentDirectory + 'image.jpeg';\n\nawait ExpoStableDiffusion.loadModel(MODEL_PATH);\n\nconst subscription = ExpoStableDiffusion.addStepListener(({ step }) =\u003e {\n  console.log(`Current Step: ${step}`);\n});\n\nawait ExpoStableDiffusion.generateImage({\n  prompt: 'a cat coding at night',\n  stepCount: 25,\n  savePath: SAVE_PATH,\n});\n\nsubscription.remove();\n```\n\n\u003e 💡 If you are saving the image in a custom directory, make sure the directory exists. You can create a directory by calling the [`FileSystem.makeDirectoryAsync(fileUri, options)`](https://docs.expo.dev/versions/latest/sdk/filesystem/#filesystemmakedirectoryasyncfileuri-options) function from `expo-file-system`.\n\n## Obtaining Stable Diffusion Models\n\nTo use the `expo-stable-diffusion` module, you need a converted Core ML Stable Diffusion model. You can convert your own model using [Apple's official guide](https://github.com/apple/ml-stable-diffusion#-converting-models-to-core-ml) or download pre-converted models from [Apple's Hugging Face repository](https://huggingface.co/apple) or [my Hugging Face repository](https://huggingface.co/andrei-zgirvaci/coreml-stable-diffusion-2-1-split-einsum-v2-txt2img).\n\n## Troubleshooting\n\n\u003e ❗️ The model load time and image generation duration take some time, especially on devices with lower RAM than 6GB! Find more information in **Q6** in the **FAQ** section of the [ml-stable-diffusion](https://github.com/apple/ml-stable-diffusion#-faq) repo.\n\n\u003e [Running Stable Diffusion on Lower-End Devices](https://andreizgirvaci.com/blog/how-to-create-ai-generated-images-on-ios-in-react-native-using-stable-diffusion#running-stable-diffusion-on-lower-end-devices)\n\n\u003e [failed to load ANE model](https://github.com/apple/ml-stable-diffusion/issues/51)\n\n## Sponsorship 🩷\n\n**I am looking for at least $1,000 in sponsorship so that I can go full-time into building this project.**\n\nCurrently, I dedicate my spare time to the development of this library. Please consider [supporting this project](https://ko-fi.com/andrei_zgirvaci) if you find `expo-stable-diffusion` helpful or if you are using it in a production-ready app. This will motivate me to work on improving it and adding new features like Android support!\n\nIn case you need premium guidance on integrating `expo-stable-diffusion` into your own project, bugfixes or any other help, feel free to [contact me](mailto:me@andreizgirvaci.com?subject=Integrating%20expo-stable-diffusion%20in%20my%20app). I will be happy to help!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei-zgirvaci%2Fexpo-stable-diffusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrei-zgirvaci%2Fexpo-stable-diffusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei-zgirvaci%2Fexpo-stable-diffusion/lists"}