Let’s install the topical image generation AI in your apps and services ~ Use Stable Diffusion on iPhone and Macbook ~
Install image generation AI in your app
Image generation AI ( AI that generates images from text ) is a hot topic right now , but it would be nice if you could quickly incorporate it into your own app and use it for your service .
For example, you can automatically generate user profile icons and header images.
But how should we adopt AI?
In fact, you can include it in apps for Mac, iPhone, and iPad .
This way, you don’t need to prepare a server, you can generate images on the user’s device, so you can easily incorporate it into the service.
If you want to try it as a sample app, it is uploaded to the AppStore, so you can download it.
Diffusers is a native Mac app to generate images from a text description of what you want. It uses state-of-the-art…
How to use image generation AI in iPhone / Mac application
To include image generation AI in your app, convert it to a format called CoreML.
Apple has provided a CoreML version of their image generation AI Stable Diffusion. Use this.
GitHub - apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon
Run Stable Diffusion on Apple Silicon with Core ML This repository comprises: python_coreml_stable_diffusion, a Python…
Download and run the sample project provided by HuggingFace.
GitHub - huggingface/swift-coreml-diffusers: Swift app demonstrating Core ML Stable Diffusion
This is a native app that shows how to integrate Apple's Core ML Stable Diffusion implementation in a native Swift UI…
You can generate an image by entering text and pressing the Generate button.
You can choose from several versions of the image generation model.
There is also an on/off function for SafetyCheck, which blocks adult and harmful content.
How to import into your own app
You can easily add the AI image generation function by extracting the code of the CoreML model download part and the AI execution part of the sample application and importing them into your own application.
Below, the input text is vectorized with the textEncoder model.
let promptEmbedding = try textEncoder.encode(prompt)
let negativePromptEmbedding = try textEncoder.encode(negativePrompt)
Generate noise from Latent and text vectors in UNet.
var noise = try unet.predictNoise(
Finally, generate the image with the image generation model.
try decodeToImages(latents, disableSafety: disableSafety)
I am a freelance engineer.
If you have any of the following requests, please feel free to contact us.
I want to develop AI services, I want to incorporate AI into my business to make it more efficient, I want to develop a smartphone app that uses AI, I want to create an
application that uses AR, I want to create a smartphone app but I don’t know who to consult, image generation AI, etc. I want to use ChatGPT for my own service…
All of them can be ordered at a reasonable price without intermediate costs.
For work inquiries, please contact
I am creating applications using machine learning and AR technology.
I send machine learning / AR related information.