DCAI
Loading Light/Dark Toggl

Generate high quality images using Negative Embedding (Textual Inversion)

⏱️7min read
📅 Apr 24, 2024
🔄 Jul 26, 2024
Category:📂 Novice
Generate high quality images using Negative Embedding (Textual Inversion) featured Image
Supported by

What is Negative Embedding (Textual Inversion)?

Negative Embedding (Textual Inversion) is one of the techniques used to help computers understand the meaning of words. Normally, a computer understands a word as a collection of numbers, or vector. This vector represents the meaning or relevance of the word.

For instance, suppose we have the word “dog”. The computer represents “dog” as a certain vector and thereby understands that “dog” is an animal, a pet, etc. However, in Negative Embedding, this vector of “dog” is reversed. The computer then starts looking for concepts that are the opposite or opposite of “dog”. In other words, it can find other animals that are not “dogs,” such as “cats” or “birds.

This technique is especially useful in situations that require a deeper understanding of the meaning of the words. For example, when analyzing a text to find conflicting ideas or emotions within it. However, this method is not yet perfect and the computer may find wrong associations. So, care should be taken when using it.

It may be difficult for beginners to understand such a complex technology, but in short, we hope you can think of Negative Embedding (Textual Inversion) as a tool to invert the meaning of words to find new perspectives and associations. It is an interesting technique, and if you want to learn more, you may want to look into word embedding models such as Word2Vec and GloVe. These are basic tools for representing word meanings as vectors.

PR
Image of GIGABYTE - AORUS 17 (2024) Gaming Laptop - 240Hz 2560x1440 QHD - NVIDIA GeForce RTX 4070 - Intel Ultra 7 155H - 1TB SSD with 16GB DDR5 RAM - Windows 11 Home AD (AORUS 17 BSG-13US654SH)
GIGABYTE - AORUS 17 (2024) Gaming Laptop - 240Hz 2560x1440 QHD - NVIDIA GeForce RTX 4070 - Intel Ultra 7 155H - 1TB SSD with 16GB DDR5 RAM - Windows 11 Home AD (AORUS 17 BSG-13US654SH)
🔗Amazon-Usa Link
Image of Seasonic Focus V4 GX-1000 (ATX3) -1000W -80+ Gold -Full-Modular -ATX Form Factor -Premium Japanese Capacitor -10 Year Warranty -Nvidia RTX 30/40 Super & AMD GPU Compatible -Focus V4 GX-1000 (ATX3)
Seasonic Focus V4 GX-1000 (ATX3) -1000W -80+ Gold -Full-Modular -ATX Form Factor -Premium Japanese Capacitor -10 Year Warranty -Nvidia RTX 30/40 Super & AMD GPU Compatible -Focus V4 GX-1000 (ATX3)
🔗Amazon-Usa Link

How to install Negative Embedding (Textual Inversion)

Move the downloaded file to the \stable-diffusion-webui\embeddings folder.

Folder of stable-diffusion-webui
In the folder, we have placed a Place Textual Inversion embeddings here.txt file.
Open Image
  1. Open the browser in the Web UI and open the “Textual Inversion” in the Generated Parameters area.
  2. Press the Refresh button to the right to see the file in the list.
State after reloading Textual Inversion
“EasyNegative” is loaded.
Open Image

If SD1.5 is selected as the checkpoint model, the only models displayed are those suitable for SD1.5. Please note that other models (SDXL) will not be displayed.

How to use Negative Embedding (Textual Inversion)

First, open the “Textual Inversion” page. If you want to apply a negative prompt, click on the position where you want to insert the negative prompt and select the Negative Embedding you want to apply from the list, and its name will appear in the negative prompt input field.

If you wish to cancel the adaptation, you can do so by selecting Negative Embedding again.

Comparative images of EasyNegative
Comparative images when EasyNegative is applied
Open Image

Negative Embedding (Textual Inversion) weighting adjustment

To adjust the weight (strength) of Negative Embedding, perform the following steps

  1. Select a name for the negative prompt input field.
  2. The weights can be increased or decreased by holding down the Ctrl key and pressing the or key (arrow keys).
Example:
 (EasyNegative:1.2)

In the above example, this means that “EasyNegative” is applied at 1.2x weighting.

How to use the UI for Negative Embedding (Textual Inversion)

Model Search: If you want to search for a model, enter it here.
Sort by path: Sort the model list by file path.
Sort by name: Sort the model list by file name.
Sort by creation date: Sort the model list by file creation date.
Sorted by update date: Sort the model list by the date the file was last updated.
Sort in descending or ascending order: Sort the model list in descending or ascending order.
Tree view switching: If you have further folders within the \stable-diffusion-webui\embeddings folder, you can activate this button to switch to the tree view.
Explanatory image of tree view
Example of display when EasyNegative is placed in the SD15 folder
Open Image
Model update: Updates the list on the “Textual Inversion” page. Use this page when you add a new model, or after switching the base model from SD1.5 to SDXL.

How to Edit Metadata for Negative Embedding (Textual Inversion) Models

Basically, you do not need to include any metadata. However, as the number of models increases, it becomes difficult to understand what kind of models they are, so we store descriptions of the models as metadata.

Move the mouse over the model you want to edit from the list, and the mark will appear in the upper right corner.

  1. Description: Enter a description of the metadata.
  2. Thumbnail: Thumbnails of metadata are displayed.
  3. Notes: Metadata notes and other information will be included.
  4. Replace preview: Use this when you want to update metadata thumbnails.

How to update metadata thumbnails

Generate images with models in portrait (SD1.5 -> 512×768/ SDXL -> 768×1344) with txt2img.

Once the image you want to use as a thumbnail has been generated, open the model edit screen on the “Textual Inversion” page.

Press “Replace preview” to replace the image with the one you just generated.

If you want to remove the thumbnails, you can find the model name.preview.png in the \stable-diffusion-webui\embeddings folder and delete the PNG image to restore the initial state.

Conclusion

In this article, we have explained Negative Embedding (Textual Inversion); please try using Negative Embedding as it improves the quality of text generation. Also, please select an appropriate model, taking into consideration its compatibility with the checkpoint model.

We will be compiling a separate article on the recommended models, so please refer to that as well. Thank you for reading to the end.

PR
Image of GIGABYTE GeForce RTX 4080 Super WINDFORCE V2 16G Graphics Card, 3X WINDFORCE Fans, 16GB 256-bit GDDR6X, GV-N408SWF3V2-16GD Video Card
GIGABYTE GeForce RTX 4080 Super WINDFORCE V2 16G Graphics Card, 3X WINDFORCE Fans, 16GB 256-bit GDDR6X, GV-N408SWF3V2-16GD Video Card
🔗Amazon-Usa Link
Image of MSI Gaming RTX 4070 Ti Super 16G Gaming X Slim Graphics Card (NVIDIA RTX 4070 Ti Super, 256-Bit, Extreme Clock: 2685 MHz, 16GB GDRR6X 21 Gbps, HDMI/DP, Ada Lovelace Architecture)
MSI Gaming RTX 4070 Ti Super 16G Gaming X Slim Graphics Card (NVIDIA RTX 4070 Ti Super, 256-Bit, Extreme Clock: 2685 MHz, 16GB GDRR6X 21 Gbps, HDMI/DP, Ada Lovelace Architecture)
🔗Amazon-Usa Link
Supported by