model cache bug

This commit is contained in:
billwuhao
2025-06-02 23:06:02 +08:00
parent 79c83e089b
commit 7c631eecf0
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -39,6 +39,7 @@ class NotaGenRun:
def __init__(self):
self.device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
self.node_dir = node_dir
self.model_name = None
@classmethod
def INPUT_TYPES(s):
@@ -109,7 +110,9 @@ class NotaGenRun:
model_file_path = os.path.join(nota_model_path, model)
global MODEL_CACHE, PATCHILIZER
if MODEL_CACHE is None:
if MODEL_CACHE is None or self.model_name != model:
self.model_name = model
MODEL_CACHE = torch.load(model_file_path, map_location=torch.device(self.device))
nota_model.load_state_dict(MODEL_CACHE['model'])
nota_model = nota_model.to(self.device)
@@ -123,7 +126,8 @@ class NotaGenRun:
'%' + composer + '\n',
'%' + instrumentation + '\n']
if PATCHILIZER is None:
if PATCHILIZER is None or self.model_name != model:
self.model_name = model
PATCHILIZER = Patchilizer(model)
bos_patch = [PATCHILIZER.bos_token_id] * (patch_size - 1) + [PATCHILIZER.eos_token_id]
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "notagen-mw"
description = "Symbolic Music Generation, NotaGen node for ComfyUI."
version = "2.2.8"
version = "2.2.9"
license = {file = "LICENSE"}
[project.urls]