diff --git a/examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py b/examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py index 235113d6a348..51b96ec72f10 100644 --- a/examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py +++ b/examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py @@ -227,7 +227,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None autocast_ctx = nullcontext() with autocast_ctx: diff --git a/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py b/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py index 86891d5d7f0c..41ab1eb660d7 100644 --- a/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py +++ b/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py @@ -1883,7 +1883,11 @@ def compute_text_embeddings(prompt, text_encoders, tokenizers): pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = ( + torch.Generator(device=accelerator.device).manual_seed(args.seed) + if args.seed is not None + else None + ) pipeline_args = {"prompt": args.validation_prompt} if torch.backends.mps.is_available(): @@ -1987,7 +1991,9 @@ def compute_text_embeddings(prompt, text_encoders, tokenizers): ) # run inference pipeline = pipeline.to(accelerator.device) - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = ( + torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None + ) images = [ pipeline(args.validation_prompt, num_inference_steps=25, generator=generator).images[0] for _ in range(args.num_validation_images) diff --git a/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py b/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py index 6e4f40c22df9..5ec028026364 100644 --- a/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py +++ b/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py @@ -269,7 +269,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # Currently the context determination is a bit hand-wavy. We can improve it in the future if there's a better # way to condition it. Reference: https://github.com/huggingface/diffusers/pull/7126#issuecomment-1968523051 if torch.backends.mps.is_available() or "playground" in args.pretrained_model_name_or_path: diff --git a/examples/cogvideo/train_cogvideox_image_to_video_lora.py b/examples/cogvideo/train_cogvideox_image_to_video_lora.py index aaee133680ea..eed8305f4fbc 100644 --- a/examples/cogvideo/train_cogvideox_image_to_video_lora.py +++ b/examples/cogvideo/train_cogvideox_image_to_video_lora.py @@ -722,7 +722,7 @@ def log_validation( # pipe.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None videos = [] for _ in range(args.num_validation_videos): diff --git a/examples/cogvideo/train_cogvideox_lora.py b/examples/cogvideo/train_cogvideox_lora.py index 01ea59c593a9..74ea98cbac5e 100644 --- a/examples/cogvideo/train_cogvideox_lora.py +++ b/examples/cogvideo/train_cogvideox_lora.py @@ -739,7 +739,7 @@ def log_validation( # pipe.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None videos = [] for _ in range(args.num_validation_videos): diff --git a/examples/custom_diffusion/train_custom_diffusion.py b/examples/custom_diffusion/train_custom_diffusion.py index dc21746cb159..ea1449f9f382 100644 --- a/examples/custom_diffusion/train_custom_diffusion.py +++ b/examples/custom_diffusion/train_custom_diffusion.py @@ -1334,7 +1334,9 @@ def main(args): # run inference if args.validation_prompt and args.num_validation_images > 0: - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = ( + torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None + ) images = [ pipeline(args.validation_prompt, num_inference_steps=25, generator=generator, eta=1.0).images[0] for _ in range(args.num_validation_images) diff --git a/examples/dreambooth/train_dreambooth_flux.py b/examples/dreambooth/train_dreambooth_flux.py index 9fcdc5ee2cb0..66f533e52a8a 100644 --- a/examples/dreambooth/train_dreambooth_flux.py +++ b/examples/dreambooth/train_dreambooth_flux.py @@ -172,7 +172,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # autocast_ctx = torch.autocast(accelerator.device.type) if not is_final_validation else nullcontext() autocast_ctx = nullcontext() diff --git a/examples/dreambooth/train_dreambooth_lora.py b/examples/dreambooth/train_dreambooth_lora.py index 83a24b778083..07b14e1ddc0c 100644 --- a/examples/dreambooth/train_dreambooth_lora.py +++ b/examples/dreambooth/train_dreambooth_lora.py @@ -150,7 +150,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None if args.validation_images is None: images = [] diff --git a/examples/dreambooth/train_dreambooth_lora_flux.py b/examples/dreambooth/train_dreambooth_lora_flux.py index 91e028251a1d..dda3300d65cc 100644 --- a/examples/dreambooth/train_dreambooth_lora_flux.py +++ b/examples/dreambooth/train_dreambooth_lora_flux.py @@ -181,7 +181,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # autocast_ctx = torch.autocast(accelerator.device.type) if not is_final_validation else nullcontext() autocast_ctx = nullcontext() diff --git a/examples/dreambooth/train_dreambooth_lora_lumina2.py b/examples/dreambooth/train_dreambooth_lora_lumina2.py index 778b0bc59c65..a8bf4e1cdc61 100644 --- a/examples/dreambooth/train_dreambooth_lora_lumina2.py +++ b/examples/dreambooth/train_dreambooth_lora_lumina2.py @@ -167,7 +167,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None autocast_ctx = torch.autocast(accelerator.device.type) if not is_final_validation else nullcontext() with autocast_ctx: diff --git a/examples/dreambooth/train_dreambooth_lora_sana.py b/examples/dreambooth/train_dreambooth_lora_sana.py index 798980e86b5e..674cb0d1ad1e 100644 --- a/examples/dreambooth/train_dreambooth_lora_sana.py +++ b/examples/dreambooth/train_dreambooth_lora_sana.py @@ -170,7 +170,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None images = [pipeline(**pipeline_args, generator=generator).images[0] for _ in range(args.num_validation_images)] diff --git a/examples/dreambooth/train_dreambooth_lora_sd3.py b/examples/dreambooth/train_dreambooth_lora_sd3.py index 65e7dac26bdd..4a08daaf61f7 100644 --- a/examples/dreambooth/train_dreambooth_lora_sd3.py +++ b/examples/dreambooth/train_dreambooth_lora_sd3.py @@ -199,7 +199,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # autocast_ctx = torch.autocast(accelerator.device.type) if not is_final_validation else nullcontext() autocast_ctx = nullcontext() diff --git a/examples/dreambooth/train_dreambooth_lora_sdxl.py b/examples/dreambooth/train_dreambooth_lora_sdxl.py index 29e8d85efc9d..f0d993ad9bbc 100644 --- a/examples/dreambooth/train_dreambooth_lora_sdxl.py +++ b/examples/dreambooth/train_dreambooth_lora_sdxl.py @@ -207,7 +207,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # Currently the context determination is a bit hand-wavy. We can improve it in the future if there's a better # way to condition it. Reference: https://github.com/huggingface/diffusers/pull/7126#issuecomment-1968523051 if torch.backends.mps.is_available() or "playground" in args.pretrained_model_name_or_path: diff --git a/examples/dreambooth/train_dreambooth_sd3.py b/examples/dreambooth/train_dreambooth_sd3.py index b99a81a4073a..7a16b64e7d05 100644 --- a/examples/dreambooth/train_dreambooth_sd3.py +++ b/examples/dreambooth/train_dreambooth_sd3.py @@ -175,7 +175,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None # autocast_ctx = torch.autocast(accelerator.device.type) if not is_final_validation else nullcontext() autocast_ctx = nullcontext() diff --git a/examples/text_to_image/train_text_to_image_lora_sdxl.py b/examples/text_to_image/train_text_to_image_lora_sdxl.py index f71e4a71bb90..2061f0c6775b 100644 --- a/examples/text_to_image/train_text_to_image_lora_sdxl.py +++ b/examples/text_to_image/train_text_to_image_lora_sdxl.py @@ -137,7 +137,7 @@ def log_validation( pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None pipeline_args = {"prompt": args.validation_prompt} if torch.backends.mps.is_available(): autocast_ctx = nullcontext() diff --git a/examples/text_to_image/train_text_to_image_sdxl.py b/examples/text_to_image/train_text_to_image_sdxl.py index 7b32c4420856..29da1f2efbaa 100644 --- a/examples/text_to_image/train_text_to_image_sdxl.py +++ b/examples/text_to_image/train_text_to_image_sdxl.py @@ -1241,7 +1241,11 @@ def compute_time_ids(original_size, crops_coords_top_left): pipeline.set_progress_bar_config(disable=True) # run inference - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = ( + torch.Generator(device=accelerator.device).manual_seed(args.seed) + if args.seed is not None + else None + ) pipeline_args = {"prompt": args.validation_prompt} with autocast_ctx: @@ -1305,7 +1309,9 @@ def compute_time_ids(original_size, crops_coords_top_left): images = [] if args.validation_prompt and args.num_validation_images > 0: pipeline = pipeline.to(accelerator.device) - generator = torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed else None + generator = ( + torch.Generator(device=accelerator.device).manual_seed(args.seed) if args.seed is not None else None + ) with autocast_ctx: images = [