Skip to content

Commit 566641a

Browse files
committed
ft fixes: speaker selection, weight mismatch
Fix an error when loading the fine tuned model caused by incorrect vocab size Add an option to the prompt node to set a speaker Move tokenizer initialization to initializer for prompt. It's only used here and produces excessive console spam when when orpheus workflows are not in use
1 parent 136ad36 commit 566641a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

nodes.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ def __call__(self, input_ids, score):
137137
new_score[:,code_base:code_base+4096] = score[:,code_base:code_base+4096]
138138
return new_score
139139

140-
141-
142-
#TODO: properly load this
143-
tok = LLAMA3Tokenizer()
144-
145140
class LoadOrpheus:
146141
@classmethod
147142
def INPUT_TYPES(s):
@@ -156,6 +151,8 @@ def loadorpheus(self, model):
156151
conf = os.path.join(os.path.split(__file__)[0], 'orpheus-config.json')
157152
config = PretrainedConfig.from_json_file(conf)
158153
sd = safetensors.torch.load_file(model)
154+
#TODO: use this to detect pt/ft and add further tweaks?
155+
config.vocab_size = sd['lm_head.weight'].size(0)
159156
model = LlamaForCausalLM.from_pretrained(None, config=config, state_dict=sd)
160157
return model,
161158

@@ -206,14 +203,21 @@ def sample(self, model, prompt, add_start_token, seed=None):
206203
class OrpheusPrompt:
207204
@classmethod
208205
def INPUT_TYPES(s):
209-
return {"required": {"text": ("STRING", {"multiline": True})},}
206+
return {"required": {"text": ("STRING", {"multiline": True})},
207+
"optional": {"speaker": (['None','tara','leah','jess','leo','dan','mia','zac','zoe'],)}}
210208
FUNCTION = "encodeprompt"
211209
RETURN_TYPES = ("ORPH_TOKENS",)
212210
CATEOGRY = "Orpheus"
213-
def encodeprompt(self, text):
211+
def __init__(self):
212+
#TODO: properly load this
213+
tok = LLAMA3Tokenizer()
214+
self.tokenizer = tok.tokenizer
215+
def encodeprompt(self, text, speaker='None'):
216+
if speaker != 'None':
217+
text = speaker + ": " + text
214218
#start_of_text is included during tokenization automatically
215219
tokens = [TOKENS['start_of_human']] \
216-
+ tok.tokenizer(text).input_ids \
220+
+ self.tokenizer(text).input_ids \
217221
+ [TOKENS['end_of_text'], TOKENS['end_of_human']]
218222
return tokens,
219223

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-orpheus"
33
description = "Nodes for using Orpheus-TTS in ComfyUI"
4-
version = "0.1.2"
4+
version = "0.1.3"
55
classifiers = [
66
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
77
]

0 commit comments

Comments
 (0)