Comments (13)
The actual problem is that on newer version the code of UNet was rewritten, and instead of CrossAttention they use Attention so it doesn't allow attention masks to be stored
So, to fix this one should change register_recr
on this function
def register_recr(net_, count, place_in_unet):
if net_.__class__.__name__ == 'Attention':
And rewrite ca_forward. For version 0.17.1 it will looks like:
def ca_forward(self, place_in_unet):
to_out = self.to_out
if type(to_out) is torch.nn.modules.container.ModuleList:
to_out = self.to_out[0]
else:
to_out = self.to_out
def forward(hidden_states, encoder_hidden_states=None, attention_mask=None,temb=None,):
is_cross = encoder_hidden_states is not None
residual = hidden_states
if self.spatial_norm is not None:
hidden_states = self.spatial_norm(hidden_states, temb)
input_ndim = hidden_states.ndim
if input_ndim == 4:
batch_size, channel, height, width = hidden_states.shape
hidden_states = hidden_states.view(batch_size, channel, height * width).transpose(1, 2)
batch_size, sequence_length, _ = (
hidden_states.shape if encoder_hidden_states is None else encoder_hidden_states.shape
)
attention_mask = self.prepare_attention_mask(attention_mask, sequence_length, batch_size)
if self.group_norm is not None:
hidden_states = self.group_norm(hidden_states.transpose(1, 2)).transpose(1, 2)
query = self.to_q(hidden_states)
if encoder_hidden_states is None:
encoder_hidden_states = hidden_states
elif self.norm_cross:
encoder_hidden_states = self.norm_encoder_hidden_states(encoder_hidden_states)
key = self.to_k(encoder_hidden_states)
value = self.to_v(encoder_hidden_states)
query = self.head_to_batch_dim(query)
key = self.head_to_batch_dim(key)
value = self.head_to_batch_dim(value)
attention_probs = self.get_attention_scores(query, key, attention_mask)
attention_probs = controller(attention_probs, is_cross, place_in_unet)
hidden_states = torch.bmm(attention_probs, value)
hidden_states = self.batch_to_head_dim(hidden_states)
# linear proj
hidden_states = to_out(hidden_states)
if input_ndim == 4:
hidden_states = hidden_states.transpose(-1, -2).reshape(batch_size, channel, height, width)
if self.residual_connection:
hidden_states = hidden_states + residual
hidden_states = hidden_states / self.rescale_output_factor
return hidden_states
return forward
from prompt-to-prompt.
me too...
solved it by installing diffusers==0.10.0, you can try
from prompt-to-prompt.
not work, could you share more detail? thanks.
and installing diffusers==0.10.0
from prompt-to-prompt.
me too...
from prompt-to-prompt.
solved!thanx!!!!!
from prompt-to-prompt.
not work, could you share more detail? thanks.
from prompt-to-prompt.
it works. thanks!
from prompt-to-prompt.
Using diffusers==0.10.0, raises another error for me: no attribute 'StableUnCLIPImg2ImgPipeline'
from prompt-to-prompt.
Using diffusers==0.10.0, raises another error for me: no attribute 'StableUnCLIPImg2ImgPipeline'
from prompt-to-prompt.
Thx!but after changing to 0.17.1 version and modify the code as you instructed, still error when calling the cell in Cross-Attention Visualization session.
g_cpu = torch.Generator().manual_seed(88)
prompts = ["A painting of a squirrel eating a burger"]
controller = AttentionStore()
image, x_t = run_and_display(prompts, controller, latent=None, run_baseline=False, generator=g_cpu)
show_cross_attention(controller, res=16, from_where=("up", "down"))
TypeError: PNDMScheduler.set_timesteps() got an unexpected keyword argument 'offset'
from prompt-to-prompt.
It's other problem :)
The solution is here
from prompt-to-prompt.
change show_cross_attention(controller, 16, ["up", "down"])
to show_cross_attention(controller, 24, ["up", "down"])
from prompt-to-prompt.
@anvilarth 你是我的神
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.