Home

Awesome

sd-model-preview-xd

Extension for Automatic1111 Stable Diffusion WebUI to display previews for custom models1.

About

With so many new models appearing it's becoming harder to keep track of what models output what styles and what tags are used to call these styles. This extension allows you to create various types of preview files/notes2, each with the same name as your model and have this info easily displayed for later reference in webui.

Installation

  1. From the extensions tab in web ui click install from url
  2. Paste https://github.com/CurtisDS/sd-model-preview-xd into the url box.
  3. Click Install
  4. From the Installed tab click apply and restart3.
  5. Put .html4, .md4, .txt, .png, .webp, .jpg/.jpeg, .prompt5, .tags6, and/or .civitai.info7 files in the same directory as your models, or a subfolder. Make sure to name the files the same as your model. You may append something after the name of the model and it will still work (See: Name Matching Rules). You can have multiple images for a single model, but only one markdown, text, civitai.info or html file. You can also mix and match any of the preview files except for HTML and civitai.info files, if the extension finds either file it will only show that output (html files have priority).

Note: If you are using symlinks or otherwise changing the default model directories click here for information

For example if you have my_model.ckpt in models\Stable-diffusion then you can put my_model.txt, my_model_1.jpg and, my_model_2.jpg in models\Stable-diffusion\Previews and it will display them in the "Model Preview" tab.

This extension supports the following model types in the the default directories:

Usage

  1. After creating the preview files and putting them in the corresponding directories, select the Model Preview tab in web ui and then the type of model you want to preview
  2. Select a model from the dropdown list. (If the model has any preview files they will be shown)
  3. Any preview png files found that also contain prompt data embedded in them will have a red "copy" button when hovering over the image. By clicking the button it will copy the prompt data to your clipboard.
  4. If you would like to filter the list of models enter text in the filter text box. The filter text will be separated by commas and return models who have that text anywhere in its name or its associated .tags6 file.

screenshot

Tips

  1. <a name="tips-1"></a>You can save the README.md file from a models huggingface page to use as your model preview:

    screenshot of markdown example

  2. <a name="tips-2"></a>You can save the model's Civitai page (using <kbd>Ctrl</kbd>+<kbd>S</kbd> in your browser) to use the Civitai page as your model preview:

    screenshot of html example

  3. <a name="tips-3"></a>If you want to keep it clean, create a simple .txt file with the trigger words and save a few sample images:

    screenshot of text and images example

  4. <a name="tips-4"></a>You can now be linked directly to the preview files of a model by clicking on the in the extra networks thumbnail cards.

    image

    Depending on the size setting for the extra network cards you might not be able to see this button. These are the settings I suggest:

    image

  5. <a name="tips-5"></a>In the settings for the extension you can turn off the limit height setting to change how tall the preview panel can be.

    screenshot of difference between limit height and not limit height

  6. <a name="tips-6"></a>If the image previews are too small or too big for you, add the following css to your user.css file (If the file doesn't exist then create it in the root of your Automatic1111 folder). Edit the width and height values accordingly:

    /* custom CSS for sd-model-preview-xd preview image sizes */
    #tab_modelpreview_xd_interface .modelpreview_xd_html_div .img-container-set .img-container {
          /* default width and height */
          width: 293px;
          height: 294px;
    }
    
    @media (max-height: 1000px), (max-width: 1300px) {
          /* intended to shrink the images when the height or width of the browser window is less than 1000px or 1300px respectively */
          #tab_modelpreview_xd_interface .modelpreview_xd_html_div .img-container-set .img-container {
                width: 193px;
                height: 194px;
          }
    }
    

Things to watch out for

Name Matching Rules

In the settings tab there is a page for Model Preview XD where you can update the setting to use "Strict", "Loose", "Folder", or "Index" naming. Depending on that setting the rules for naming preview files will be slightly different.

Changing Default Directories

Gradio (the software Automatic1111 is built on) doesn't support linking to files outside of the Automatic1111 install directory through the webui. So if you have used symlinks or Automatic1111's built in command line arguments to change the directories for your models to something outside of the Automatic1111 directory you will need to take advantage of one of the following workarounds for your previews to work.

  1. If you use the command line arguments to change the directories for your models the extension will look in both the default directories and the custom directories for preview files. So you could change the directory for your models and leave your preview files in the default directories, this will keep them within the install directory and remove the issues with linking.

    <details> <summary>Click here for a quick guide on how to change directories without using symlinks.</summary> ​

    If you want to change the directories for models add these settings to your webui-user.bat COMMANDLINE_ARGS for each model type:

    --ckpt-dir "D:\\my models\\checkpoints"

    --hypernetwork-dir "D:\\my models\\hypernetworks"

    --embeddings-dir "D:\\my models\\embeddings"

    --lora-dir "D:\\my models\\lora"

    If you wanted to use all the settings at once your COMMANDLINE_ARGS line would look something like this:

    set COMMANDLINE_ARGS=--xformers --api --ckpt-dir "D:\\my models\\checkpoints" --hypernetwork-dir "D:\\my models\\hypernetworks" --embeddings-dir "D:\\my models\\embeddings" --lora-dir "D:\\my models\\lora"
    
    </details>
  2. The extension can detect if a preview file is outside of the install directory and alter how it handles the preview to try and avoid some of the issues with linking files in the webui. The following differences will occur:

Linking to local files/images in markdown or html pages

Linking to a file/image using relative paths is slightly different in Markdown vs HTML because of the difference in how they are loaded. Markdown has the relative path resolve from the location of the Automatic1111 install directory where as HTML files will need to have the path be relative from the actual HTML file.... unless you have the HTML outside of the Automatic1111 directory which changes how the HTML file is loaded and also will change where the path is relative from.

A quick way to avoid complications is to link to the file using the webserver that is created by Automatic1111. By default it is located at http://127.0.0.1:7860. This webserver serves up all files within the install directory and so will have relative paths be relative to that directory. The webserver doesn't have access to anything outside of the install directory so you will get an error if you try linking to any such file.

You will also have to use a special URI to reference that you want to use a local file. You need to include file= before the file path.

So to make it simple if you would like to link to a file or image from within a Markdown or HTML file use this syntax with the path always being relative from the Automatic install directory:

<img src="http://127.0.0.1:7860/file=models/Stable-diffusion/image.png">
![image alt text](http://127.0.0.1:7860/file=models/Stable-diffusion/image.png)

Footnotes

  1. This extension should support all operating systems in theory but has only been tested in Windows

  2. Generally referred to as "preview files" this refers to any file type supported by this extension including .html, .txt, .png etc.

  3. If you run into issues after first install you may need to fully shutdown and rerun the webui-user.bat after you install the extension.

  4. HTML and Markdown files will not support linking to files or images outside of the Automatic1111 directory. If you cannot keep linked files within the install directory upload them to the internet and link to them remotely. 2

  5. A .prompt file is a CSV file containing a list of prompts associated with your model.

  6. A .tags file is just a text file containing words that you want to use for searching for the associated model. It is suggested you format this as a list of hashtags. For example: "#anime #sfw #mix #high_quality". This will help avoid matching "nsfw" when searching for "sfw". However there is no required format. A search will match as long as the search text appears anywhere in the file. 2

  7. A .civitai.info file is a JSON file created by the Civitai Helper extension