Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 59486be

Browse files
committed
Move SD content to SD README
1 parent d8bf0ce commit 59486be

File tree

1 file changed

+112
-1
lines changed

1 file changed

+112
-1
lines changed

OnnxStack.StableDiffusion/README.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,115 @@ Each model can be assigned to its own device, which is handy if you have only a
224224
]
225225
}
226226
}
227-
```
227+
```
228+
229+
### **Prompt**
230+
231+
Stable Diffusion models take a text prompt and create an image that represents the text.
232+
233+
*Example:*
234+
`
235+
High-fashion photography in an abandoned industrial warehouse, with dramatic lighting and edgy outfits, detailed clothing, intricate clothing, seductive pose, action pose, motion, beautiful digital artwork, atmospheric, warm sunlight, photography, neo noir, bokeh, beautiful dramatic lighting, shallow depth of field, photorealism, volumetric lighting, Ultra HD, raytracing, studio quality, octane render
236+
`
237+
238+
### **Negative Prompt**
239+
240+
A negative prompt can be provided to guide the inference to exclude in calculations
241+
242+
*Example:*
243+
244+
`
245+
painting, drawing, sketches, monochrome, grayscale, illustration, anime, cartoon, graphic, text, crayon, graphite, abstract, easynegative, low quality, normal quality, worst quality, lowres, close up, cropped, out of frame, jpeg artifacts, duplicate, morbid, mutilated, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, glitch, deformed, mutated, cross-eyed, ugly, dehydrated, bad anatomy, bad proportions, gross proportions, cloned face, disfigured, malformed limbs, missing arms, missing legs fused fingers, too many fingers,extra fingers, extra limbs,, extra arms, extra legs,disfigured,
246+
`
247+
248+
### **Schedulers**
249+
250+
Many different scheduler algorithms can be used for this computation, each having its pro- and cons.
251+
So far `OnnxStack.StableDiffusion` as included `LMS Discrete`, `Euler Ancestral`, `DDPM`, `DDIM`, and `KDPM2` options with more in the works.
252+
253+
*Example:*
254+
| LMS Scheduler | Euler Ancestral Scheduler | DDPM Scheduler |
255+
| :--- | :--- | :--- |
256+
<img src="../Assets/Samples/624461087_22_8_LMSScheduler.png" width="256" alt="Image of browser inferencing on sample images."/> | <img src="../Assets/Samples/624461087_22_8_EulerAncestralScheduler.png" width="256" alt="Image of browser inferencing on sample images."/> |<img src="../Assets/Samples/624461087_22_8_DDPMScheduler.png" width="256" alt="Image of browser inferencing on sample images."/> |
257+
258+
Seed: 624461087 GuidanceScale: 8 NumInferenceSteps: 22
259+
260+
### **Text To Image**
261+
Text To Image Stable Diffusion is a powerful machine learning technique that allows you to generate high-quality images from textual descriptions. It combines the capabilities of text understanding and image synthesis to convert natural language descriptions into visually coherent and meaningful images
262+
263+
| Input Text | Output Image | Diffusion Steps |
264+
| :--- | :--- | :--- |
265+
<img src="../Assets/Samples/Text2Img_Start.png" width="256" alt="Image of browser inferencing on sample images."/> | <img src="../Assets/Samples/Text2Img_End.png" width="256" alt="Image of browser inferencing on sample images."/> |<img src="../Assets/Samples/Text2Img_Animation.webp" width="256" alt="Image of browser inferencing on sample images."/> |
266+
267+
### **Image To Image**
268+
Image To Image Stable Diffusion is an advanced image processing and generation method that excels in transforming one image into another while preserving the visual quality and structure of the original content. Using stable diffusion, this technique can perform a wide range of image-to-image tasks, such as style transfer, super-resolution, colorization, and more
269+
270+
| Input Image | Output Image | Diffusion Steps |
271+
| :--- | :--- | :--- |
272+
<img src="../Assets/Samples/Img2Img_Start.bmp" width="256" alt="Image of browser inferencing on sample images."/> | <img src="../Assets/Samples/Img2Img_End.png" width="256" alt="Image of browser inferencing on sample images."/> |<img src="../../Assets/Samples/Img2Img_Animation.webp" width="256" alt="Image of browser inferencing on sample images."/> |
273+
274+
```
275+
Prompt: Dog wearing storm trooper helmet, head shot
276+
```
277+
278+
### **Image Inpainting**
279+
Image inpainting is an image modification/restoration technique that intelligently fills in missing or damaged portions of an image while maintaining visual consistency. It's used for tasks like photo restoration and object removal, creating seamless and convincing results.
280+
281+
In the below example we use a simple mask image + prompt to add a rider to the horse
282+
The black part of the mask will be used buy the process to generate new content, in this case the rider
283+
284+
| Input Image | Mask Image | Masked Image | Result
285+
| :--- | :--- | :--- | :--- |
286+
<img src="../Assets/Samples/Inpaint-Original.png" width="256" alt="Image of browser inferencing on sample images."/> | <img src="../Assets/Samples/Inpaint-Mask.png" width="256" alt="Image of browser inferencing on sample images."/> |<img src="../Assets/Samples/Inpaint-MaskedImage.PNG" width="256" alt="Image of browser inferencing on sample images."/> |<img src="../Assets/Samples/Inpaint-Result.png" width="256" alt="Image of browser inferencing on sample images."/> |
287+
288+
```
289+
Prompt: Rider on horse
290+
```
291+
292+
293+
## **Realtime Stable Diffusion**
294+
Realtime stable diffusion is a process where the results are constantly rendered as you are working with the image or changing the settings, This can be fantastic if you are creating new artworks or editing existing images.
295+
296+
Performance will depend on hardware and models selected, but for `Latent Consistency Models` you can get up to 4fps with a 3090 :)
297+
298+
### Text To Image
299+
https://user-images.githubusercontent.com/4353684/285347887-99db7f37-cff4-48b6-805b-3ca55e8f0c3a.mp4
300+
301+
### Image To Image
302+
https://user-images.githubusercontent.com/4353684/285348410-c19a2111-6745-4f01-8400-d137d40180fe.mp4
303+
304+
### Image Inpaint
305+
https://user-images.githubusercontent.com/4353684/285347894-9d044d7d-7c22-4379-8187-9cf7b9cac89c.mp4
306+
307+
### Paint To Image
308+
https://user-images.githubusercontent.com/4353684/285347896-8da6709b-fea6-4cd4-ba65-ec692401f475.mp4
309+
310+
https://user-images.githubusercontent.com/4353684/285547207-3a7ea067-fcbf-47f0-9372-fafa94d301f7.mp4
311+
312+
313+
314+
## ONNX Model Download
315+
You will need an ONNX compatible model to use, Hugging Face is a great place to download the Stable Diffusion models
316+
317+
Download the [ONNX Stable Diffusion models from Hugging Face](https://huggingface.co/models?sort=downloads&search=Stable+Diffusion).
318+
319+
- [Stable Diffusion Models v1.4](https://huggingface.co/CompVis/stable-diffusion-v1-4/tree/onnx)
320+
- [Stable Diffusion Models v1.5](https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/onnx)
321+
322+
323+
Once you have selected a model version repo, click `Files and Versions`, then select the `ONNX` branch. If there isn't an ONNX model branch available, use the `main` branch and convert it to ONNX. See the [ONNX conversion tutorial for PyTorch](https://learn.microsoft.com/windows/ai/windows-ml/tutorials/pytorch-convert-model) for more information.
324+
325+
Clone the model repo:
326+
```text
327+
git lfs install
328+
git clone https://huggingface.co/runwayml/stable-diffusion-v1-5 -b onnx
329+
```
330+
331+
332+
## Resources
333+
- [Hugging Face Stable Diffusion Blog](https://huggingface.co/blog/stable_diffusion)
334+
- [ONNX Runtime tutorial for Stable Diffusion in C#](https://onnxruntime.ai/docs/tutorials/csharp/stable-diffusion-csharp.html)
335+
336+
337+
## Reference
338+
This work is based on the original C# implementation of Stable Diffusion by Cassie Breviu here: [Stable Diffusion with C# and ONNX Runtime](https://github.com/cassiebreviu/stablediffusion).

0 commit comments

Comments
 (0)