AI Painting Stable Diffusion Research (15) SD Embedding Detailed Explanation


Hello everyone, I am rain or shine.

Contents of this issue:

  • What is Embedding?
  • What is the role of Embedding?
  • How to download and install Embedding?
  • How to use Embedding?

Do you still remember Stable Diffusion Research in AI Painting (7) Read the article to understand the working principle of Stable Diffusion In this article, did you mention word embedding (Embedding)?


Let's briefly review: Embedding converts the input tokens into a continuous vector, and then stable diffusion converts the Embedding vector text transformeras a model input for training.


In the previous article, Embedding was only briefly mentioned. In our actual use of stable diffusion, many friends may not be very clear about the concept of Embedding. Today we will introduce Embedding in detail. What exactly does it do? what's the effect? And how to install and use Embedding?


1. Introduction to Embedding


1. What is Embedding?


Embedding also known as textual inversion Chinese name: "embedding or text inversion".

In computer science, Embedding is the process of mapping high-dimensional data to a low-dimensional space.

In image processing, Embedding is often used to convert images into vector representations for machine learning and deep learning tasks.


When using stable diffusion for painting, Embedding can be used to convert the input image into a vector representation, so that the algorithm can process it and generate a new image. This technique could allow algorithms to process image data more efficiently and improve the quality and accuracy of the resulting images.


2. What is the function of Embedding?


In layman's terms, the function of Embedding is to package the prompt words.

If you have experience in UI, you should know the concept of components.

In Stable Diffusion, Embedding technology can be understood as a component that converts input data into a vector representation to facilitate model processing and generation.

In daily use, Embedding technology is usually used to control the actions and characteristics of characters, or to generate a specific style of painting.


Let's take an example and consider a question:

If we directly use the original version of the stable diffusion Vinson diagram function without using any stable diffusion plug-ins, how should we generate the following pictures?


insert image description here


Presumably the first thing everyone thinks of is to write a lot of prompt words to control generation, similar to for example:

masterpiece, high-quality,1girl,clothes with Pink pattern,(brown hair), pinkearphones, green pattern on the earphones, blue tights, white gloves, ((pinkpattern on the clothes)), cat pattern on the face, detailed eyes, (pink theme), rabbitdecoration on the chest, green word pattern, sewing line on the clothes, long hair.thin girl, delicate face, beautiful face, melon face, skin full of details, pinkbackground, white gloves, thin neck, Sexy figure, (brown eyes:1.2), smile, wearingwhite shoes, green patterns, blushing,.....以下省略N个tag

However, if we introduce Embedding, we only need the following prompt words to generate the above picture:

 masterpiece, high-quality,corneo dva

Through the above questions, I believe that everyone has already understood the role of Embedding.


3. Features of Embedding


Compared with other models (such as LORA), the size of the Embedding file is only tens of KB.

Except that the reduction degree is worse than that of LORA, it is more convenient in storage and use.


all in all:

Embedding technology converts input data into vector representation, which facilitates the processing and generation of models.

By using Embedding, we can more easily generate expected samples without manually entering a large number of descriptive words.


2. Embedding download and installation


Since Embedding is so convenient, we must use it well, so where can I download it?

It is mainly downloaded at station c .

Next, just follow my demonstration steps and actually operate it.


The first step is to open station c and search for Embedding


insert image description here


The second step is to choose your favorite Embedding to download


Here is a demonstration, we choose this alien on horseback, click "Download" to download:

insert image description here


After downloading, we get the file 16-token-negative-deliberate-neg.pt.


The third step Embedding installation


Copy the file 16-token-negative-deliberate-neg.pt to the sd-webui-aki-v4.2\embeddings directory.


\sd-webui-aki-v4.2\embeddings

insert image description here

Remember to restart stable diffusion to take effect.


3. The use of Embedding


1. In the function bar area, select the Vincent diagram, and then select the "Show/Hide Extended Model" icon under the generate button on the right


As shown in the picture:

insert image description here


Switch to the Embedded (Enbedding) tab page:

insert image description here


2. Set according to the parameters of the Enbedding model demonstration picture


  • Forward prompt word input

    an astronaut riding a horse on the moon, 8k uhd
    

  • Reverse prompt word input

    3d render
    

  • Select the Enbedding just installed below: 16-token-negative-deliberate-neg

insert image description here


The 16-token-negative-deliberate-neg model prompt word will be automatically added to the negative prompt word input box


As shown in the picture:

insert image description here


  • Sampling method settings: Euler

  • Iteration steps setting: 50

  • Tick ​​HD Resolution Repair

  • Random seed setting: 43


insert image description here


4. Click the "Generate" button to view the effect


insert image description here


It can be seen that Embedding is really a very useful tool. Through a simple prompt word, you can create a work with your own characteristics. Interested friends, let’s play it~


Guess you like

Origin blog.csdn.net/lizhong2008/article/details/132483369