How to Use Stable Diffusion Safetensors in Automatic1111

If you’re seeking SD models without malicious code, Stable Diffusion safetensors are your go-to model format. 

Rest assured that you’ll only be running secure code on your system.

Safetensor models not only guarantee safety but also boast self-contained functionality. 

How to Use Stable Diffusion Safetensors in Automatic1111

They can be effortlessly moved or copied and loaded and utilized by Stable Diffusion at a faster pace than .ckpt files.

Now, let’s delve into it a bit before moving on to how to use Safetensors.

What are Safetensors in Stable Diffusion?

In short, Safetensors are a safer alternative to the standard checkpoint (.ckpt) format used in Stable Diffusion and are designed to be more secure than traditional .ckpt files. 

The Stable Diffusion team created them in response to concerns about the potential for malicious code to be hidden inside of .ckpt files.

Safetensors mainly are created by converting a .ckpt file into a new format that is incompatible with Python. 

This means that it is impossible to run any Python code embedded inside a safetensor file. 

And of course, this makes them much safer to use, as there is no risk of accidentally running malicious code.

How to Use Safetensors in Automatic1111

Unfortunately, currently, ComfyUI doesn’t directly support Safetensors, and that’s why to use Safetensors file format, you should utilize the Automatic1111 webUI.

And do not worry, in this post, we are actually talking about how to use Safetensors in Automatic1111.

So, to use Safetensors in Stable Diffusion, you can follow these simple steps. 

Based on our experiences with stable diffusion over 1 year, it works.

1. Update Automatic1111: First of all, ensure you have the latest version of Automatic1111. The latest versions support Safetensors natively.

You can update Automatic1111 by pulling the latest changes from the Git repository: stable-diffusion-webui

2. Download a Safetensor model: Next, there are various sources for Safetensor models, including online repositories like CivitAI and Hugging Face.

After landing on the Hugging Face page search for ‘safetensors’.

But before downloading, ensure you download a model compatible with your Automatic1111 version and system requirements reading the documents carefully.

3. Place the Safetensor file in the correct location: Now, copy the downloaded Safetensor file to the appropriate directory within your Automatic1111 installation.

The location typically depends on the model type:

For model checkpoints (e.g., Dreambooth models): models/ldm/models/your_model_name.safetensors

For LoRA models: models/Lora/your_model_name.safetensors

4. Launch Automatic1111 and select the Safetensor model: Lastly, open Automatic1111 and navigate to the model selection panel. In the dropdown menu, locate your Safetensor model and select it.

Once the Safetensor model is loaded, you can start generating images as usual by providing prompts and adjusting other settings.

If you’re new to stable diffusion, you can explore our SDXL prompt guide to craft effective prompts and generate stunning images.

Additional tips:

If you have .ckpt files, you can also convert your existing .ckpt models to Safetensors using dedicated tools like safetensor-convert.

Keep in mind that some extensions and plugins for Automatic1111 may require specific model formats. 

And don’t forget to ensure your Safetensor model is compatible with the tools you plan to use.

If you are still unsatisfied or haven’t grasped the key points for using Safetensors files, let’s explore the reasons why you should utilize them.

Why Use Safetensors file?

While there are numerous advantages to using Safetensor files, I will specifically highlight two main reasons to utilize these files, providing a comprehensive comparison with .ckpt files.

Security: .ckpt files can contain arbitrary Python code, which could be used to execute malicious code on your system. 

Safetensors, on the other hand, are a pure data format that cannot contain any executable code.

Usability: .ckpt files require a specific folder structure and can be difficult to manage. 

So, Safetensors are self-contained and can be placed anywhere in your file system.

Now, let’s see a comparison of .ckpt and Safetensors:

Feature.ckptSafetensors
Security Potentially unsafeSafe
UsabilityDifficult to manageEasy to manage
CompatibilitySupported by most
Stable Diffusion tools
Supported by a growing
number of tools

Therefore, Safetensors ensure code safety, preventing malicious content. They are self-contained and easily transferable.

Additionally, Stable Diffusion loads Safetensors faster than .ckpt files.

However, it does not imply that they have no limitations or drawbacks. Therefore, before using Safetensors, please review the following information.

Limitations and Drawbacks of Safetensors

Limited adoption: While adoption is growing, not all Stable Diffusion tools currently support Safetensors.

So, this can make it difficult to find compatible tools and workflows for you.

Potential compatibility issues: Converting existing .ckpt files to Safetensors can sometimes introduce compatibility issues, leading to unexpected behavior or errors in some tools.

New format: As a relatively new format, Safetensors are still under development, and some features or optimizations may be missing compared to established formats like .ckpt.

Performance considerations: Although Safetensors offer faster loading times in some cases, they may not always outperform .ckpt files, especially on older hardware or with large models.

Interoperability: While Safetensors can be exchanged between different programming languages, there may be limitations in specific cases, especially when dealing with custom libraries or frameworks.

Final Verdict:

In a nutshell, using Stable Diffusion Safetensors can be a game-changer, but you see there are a few things to keep in mind.

So, take it step by step, weigh the pros and cons, and in this way, I hope you’ll be on the right track!

If you are facing any issues related to Safetensors, please let us know by commenting below. We are always here to solve your issues free of cost.

Leave a Comment