mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-04-30 19:21:39 +00:00
Fixed issue with prompt token replace adding more than one replacement
This commit is contained in:
@@ -312,6 +312,7 @@ class BaseSDTrainProcess(BaseTrainProcess):
|
|||||||
if self.trigger_word is not None and not is_reg:
|
if self.trigger_word is not None and not is_reg:
|
||||||
prompt = self.sd.inject_trigger_into_prompt(
|
prompt = self.sd.inject_trigger_into_prompt(
|
||||||
prompt,
|
prompt,
|
||||||
|
trigger=self.trigger_word,
|
||||||
add_if_not_present=True,
|
add_if_not_present=True,
|
||||||
)
|
)
|
||||||
conditioned_prompts.append(prompt)
|
conditioned_prompts.append(prompt)
|
||||||
|
|||||||
@@ -698,6 +698,7 @@ class StableDiffusion:
|
|||||||
return prompt
|
return prompt
|
||||||
output_prompt = prompt
|
output_prompt = prompt
|
||||||
default_replacements = ["[name]", "[trigger]"]
|
default_replacements = ["[name]", "[trigger]"]
|
||||||
|
num_times_trigger_exists = prompt.count(trigger)
|
||||||
|
|
||||||
replace_with = trigger
|
replace_with = trigger
|
||||||
if to_replace_list is None:
|
if to_replace_list is None:
|
||||||
@@ -714,7 +715,7 @@ class StableDiffusion:
|
|||||||
output_prompt = output_prompt.replace(to_replace, replace_with)
|
output_prompt = output_prompt.replace(to_replace, replace_with)
|
||||||
|
|
||||||
# see how many times replace_with is in the prompt
|
# see how many times replace_with is in the prompt
|
||||||
num_instances = prompt.count(replace_with)
|
num_instances = output_prompt.count(replace_with)
|
||||||
|
|
||||||
if num_instances == 0 and add_if_not_present:
|
if num_instances == 0 and add_if_not_present:
|
||||||
# add it to the beginning of the prompt
|
# add it to the beginning of the prompt
|
||||||
|
|||||||
Reference in New Issue
Block a user