Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Using Stable Diffusion with Python
  • Table Of Contents Toc
  • Feedback & Rating feedback
Using Stable Diffusion with Python

Using Stable Diffusion with Python

By : Andrew Zhu (Shudong Zhu)
4.8 (5)
close
close
Using Stable Diffusion with Python

Using Stable Diffusion with Python

4.8 (5)
By: Andrew Zhu (Shudong Zhu)

Overview of this book

Stable Diffusion is a game-changing AI tool that enables you to create stunning images with code. The author, a seasoned Microsoft applied data scientist and contributor to the Hugging Face Diffusers library, leverages his 15+ years of experience to help you master Stable Diffusion by understanding the underlying concepts and techniques. You’ll be introduced to Stable Diffusion, grasp the theory behind diffusion models, set up your environment, and generate your first image using diffusers. You'll optimize performance, leverage custom models, and integrate community-shared resources like LoRAs, textual inversion, and ControlNet to enhance your creations. Covering techniques such as face restoration, image upscaling, and image restoration, you’ll focus on unlocking prompt limitations, scheduled prompt parsing, and weighted prompts to create a fully customized and industry-level Stable Diffusion app. This book also looks into real-world applications in medical imaging, remote sensing, and photo enhancement. Finally, you'll gain insights into extracting generation data, ensuring data persistence, and leveraging AI models like BLIP for image description extraction. By the end of this book, you'll be able to use Python to generate and edit images and leverage solutions to build Stable Diffusion apps for your business and users.
Table of Contents (29 chapters)
close
close
Free Chapter
1
Part 1 – A Whirlwind of Stable Diffusion
In Progress | 0 / 1 sections completed | 0%
8
Part 2 – Improving Diffusers with Custom Features
In Progress | 0 / 1 sections completed | 0%
11
Chapter 9: Using Textual Inversion
In Progress | 0 / 6 sections completed | 0%
15
Part 3 – Advanced Topics
In Progress | 0 / 1 sections completed | 0%
19
Chapter 16: Exploring Stable Diffusion XL
In Progress | 0 / 5 sections completed | 0%
20
Chapter 17: Building Optimized Prompts for Stable Diffusion
In Progress | 0 / 5 sections completed | 0%
21
Part 4 – Building Stable Diffusion into an Application
In Progress | 0 / 1 sections completed | 0%
22
Chapter 18: Applications – Object Editing and Style Transferring
In Progress | 0 / 5 sections completed | 0%
27
Index
In Progress | 0 / 2 sections completed | 0%

Overcoming the 77-token limitation using community pipelines

Implementing a pipeline supporting long prompt weighting from scratch can be challenging. Often, we simply wish to utilize Diffusers to generate images using detailed and nuanced prompts. Fortunately, the open source community has provided implementations for SD v1.5 and SDXL. The SDXL implementation was originally initialized by Andrew Zhu, the author of this book, and massively improved by the community.

I’ll now provide two examples of how to use the community pipeline for SD v1.5 and SDXL:

  1. This example uses the lpw_stable_diffusion pipeline for SD v1.5.

    Use the following code to start a long prompt weighted pipeline:

    from diffusers import DiffusionPipeline
    import torch
    model_id_or_path = "stablediffusionapi/deliberate-v2"
    pipe = DiffusionPipeline.from_pretrained(
        model_id_or_path,
        torch_dtype = torch.float16,
        custom_pipeline =...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY