pooled output

This commit is contained in:
nullquant
2024-05-03 22:14:20 +03:00
parent 331c2f43a0
commit bd7c521b7b
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -823,7 +823,13 @@ class BrushNetModel(ModelMixin, ConfigMixin):
# 2. pre-process
if sample.shape[2] != brushnet_cond.shape[2] or sample.shape[3] != brushnet_cond.shape[3]:
raise Exception("Image "+ str(brushnet_cond.shape) +" and latent " + str(sample.shape) + " should be the same size")
print("Image "+ str(brushnet_cond.shape) +" and latent " + str(sample.shape) + " have different size, resizing image")
brushnet_cond = torch.nn.functional.interpolate(
brushnet_cond, size=(
sample.shape[2],
sample.shape[3],
), mode='bicubic',
).to(sample.device).to(sample.dtype)
brushnet_cond=torch.concat([sample,brushnet_cond],1)
sample = self.conv_in_condition(brushnet_cond)
+2 -2
View File
@@ -251,7 +251,7 @@ class BrushNet:
prompt_embeds = positive[0][0][0].to(brushnet['brushnet'].device)
negative_prompt_embeds = negative[0][0][0].to(brushnet['brushnet'].device)
if len(positive[0]) > 1 and 'pooled_output' in positive[0][1]:
if len(positive[0]) > 1 and 'pooled_output' in positive[0][1] and positive[0][1]['pooled_output'] is not None:
add_text_embeds = positive[0][1]['pooled_output'].to(brushnet['brushnet'].device)
else:
print('BrushNet: positive conditioning has not pooled_output')
@@ -259,7 +259,7 @@ class BrushNet:
print('BrushNet will not produce correct results')
add_text_embeds = torch.empty([2, 1280], device=brushnet['brushnet'].device)
if len(negative[0]) > 1 and 'pooled_output' in negative[0][1]:
if len(negative[0]) > 1 and 'pooled_output' in negative[0][1] and negative[0][1]['pooled_output'] is not None:
negative_pooled_prompt_embeds = negative[0][1]['pooled_output'].to(brushnet['brushnet'].device)
else:
print('BrushNet: negative conditioning has not pooled_output')