Views
No views yet

1pip install replicate
2export REPLICATE_API_TOKEN=r8_*************************************1import replicate
2
3output = replicate.run(
4 "sdxl-barbietron@sha256:e120cde4b3a343dbe5116638645c3a41b4859347c08dbfb8f49bcea7cb91b5fa",
5 input={"prompt": "A portrait photo of a woman in the style of TOK, pastel pink, neon"}
6)
7print(output)diffusers doesn't yet support textual inversion for SDXL, we will use cog-sdxl TokenEmbeddingsHandler class.<s0><s1>1pip install diffusers transformers accelerate safetensors huggingface_hub
2git clone https://github.com/replicate/cog-sdxl cog_sdxl1import torch
2from huggingface_hub import hf_hub_download
3from diffusers import DiffusionPipeline
4from cog_sdxl.dataset_and_utils import TokenEmbeddingsHandler
5from diffusers.models import AutoencoderKL
6
7pipe = DiffusionPipeline.from_pretrained(
8 "stabilityai/stable-diffusion-xl-base-1.0",
9 torch_dtype=torch.float16,
10 variant="fp16",
11).to("cuda")
12
13pipe.load_lora_weights("fofr/sdxl-barbietron", weight_name="lora.safetensors")
14
15text_encoders = [pipe.text_encoder, pipe.text_encoder_2]
16tokenizers = [pipe.tokenizer, pipe.tokenizer_2]
17
18embedding_path = hf_hub_download(repo_id="fofr/sdxl-barbietron", filename="embeddings.pti", repo_type="model")
19embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
20embhandler.load_embeddings(embedding_path)
21prompt="A portrait photo of a woman in the style of <s0><s1>, pastel pink, neon"
22images = pipe(
23 prompt,
24 cross_attention_kwargs={"scale": 0.8},
25).images
26#your output image
27images[0]