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

Weighted prompt on photomaker #140

Open
Fqlox opened this issue Apr 11, 2024 · 0 comments
Open

Weighted prompt on photomaker #140

Fqlox opened this issue Apr 11, 2024 · 0 comments

Comments

@Fqlox
Copy link

Fqlox commented Apr 11, 2024

I wanted to add weighted prompt on the photomaker pipe.

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()

Ang got :
RuntimeError: CUDA error: device-side assert triggered

Is there any boilerplate code to implement weighted prompt ?

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