Views
No views yet

1pip install replicate
2export REPLICATE_API_TOKEN=r8_*************************************1import replicate
2
3output = replicate.run(
4 "sdxl-zelda64@sha256:435913219645a80ee6743ca500940ab8708889172ca5c4c71bbb701309bb4a60",
5 input={"prompt": "Link working as a pizza delivery driver, on a scooter, in new york, in the style of TOK"}
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
13load_lora_weights("jbilcke-hf/sdxl-zelda64", 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="jbilcke-hf/sdxl-zelda64", filename="embeddings.pti", repo_type="model")
19embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
20embhandler.load_embeddings(embedding_path)
21prompt="Link working as a pizza delivery driver, on a scooter, in new york, in the style of <s0><s1>"
22images = pipe(
23 prompt,
24 cross_attention_kwargs={"scale": 0.8},
25).images
26#your output image
27images[0]