mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-15 16:39:42 +00:00
Update train_util.py
This commit is contained in:
@@ -5507,10 +5507,6 @@ def sample_images_common(
|
||||
|
||||
# preprocess prompts
|
||||
idx = 0
|
||||
if example_tuple:
|
||||
logger.info(f"len(example_tuple): {len(example_tuple)}")
|
||||
logger.info(f"len(example_tuple[0]): {len(example_tuple[0])}")
|
||||
logger.info(f"len(example_tuple[1]): {len(example_tuple[1])}")
|
||||
for i in range(len(prompts)):
|
||||
prompt_dict = prompts[i]
|
||||
if isinstance(prompt_dict, str):
|
||||
@@ -5520,23 +5516,18 @@ def sample_images_common(
|
||||
|
||||
if '__caption__' in prompt_dict.get("prompt") and example_tuple:
|
||||
logger.info(f"Original prompt: {prompt_dict.get('prompt')}")
|
||||
if len(example_tuple[1]) > 1:
|
||||
while example_tuple[1][idx] == '':
|
||||
idx = (idx + 1) % len(example_tuple[1])
|
||||
if idx == 0:
|
||||
break
|
||||
prompt_dict["prompt"] = f"{example_tuple[1][idx]}"
|
||||
logger.info(f"Replacement prompt: {example_tuple[1][idx]}")
|
||||
prompt_dict["height"] = example_tuple[0].shape[2] * 8
|
||||
prompt_dict["width"] = example_tuple[0].shape[3] * 8
|
||||
prompt_dict["original_lantent"] = example_tuple[0][idx].unsqueeze(0)
|
||||
idx = (idx + 1) % len(example_tuple[1])
|
||||
else:
|
||||
prompt_dict["prompt"] = f"{example_tuple[1]}"
|
||||
logger.info(f"Replacement prompt: {example_tuple[1]}")
|
||||
prompt_dict["height"] = example_tuple[0].shape[2] * 8
|
||||
prompt_dict["width"] = example_tuple[0].shape[3] * 8
|
||||
prompt_dict["original_lantent"] = example_tuple[0].unsqueeze(0)
|
||||
|
||||
while example_tuple[1][idx] == '':
|
||||
idx = (idx + 1) % len(example_tuple[1])
|
||||
if idx == 0:
|
||||
break
|
||||
prompt_dict["prompt"] = f"{example_tuple[1][idx]}"
|
||||
logger.info(f"Replacement prompt: {example_tuple[1][idx]}")
|
||||
prompt_dict["height"] = example_tuple[0].shape[2] * 8
|
||||
prompt_dict["width"] = example_tuple[0].shape[3] * 8
|
||||
prompt_dict["original_lantent"] = example_tuple[0][idx].unsqueeze(0)
|
||||
idx = (idx + 1) % len(example_tuple[1])
|
||||
|
||||
prompt_dict["enum"] = i
|
||||
prompt_dict.pop("subset", None)
|
||||
prompts[i] = prompt_dict
|
||||
|
||||
Reference in New Issue
Block a user