Join the conversation

Join the community of Machine Learners and AI enthusiasts.

Sign Up
OFT 
posted an update about 20 hours ago
Post
273
Who can help?
I got a safetensor file and want to make a working txt2img diffuser on HF. You may explain or even link me to the right tutorial (I dont think it is inside the diffusers turorial?). Thank you ❤️

If you have a safetensor file and want to set up a working txt2img pipeline using Hugging Face diffusers, you're on the right track! The diffusers library itself doesn't have a dedicated tutorial for safetensors, but integrating them is possible with a bit of customization. Here's a brief guide:

Install Required Libraries: Make sure you have diffusers, transformers, and safetensors installed.

Load the safetensor File: Use torch or diffusers to load the model. Safetensors ensures a faster and more secure way to handle the weights.

Set Up the txt2img Pipeline: Use StableDiffusionPipeline from diffusers and point it to your safetensor-loaded model.

Do you mean a single safetensors file?
If it's a complete all-in-one safetensors file, it can often be read using from_single_file().
If you only have a transformer, this method cannot be used. You will need to import individual classes, load the transformer, and load the rest of the files from somewhere else.
https://huggingface.co/docs/diffusers/main/api/loaders/single_file
https://github.com/huggingface/diffusers/issues/9165#issue-2462431761

In this post