diff --git a/library/train_util.py b/library/train_util.py index 83ae5122..4d644f9e 100644 --- a/library/train_util.py +++ b/library/train_util.py @@ -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