Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PhotoMaker #106

Open
kelvincai522 opened this issue Oct 22, 2024 · 0 comments
Open

Support PhotoMaker #106

kelvincai522 opened this issue Oct 22, 2024 · 0 comments

Comments

@kelvincai522
Copy link

kelvincai522 commented Oct 22, 2024

Trying to use compel on the photomaker pipeline. Got error: RuntimeError: CUDA error: device-side assert triggered

pipe = PhotoMakerStableDiffusionXLPipeline.from_single_file(

    "model.safetensors",
    torch_dtype=torch.bfloat16, 
    use_safetensors=True, 
    variant="fp16"
).to("cuda")

### Load PhotoMaker checkpoint
pipe.load_photomaker_adapter(
    folder,
    subfolder="",
    weight_name= weightname,

    trigger_word="img"  # define the trigger word
)     

pipe.scheduler = DDPMScheduler.from_config(pipe.scheduler.config)


# Weighted prompt with compel
from compel import Compel, ReturnedEmbeddingsType

compel = Compel(
  tokenizer=[pipe.tokenizer, pipe.tokenizer_2] ,
  text_encoder=[pipe.text_encoder, pipe.text_encoder_2],
  returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,
  requires_pooled=[False, True]
)

id_img = Image.open(img.png")

prompt = "blahbla"

conditioning, pooled = compel(prompt)

# generation
generator = torch.Generator(device="cuda").manual_seed(4)

images = pipe(
    #prompt=prompt,
    prompt_embeds=conditioning,
    pooled_prompt_embeds=pooled,    
    input_id_images= [id_img],
    num_images_per_prompt=1,
    num_inference_steps=10,
    guidance_scale=4,
    start_merge_step=0, 
    generator=generator,
    height= 1024,
    width= 1024,    
).images[0]
images.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant