diff --git a/custom_nodes/stt.py b/custom_nodes/stt.py index 11daa69..40c5159 100644 --- a/custom_nodes/stt.py +++ b/custom_nodes/stt.py @@ -136,12 +136,6 @@ class AudioTranscriptionNode: print(f"{audio_frames=}s") return (transcription, audio_frames) - - @classmethod - def IS_CHANGED(cls, *args, **kwargs): - print(f"{args=} {kwargs=}") - return get_hash(*args, *kwargs.items()) - class BatchedTranscriptionEncoderNode: def __init__(self): @@ -189,7 +183,7 @@ class BatchedTranscriptionEncoderNode: tokens = clip.tokenize(text) cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True) - return text, duration, cond, pooled + return f'"{i*frame_interpolation}": "{text}"', duration, cond, pooled @staticmethod def get_spacy_model(language="en"): @@ -260,12 +254,12 @@ class BatchedTranscriptionEncoderNode: max_words=max_words) batch_prompt_text.append(t) batch_values_int.append(d) - cond.append(c) - pooled.append(pc) + cond.append(c.squeeze()) + pooled.append(pc.squeeze()) num_chunks = len(total_chunks) - final_pooled_output = torch.cat(pooled, dim=0) - final_conditioning = torch.cat(cond, dim=0) + final_pooled_output = torch.nested.to_padded_tensor(torch.nested.nested_tensor(pooled, dtype=torch.float32),0) + final_conditioning = torch.nested.to_padded_tensor(torch.nested.nested_tensor(cond, dtype=torch.float32),0) conditioning = [[final_conditioning,{"pooled_output": final_pooled_output}]] del pooled, cond @@ -274,9 +268,4 @@ class BatchedTranscriptionEncoderNode: print(batch_values_int) print(f"{num_chunks=}, {max_chunks=}, {num_frames=}") - return (conditioning, batch_prompt_text, batch_values_int, num_chunks, num_frames) - - @classmethod - def IS_CHANGED(cls, *args, **kwargs): - print(f"{args=} {kwargs=}") - return get_hash(*args, *kwargs.items()) \ No newline at end of file + return (conditioning, batch_prompt_text, batch_values_int, num_chunks, num_frames) \ No newline at end of file diff --git a/custom_nodes/utils.py b/custom_nodes/utils.py index e2ba3a6..aaa429c 100644 --- a/custom_nodes/utils.py +++ b/custom_nodes/utils.py @@ -112,7 +112,6 @@ class MergeImageBatches: return (images,) - class MergeLatentBatches: @classmethod def INPUT_TYPES(s): @@ -142,6 +141,7 @@ class MergeLatentBatches: gc_collect() merged_latent["samples"] = self.merge_tensor([latent["samples"] for latent in latents]) merged_latent["noise_mask"] = self.merge_tensor([latent["noise_mask"] for latent in latents if "noise_mask" in latent]) + # if len(merged_latent["noise_mask"])>0: merged_latent["noise_mask"] = torch.mean(merged_latent["noise_mask"],dim=0) # merged_latent["batch_index"] = self.merge_tensor([latent["batch_index"] for latent in latents if "batch_index" in latent]) merged_latent["batch_index"] = range(len(merged_latent["samples"])) @@ -195,7 +195,6 @@ class AudioBatchValueNode: audio_zscore = (audio_rms-audio_rms.mean())/audio_rms.std() output_range = output_max-output_min - print(f"{audio_rms.min()=} {audio_rms.max()=} {audio_rms.mean()=}") if norm=="tanh": x_norm = np.tanh(audio_zscore) #tanh=-1 to 1 if inverse: x_norm*=-1 @@ -209,10 +208,11 @@ class AudioBatchValueNode: x_norm = (audio_zscore - x_min) / (audio_zscore.max() - x_min) #scale=0 to 1 if inverse: x_norm=1-x_norm x_norm = x_norm * output_range + output_min - print(f"{x_norm.min()=} {x_norm.max()=} {x_norm.mean()=}") - batch_value = ",\n".join([f'{n}:({v})' for n,v in enumerate(x_norm)]) - if print_output: pprint(batch_value) + # batch_value = ",\n".join([f'{n}:({v})' for n,v in enumerate(x_norm)]) + if print_output: + print(f"{audio_rms.min()=} {audio_rms.max()=} {audio_rms.mean()=} {len(audio_rms)=}") + print(f"{x_norm.min()=} {x_norm.max()=} {x_norm.mean()=} {len(x_norm)=}") return (list(x_norm),list(map(int,x_norm)),num_values) class ImageRepeatInterleavedNode: @@ -236,24 +236,25 @@ class ImageRepeatInterleavedNode: CATEGORY = CATEGORY def rebatch(self, images, repeats, fps=1): - repeats = np.array(repeats).flatten()*fps - print(f"{repeats=}") + repeats = np.array(repeats).flatten() + fps = np.array(fps)[0] + print(f"{repeats=} {fps=}") all_images = [] for img in images: for i in range(img.shape[0]): all_images.append(img[i:i+1]) - # expand repeat if len(repeats)==1: - repeats = repeats.repeat(len(all_images),axis=0) - elif len(repeats)1: all_images[i] = img.expand(repeats[i], *img.shape).flatten(0,1) + repeat = int(repeats[i])*fps + if repeat>1: all_images[i] = img.expand(repeat, *img.shape).flatten(0,1) else: all_images[i] = img - print(f"{img.shape=} {all_images[i].shape=}") print(f"{len(images)=} {len(all_images)=}") gc_collect() @@ -296,21 +297,22 @@ class LatentRepeatInterleavedNode: offset = 0 num_latents = 0 for i in range(len(samples)): - - samples[i]["batch_index"] = [i+offset for i in range(repeats[i])] + repeat = int(repeats[i]) + samples[i]["batch_index"] = [i+offset for i in range(repeat)] offset += repeats[i] - samples[i]["samples"] = LatentRepeatInterleavedNode.repeat(samples[i]["samples"],repeats[i]) + samples[i]["samples"] = LatentRepeatInterleavedNode.repeat(samples[i]["samples"],repeat) num_latents+=len(samples[i]["samples"]) if "noise_mask" in samples[i]: - samples[i]["noise_mask"] = LatentRepeatInterleavedNode.repeat(samples[i]["noise_mask"],repeats[i]) + samples[i]["noise_mask"] = LatentRepeatInterleavedNode.repeat(samples[i]["noise_mask"],repeat) return samples,num_latents def merge(self, latents, repeats, fps=1): - repeats = np.array(repeats).flatten()*fps - print(f"{repeats=}") + repeats = np.array(repeats).flatten() + fps = np.array(fps)[0] + print(f"{repeats=} {fps=}") # combine all latents new_latents = [] @@ -322,19 +324,21 @@ class LatentRepeatInterleavedNode: new_latent = { "samples": latent["samples"][i], } - if "noise_mask" in latent: new_latent["noise_mask"] = latent["noise_mask"][i] + if "noise_mask" in latent: + print(f"{latent['noise_mask'].shape=}") + new_latent["noise_mask"] = latent["noise_mask"] new_latents.append(new_latent) - # expand repeat if len(repeats)==1: - repeats = repeats.repeat(len(new_latents),axis=0) - elif len(repeats)1: # handles list inputs return (list(map(num_to_int,number)), list(map(float,number)),)