mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-04-29 02:31:17 +00:00
Allow for a default caption file in the folder. Minor bug fixes.
This commit is contained in:
@@ -121,6 +121,9 @@ class CaptionMixin:
|
||||
prompt_path = path_no_ext + '.' + ext
|
||||
if os.path.exists(prompt_path):
|
||||
break
|
||||
|
||||
# allow folders to have a default prompt
|
||||
default_prompt_path = os.path.join(os.path.dirname(img_path), 'default.txt')
|
||||
|
||||
if os.path.exists(prompt_path):
|
||||
with open(prompt_path, 'r', encoding='utf-8') as f:
|
||||
@@ -131,6 +134,10 @@ class CaptionMixin:
|
||||
if 'caption' in prompt:
|
||||
prompt = prompt['caption']
|
||||
|
||||
prompt = clean_caption(prompt)
|
||||
elif os.path.exists(default_prompt_path):
|
||||
with open(default_prompt_path, 'r', encoding='utf-8') as f:
|
||||
prompt = f.read()
|
||||
prompt = clean_caption(prompt)
|
||||
else:
|
||||
prompt = ''
|
||||
|
||||
@@ -481,9 +481,9 @@ def get_guided_loss_polarity(
|
||||
|
||||
loss = pred_loss + pred_neg_loss
|
||||
|
||||
if sd.is_flow_matching:
|
||||
timestep_weight = sd.noise_scheduler.get_weights_for_timesteps(timesteps).to(loss.device, dtype=loss.dtype).detach()
|
||||
loss = loss * timestep_weight
|
||||
# if sd.is_flow_matching:
|
||||
# timestep_weight = sd.noise_scheduler.get_weights_for_timesteps(timesteps).to(loss.device, dtype=loss.dtype).detach()
|
||||
# loss = loss * timestep_weight
|
||||
|
||||
|
||||
loss = loss.mean([1, 2, 3])
|
||||
|
||||
Reference in New Issue
Block a user