Diffusion models validated for Unity
Collection
Diffusion models validated to run in Unity with tools.doji.diffusers (Unity Inference Engine). โข 8 items โข Updated
This is an unofficial conversion of Stable Diffusion 2.1 (stabilityai/stable-diffusion-2-1) by Stability AI, for Unity Inference Engine and the Unity package tools.doji.diffusers. The pipeline components are converted to ONNX, with float32 weights. The original license terms apply.
The files take 4.81 GiB.
Add julienkay/stable-diffusion-2-1 to the project in Window > AI Model Hub, then:
using Doji.AI.Diffusers;
using UnityEngine;
using var pipeline = await AutoPipelineForText2Image.FromPretrainedAsync("julienkay/stable-diffusion-2-1");
using var output = await pipeline.GenerateAsync(new Text2ImageParameters {
Prompt = "a cat",
});
Texture2D texture = output.ToTexture();
output.SaveAsPng("cat.png");
output owns the image tensor: dispose it when done. ToTexture and SaveAsPng take the index of an image in the batch, 0 by default. Since tools.doji.diffusers 0.4, Prompt also takes a List<string> or a string[] for a batch of prompts.
Base model
stabilityai/stable-diffusion-2-1