diffusers
Jax infer support negative prompt
#1337
Merged

Jax infer support negative prompt #1337

entrpn
entrpn2 years ago🎉 1

Added negative prompt support to jax pipeline.

For example.

prompt : a colorful photo of a castle in the middle of a forest with trees and bushes, by Ismail Inceoglu, shadows, high contrast, dynamic shading, hdr, detailed vegetation, digital painting, digital drawing, detailed painting, a detailed digital painting, gothic art, featured on deviantart

output (3)

With negative prompt: fog, grainy, purple

output (4)

entrpn support negative prompts in sd jax pipeline
5412f4b9
entrpn pass batched neg_prompt
e69c68b5
jfacevedo-google only encode when negative prompt is None
20b740c4
HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev2 years ago (edited 2 years ago)

The documentation is not available anymore as the PR was closed or merged.

entrpn Merge branch 'main' into jax-infer-support-negative-prompt
2511eff0
pcuenca
pcuenca approved these changes on 2022-11-18
pcuenca2 years ago👍 1

Looks good!

pcuenca
pcuenca2 years ago

Works fine for me, thanks a lot @entrpn!

@patil-suraj can you maybe take a quick look?

camenduru
camenduru2 years ago (edited 2 years ago)

thanks @entrpn ❤ am I doing right ?

real_seed = random.randint(0, 2147483647)
prng_seed = jax.random.PRNGKey(real_seed)
prng_seed = jax.random.split(prng_seed, jax.device_count())
num_samples = jax.device_count()
prompt_n = num_samples * [prompt]
prompt_ids = pipe.prepare_inputs(prompt_n)
prompt_ids = shard(prompt_ids)
negative_prompt_n = num_samples * [negative_prompt]
negative_prompt_ids = pipe.prepare_inputs(negative_prompt_n)
negative_prompt_ids = shard(negative_prompt_ids)
images = pipe(prompt_ids, params, prng_seed, neg_prompt_ids=negative_prompt_ids, num_inference_steps=num_inference_steps, height=height, width=width, guidance_scale=guidance_scale, jit=True).images
entrpn
entrpn2 years ago🎉 1

@camenduru that looks right.

entrpn Merge branch 'main' into jax-infer-support-negative-prompt
3e803774
pcuenca pcuenca merged 7bbbfbfd into main 2 years ago
entrpn entrpn deleted the jax-infer-support-negative-prompt branch 2 years ago

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone