From 8b828ced27414bd4c3078a5a5301c217a1a1f41d Mon Sep 17 00:00:00 2001 From: Anthony Wu Date: Wed, 30 Apr 2025 22:00:33 -0700 Subject: [PATCH 1/3] In-Context generation: allow lora composition --- src/mflux/flux/flux_initializer.py | 2 +- src/mflux/generate_in_context.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mflux/flux/flux_initializer.py b/src/mflux/flux/flux_initializer.py index ba918fe..b101920 100644 --- a/src/mflux/flux/flux_initializer.py +++ b/src/mflux/flux/flux_initializer.py @@ -85,7 +85,7 @@ class FluxInitializer: lora_weights = WeightHandlerLoRA.load_lora_weights( transformer=flux_model.transformer, lora_files=lora_paths + hf_lora_paths, - lora_scales=lora_scales, + lora_scales=lora_scales + [1.0] * len(hf_lora_paths), ) WeightHandlerLoRA.set_lora_weights( transformer=flux_model.transformer, diff --git a/src/mflux/generate_in_context.py b/src/mflux/generate_in_context.py index c80810e..d574882 100644 --- a/src/mflux/generate_in_context.py +++ b/src/mflux/generate_in_context.py @@ -25,7 +25,7 @@ def main(): quantize=args.quantize, lora_names=[get_lora_filename(args.lora_style)] if args.lora_style else None, lora_repo_id=LORA_REPO_ID if args.lora_style else None, - lora_paths=args.lora_paths if not args.lora_style else None, + lora_paths=args.lora_paths, lora_scales=args.lora_scales, ) From 219290541ab7bc7fbe91943c025e9282e495923e Mon Sep 17 00:00:00 2001 From: Anthony Wu Date: Wed, 30 Apr 2025 22:01:22 -0700 Subject: [PATCH 2/3] nit: ignore uv sync's uv.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 64907ac..dc21f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .env.production.local .venv +*.lock # created by uv sync *.png *.jpg *.pyc From 136b76de01ceffbd5ae8ae4af01abb2adc140c29 Mon Sep 17 00:00:00 2001 From: Anthony Wu Date: Thu, 1 May 2025 00:34:49 -0700 Subject: [PATCH 3/3] propose --save-full-image option --- src/mflux/generate_in_context.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mflux/generate_in_context.py b/src/mflux/generate_in_context.py index d574882..8ad2cb9 100644 --- a/src/mflux/generate_in_context.py +++ b/src/mflux/generate_in_context.py @@ -1,3 +1,5 @@ +from pathlib import Path + from mflux import Config, StopImageGenerationException from mflux.callbacks.callback_registry import CallbackRegistry from mflux.callbacks.instances.memory_saver import MemorySaver @@ -17,6 +19,12 @@ def main(): parser.add_image_generator_arguments(supports_metadata_config=True) parser.add_image_to_image_arguments(required=True) parser.add_output_arguments() + parser.add_argument( + "--save-full-image", + action="store_true", + default=False, + help="Additionally, save the full image containing the reference image. Useful for verifying the in-context usage of the reference image.", + ) args = parser.parse_args() # 1. Load the model @@ -58,7 +66,10 @@ def main(): ), ) # 4. Save the image - image.get_right_half().save(path=args.output.format(seed=seed), export_json_metadata=args.metadata) + output_path = Path(args.output.format(seed=seed)) + image.get_right_half().save(path=output_path, export_json_metadata=args.metadata) + if args.save_full_image: + image.save(path=output_path.with_stem(output_path.stem + "_full")) except StopImageGenerationException as stop_exc: print(stop_exc) finally: