From bd7c521b7b1e729223d667ca77148667873372bc Mon Sep 17 00:00:00 2001 From: nullquant Date: Fri, 3 May 2024 22:14:20 +0300 Subject: [PATCH] pooled output --- brushnet/brushnet.py | 8 +++++++- brushnet_nodes.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/brushnet/brushnet.py b/brushnet/brushnet.py index 43888fb..41ace1d 100644 --- a/brushnet/brushnet.py +++ b/brushnet/brushnet.py @@ -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) diff --git a/brushnet_nodes.py b/brushnet_nodes.py index 8567a44..d8702cc 100644 --- a/brushnet_nodes.py +++ b/brushnet_nodes.py @@ -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')