🚀 sdxl-emoji LoRA
sdxl-emoji LoRA是一个基于苹果表情符号的SDXL微调模型,可用于文本到图像的生成。
🚀 快速开始
使用Replicate API进行推理
首先,你可以从这里获取Replicate令牌。
pip install replicate
export REPLICATE_API_TOKEN=r8_*************************************
以下是使用Python代码进行推理的示例:
import replicate
output = replicate.run(
"sdxl-emoji@sha256:dee76b5afde21b0f01ed7925f0665b7e879c50ee718c5f78a9d38e04d523cc5e",
input={"prompt": "A TOK emoji of a man"}
)
print(output)
你还可以通过Node.js或curl使用API进行推理,也可以使用COG和Docker在本地进行推理。查看此模型的Replicate API页面
使用 🧨 diffusers 进行推理
Replicate SDXL LoRAs是使用关键调优(Pivotal Tuning)进行训练的,它结合了通过Dreambooth LoRA训练概念和通过文本反转训练新令牌。由于diffusers
目前还不支持SDXL的文本反转,我们将使用cog-sdxl的TokenEmbeddingsHandler
类。
提示词中的触发令牌为 <s0><s1>
pip install diffusers transformers accelerate safetensors huggingface_hub
git clone https://github.com/replicate/cog-sdxl cog_sdxl
import torch
from huggingface_hub import hf_hub_download
from diffusers import DiffusionPipeline
from cog_sdxl.dataset_and_utils import TokenEmbeddingsHandler
from diffusers.models import AutoencoderKL
pipe = DiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
variant="fp16",
).to("cuda")
pipe.load_lora_weights("fofr/sdxl-emoji", weight_name="lora.safetensors")
text_encoders = [pipe.text_encoder, pipe.text_encoder_2]
tokenizers = [pipe.tokenizer, pipe.tokenizer_2]
embedding_path = hf_hub_download(repo_id="fofr/sdxl-emoji", filename="embeddings.pti", repo_type="model")
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
embhandler.load_embeddings(embedding_path)
prompt="A <s0><s1> emoji of a man"
images = pipe(
prompt,
cross_attention_kwargs={"scale": 0.8},
).images
images[0]
📄 许可证
本项目采用CreativeML OpenRAIL-M许可证。
📦 模型信息
属性 |
详情 |
模型类型 |
基于SDXL的LoRA微调模型 |
基础模型 |
stabilityai/stable-diffusion-xl-base-1.0 |
关键调优 |
是 |
文本嵌入 |
embeddings.pti |
实例提示词 |
an emoji |
推理状态 |
否 |

此项目由 fofr 创建。