Comments (4)
!pip install diffusers==0.8.1
!pip install transformers==4.24.0
from prompt-to-prompt.
I'm getting this too, diffusers==0.6.0
solved the issue
from prompt-to-prompt.
thx, i will try it!
from prompt-to-prompt.
Another solution is to replace
def run_and_display(prompts, controller, latent=None, run_baseline=False, generator=None):
if run_baseline:
print("w.o. prompt-to-prompt")
images, latent = run_and_display(prompts, EmptyControl(), latent=latent, run_baseline=False, generator=generator)
print("with prompt-to-prompt")
images, x_t = ptp_utils.text2image_ldm_stable(ldm_stable, prompts, controller, latent=latent, num_inference_steps=NUM_DIFFUSION_STEPS, guidance_scale=GUIDANCE_SCALE, generator=generator, low_resource=LOW_RESOURCE)
ptp_utils.view_images(images)
return images, x_t
with
@torch.no_grad()
def text2image_ldm_stable(
model,
prompt: List[str],
controller,
num_inference_steps: int = 50,
guidance_scale: Optional[float] = 7.5,
generator: Optional[torch.Generator] = None,
latent: Optional[torch.FloatTensor] = None,
uncond_embeddings=None,
start_time=50,
return_type='image'
):
batch_size = len(prompt)
ptp_utils.register_attention_control(model, controller)
height = width = 512
text_input = model.tokenizer(
prompt,
padding="max_length",
max_length=model.tokenizer.model_max_length,
truncation=True,
return_tensors="pt",
)
text_embeddings = model.text_encoder(text_input.input_ids.to(model.device))[0]
max_length = text_input.input_ids.shape[-1]
if uncond_embeddings is None:
uncond_input = model.tokenizer(
[""] * batch_size, padding="max_length", max_length=max_length, return_tensors="pt"
)
uncond_embeddings_ = model.text_encoder(uncond_input.input_ids.to(model.device))[0]
else:
uncond_embeddings_ = None
latent, latents = ptp_utils.init_latent(latent, model, height, width, generator, batch_size)
model.scheduler.set_timesteps(num_inference_steps)
for i, t in enumerate(tqdm(model.scheduler.timesteps[-start_time:])):
if uncond_embeddings_ is None:
context = torch.cat([uncond_embeddings[i].expand(*text_embeddings.shape), text_embeddings])
else:
context = torch.cat([uncond_embeddings_, text_embeddings])
latents = ptp_utils.diffusion_step(model, controller, latents, context, t, guidance_scale, low_resource=False)
if return_type == 'image':
image = ptp_utils.latent2image(model.vae, latents)
else:
image = latents
return image, latent
def run_and_display(prompts, controller, latent=None, run_baseline=False, generator=None, uncond_embeddings=None, verbose=True):
if run_baseline:
print("w.o. prompt-to-prompt")
images, latent = run_and_display(prompts, EmptyControl(), latent=latent, run_baseline=False, generator=generator)
print("with prompt-to-prompt")
images, x_t = text2image_ldm_stable(ldm_stable, prompts, controller, latent=latent, num_inference_steps=NUM_DIFFUSION_STEPS, guidance_scale=GUIDANCE_SCALE, generator=generator, uncond_embeddings=uncond_embeddings)
if verbose:
ptp_utils.view_images(images)
return images, x_t
from prompt-to-prompt.
Related Issues (20)
- Can't load a fine-tuned model due to using an old version of diffusers
- On the non-convergence of null text
- Is training code available? HOT 1
- Does it support SDXL? HOT 2
- When I use Diffusers==0.21.0, p2p seems to generate the same as w/o p2p. Code needs to be upgraded.
- bad results when changing the clothes's color HOT 1
- code for user-defined mask HOT 3
- Can Null text inversion apply to Stable diffusion 2.1? HOT 1
- If I want to add null text inversion to the training process to maintain the feature of the edited image, how can I achieve this?
- code about Delta Denoising Score
- Can we give image as input? HOT 1
- wrong DDIM inversion step HOT 1
- The setting of DDIMScheduler.
- Why the image in the article is so nice and true-life however I get low-grade images on myself?
- null text inversion sdxl support require HOT 2
- DDS_zeroshot.ipynb - sds loss derivation HOT 2
- how to run! who can give me a detail environment requirement, such as the version of diffusers and transformer? HOT 2
- visualizing self attention map HOT 1
- Error introduced when using p2p pipeline comparing to null-text inversion HOT 1
- Can run in windows environment?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prompt-to-prompt.