Skip to content

Commit

Permalink
Merge pull request #454 from bghira/main
Browse files Browse the repository at this point in the history
better error message for text embed failure | fix for pipeline unload deleting pipeline before unloading the weights | sd3: use 64px interval for bucketing instead of 8px
  • Loading branch information
bghira authored Jun 14, 2024
2 parents 2d56370 + 4ab50c3 commit e40f40a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
7 changes: 6 additions & 1 deletion helpers/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,11 +1519,16 @@ def parse_args(input_args=None):
logger.info(f"Text Cache location: {args.cache_dir_text}")
else:
deepfloyd_pixel_alignment = 8
if args.aspect_bucket_alignment != deepfloyd_pixel_alignment:
if not args.sd3 and args.aspect_bucket_alignment != deepfloyd_pixel_alignment:
logger.warning(
f"Overriding aspect bucket alignment pixel interval to {deepfloyd_pixel_alignment}px instead of {args.aspect_bucket_alignment}px."
)
args.aspect_bucket_alignment = deepfloyd_pixel_alignment
elif args.sd3:
logger.warning(
"Stable Diffusion 3 requires a pixel alignment interval of 64px. Updating value."
)
args.aspect_bucket_alignment = 64

if "deepfloyd-stage2" in args.model_type and args.resolution < 256:
logger.warning(
Expand Down
12 changes: 9 additions & 3 deletions helpers/caching/sdxl_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@ def compute_embeddings_for_sdxl_prompts(
f"\n-> id: {self.id}, data_backend id: {self.data_backend.id}"
)
should_encode = True
raise Exception("This won't work. We cannot continue.")
raise Exception(
"Cache retrieval for text embed file failed. Ensure your dataloader config value for skip_file_discovery does not contain 'text', and that preserve_data_backend_cache is disabled or unset."
)
if should_encode:
# If load_from_cache is True, should_encode would be False unless we failed to load.
# self.debug_log(f"Encoding prompt: {prompt}")
Expand Down Expand Up @@ -704,7 +706,9 @@ def compute_embeddings_for_legacy_prompts(
f"\n-> error: {e}"
)
should_encode = True
raise Exception("This won't work. We cannot continue.")
raise Exception(
"Cache retrieval for text embed file failed. Ensure your dataloader config value for skip_file_discovery does not contain 'text', and that preserve_data_backend_cache is disabled or unset."
)

if should_encode:
# self.debug_log(f"Encoding prompt: {prompt}")
Expand Down Expand Up @@ -822,7 +826,9 @@ def compute_embeddings_for_sd3_prompts(
f"\n-> id: {self.id}, data_backend id: {self.data_backend.id}"
)
should_encode = True
raise Exception("This won't work. We cannot continue.")
raise Exception(
"Cache retrieval for text embed file failed. Ensure your dataloader config value for skip_file_discovery does not contain 'text', and that preserve_data_backend_cache is disabled or unset."
)
if should_encode:
# If load_from_cache is True, should_encode would be False unless we failed to load.
self.debug_log(f"Encoding prompt: {prompt}")
Expand Down
6 changes: 3 additions & 3 deletions inference_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ def combine_and_label_images(images_info, output_path):
# Generate image with specified settings
settings = pipeline_info.get("settings", {})
image = pipeline(prompt, generator=manual_seed(420420420), **settings).images[0]
# Unload LoRA weights if they were loaded
if "lora" in pipeline_info:
pipeline.unload_lora_weights()
del pipeline
image.save(image_path, format="PNG")

images_info.append((image, pipeline_info["label"]))

# Unload LoRA weights if they were loaded
if "lora" in pipeline_info:
pipeline.unload_lora_weights()

# Combine and label images
combine_and_label_images(images_info, f"{target_dir}/combined_image.png")

0 comments on commit e40f40a

Please sign in to comment.