Merge pull request #63 from IDGallagher/bug_fixes

Bug fixes
This commit is contained in:
POM
2024-04-28 23:26:01 +02:00
committed by GitHub
3 changed files with 40 additions and 15 deletions
+15 -14
View File
@@ -500,7 +500,7 @@ class BatchCreativeInterpolationNode:
frame_numbers = np.concatenate([first_half_frame_numbers, second_half_frame_numbers])
# PROCESS WEIGHTS
ipa_frame_numbers, ipa_weights = process_weights(frame_numbers, weights, base_ipa_advanced_settings["ipa_weight"])
ipa_frame_numbers, ipa_weights = process_weights(frame_numbers, weights, 1.0)
# print(f'i {i} image index {image_index} ====')
# # print(f"frame numbers {frame_numbers}")
@@ -533,20 +533,21 @@ class BatchCreativeInterpolationNode:
else:
big_negative_noise = None
# Fill up bins with image frames. Bins will automatically be created when needed but all the frames should be able to be packed into two bins
active_index = -1
# Find a bin that we can fit the next image into
for i, bin in enumerate(bins):
if bin.length() <= ipa_frame_numbers[0]:
active_index = i
break
# If we didn't find a suitable bin, add a new one
if active_index == -1:
bins.append(IPBin())
active_index = len(bins) - 1
if len(ipa_frame_numbers) > 0:
# Fill up bins with image frames. Bins will automatically be created when needed but all the frames should be able to be packed into two bins
active_index = -1
# Find a bin that we can fit the next image into
for i, bin in enumerate(bins):
if bin.length() <= ipa_frame_numbers[0]:
active_index = i
break
# If we didn't find a suitable bin, add a new one
if active_index == -1:
bins.append(IPBin())
active_index = len(bins) - 1
# Add the image to the bin
bins[active_index].add(prepped_image, image.unsqueeze(0), negative_noise, big_negative_noise, image_index, ipa_frame_numbers, ipa_weights)
# Add the image to the bin
bins[active_index].add(prepped_image, image.unsqueeze(0), negative_noise, big_negative_noise, image_index, ipa_frame_numbers, ipa_weights)
# for i, bin in enumerate(bins):
# print(f"{i} schedule {bin.image_schedule}")
@@ -25,6 +25,26 @@ class CrossAttentionPatchImport:
self.k_key = str(self.number*2+1) + "_to_k_ip"
self.v_key = str(self.number*2+1) + "_to_v_ip"
@classmethod
def from_cross_attention_patch(cls, patch):
instance = cls(ipadapter = patch.ipadapters[0])
instance.weights = patch.weights
instance.ipadapters = patch.ipadapters
instance.conds = patch.conds
instance.conds_alt = patch.conds_alt
instance.unconds = patch.unconds
instance.weight_types = patch.weight_types
instance.masks = patch.masks
instance.sigma_starts = patch.sigma_starts
instance.sigma_ends = patch.sigma_ends
instance.unfold_batch = patch.unfold_batch
instance.embeds_scaling = patch.embeds_scaling
instance.number = patch.number
instance.layers = patch.layers
instance.k_key = patch.k_key
instance.v_key = patch.v_key
return instance
def set_new_condition(self, ipadapter=None, number=0, weight=1.0, cond=None, cond_alt=None, uncond=None, weight_type="linear", mask=None, sigma_start=0.0, sigma_end=1.0, unfold_batch=False, image_schedule=None, embeds_scaling='V only'):
self.weights.append(weight)
self.ipadapters.append(ipadapter)
@@ -142,7 +142,11 @@ def set_model_patch_replace(model, patch_kwargs, key):
if key not in to["patches_replace"]["attn2"]:
to["patches_replace"]["attn2"][key] = CrossAttentionPatchImport(**patch_kwargs)
else:
to["patches_replace"]["attn2"][key].set_new_condition(**patch_kwargs)
if isinstance(to["patches_replace"]["attn2"][key], CrossAttentionPatchImport):
to["patches_replace"]["attn2"][key].set_new_condition(**patch_kwargs)
else:
to["patches_replace"]["attn2"][key] = CrossAttentionPatchImport.from_cross_attention_patch(to["patches_replace"]["attn2"][key])
to["patches_replace"]["attn2"][key].set_new_condition(**patch_kwargs)
def ipadapter_execute(model,
ipadapter,