Created
February 15, 2026 20:04
-
-
Save AmericanPresidentJimmyCarter/82e9cf036540c791be8b5993992886f2 to your computer and use it in GitHub Desktop.
various inference scripts for newer models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import QwenImageEditPlusPipeline | |
| def load_pipeline(model_path: str) -> QwenImageEditPlusPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = QwenImageEditPlusPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "FireRedTeam/FireRed-Image-Edit-1.0" | |
| INPUT_FILE_DRESS = "together_raw_1024.png" | |
| INPUT_FILE_WOMAN = "woman_upscaled.png" | |
| PROMPT = "Dress hero shot. A close-up detail editorial photograph focusing on the waist and skirt section of the reference dress worn by the woman in a minimalist studio. Background is seamless off-white #F5F5F5. The shot highlights the fabric drape and stitching details. Soft studio light. Kodak film 400 grain." | |
| RESOLUTION = 1536 | |
| CFG_VALUES = [1.0, 3.0] | |
| SEEDS = [10, 20, 30, 40, 50, 60, 70, 80] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("final_shots") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| dress_image = Image.open(INPUT_FILE_DRESS).convert("RGB") | |
| woman_image = Image.open(INPUT_FILE_WOMAN).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| inputs = { | |
| "image": [dress_image, woman_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": RESOLUTION+512, | |
| "width": RESOLUTION, | |
| "true_cfg_scale": cfg, | |
| "negative_prompt": "", | |
| "num_inference_steps": 40, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=4) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import QwenImageEditPlusPipeline | |
| def load_pipeline(model_path: str) -> QwenImageEditPlusPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = QwenImageEditPlusPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "FireRedTeam/FireRed-Image-Edit-1.0" | |
| INPUT_FILE_DRESS = "together_raw_1024.png" | |
| INPUT_FILE_WOMAN = "woman_upscaled.png" | |
| PROMPT = "Dress the model in the one-piece dress from Image 1. Match the same style and texture as in Image 1. The woman is in a minimalist studio. Her hair is fastened up. Background is seamless off-white #F5F5F5. The sharp focus is specifically on the fabric texture, neckline, and details of the reference dress. Soft studio light. Kodak film 400 grain." | |
| RESOLUTION = 1536 | |
| CFG_VALUES = [1.0, 3.0] | |
| SEEDS = [10, 20, 30, 40, 50, 60, 70, 80] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("final_shots_2") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| dress_image = Image.open(INPUT_FILE_DRESS).convert("RGB") | |
| woman_image = Image.open(INPUT_FILE_WOMAN).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| inputs = { | |
| "image": [dress_image, woman_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": RESOLUTION+512, | |
| "width": RESOLUTION, | |
| "true_cfg_scale": cfg, | |
| "negative_prompt": "", | |
| "num_inference_steps": 40, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=4) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import os | |
| from pathlib import Path | |
| import torch | |
| from PIL import Image | |
| from diffusers import QwenImageEditPlusPipeline | |
| def load_pipeline(model_path: str) -> QwenImageEditPlusPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = QwenImageEditPlusPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "FireRedTeam/FireRed-Image-Edit-1.0" | |
| INPUT_FILE_DRESS = "dress.png" | |
| INPUT_FILE_WOMAN = "woman.png" | |
| PROMPT = "Dress hero shot. A close-up detail editorial photograph focusing on the waist and skirt section of the reference dress worn by the woman in a minimalist studio. Background is seamless off-white #F5F5F5. The shot highlights the fabric drape and stitching details. Soft studio light. Kodak film 400 grain." | |
| NEGATIVE_PROMPT = "" | |
| # Sweep Parameters | |
| RESOLUTIONS = [ | |
| #1024, | |
| 1280, 1536, 1792, 2048] | |
| CFG_SCALES = [1.0, 2.0, 3.0, 4.0, 5.0] | |
| # Setup Output | |
| output_dir = Path("sweep_results") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| print(f"Pipeline loaded onto {pipeline.device}") | |
| # Start Sweep | |
| dress_image = Image.open(INPUT_FILE_DRESS).convert("RGB") | |
| woman_image = Image.open(INPUT_FILE_WOMAN).convert("RGB") | |
| SEED = 12345 | |
| for res in RESOLUTIONS: | |
| # Resize image to the target sweep resolution | |
| for cfg in CFG_SCALES: | |
| file_name = f"res{res}_cfg{cfg}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| inputs = { | |
| "image": [dress_image, woman_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(SEED), | |
| "height": res, | |
| "width": res, | |
| "true_cfg_scale": cfg, | |
| "negative_prompt": NEGATIVE_PROMPT, | |
| "num_inference_steps": 40, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| # Save result | |
| result.images[0].save(save_path) | |
| print(f"\nSweep complete! Results saved in: {output_dir.resolve()}") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import Flux2KleinPipeline | |
| def load_pipeline(model_path: str) -> Flux2KleinPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = Flux2KleinPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "black-forest-labs/FLUX.2-klein-base-9B" | |
| INPUT_FILE_ORIGINAL_IMAGE = "417_radiant_see_combined.png" | |
| INPUT_FILE_PERFUME_BOTTLE = "417_radiant_see.png" | |
| # PROMPT = "Dress the model in the one-piece dress from Image 1. Match the same style and texture as in Image 1. The woman is in a minimalist studio. Her hair is fastened up. Background is seamless off-white #F5F5F5. The sharp focus is specifically on the fabric texture, neckline, and details of the reference dress. Soft studio light. Kodak film 400 grain." | |
| PROMPT = "Add proper bokeh for the woman's face and make the perfume bottle clearer. The image features a luxury skincare serum in a sleek, tapered glass bottle with a sophisticated dark amber gradient that fades toward a thick, clear base. The bottle is topped with a tiered, metallic gold dropper cap that adds an elegant, high-end feel. All the text is printed in a matching gold serif font, beginning with the brand logo \"-417\" at the top, followed by the underlined collection name \"RADIANT SEE\" Near the bottom, the product is identified as the \"EXTREME GLOW NOURISHING FACE SERUM\" in clear, all-caps lettering." | |
| # RESOLUTION = 1536 | |
| CFG_VALUES = [2.5, 3.5] | |
| SEEDS = [10, 20, 30, 40, 50, 60, 70, 80] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("klein_perfume_base") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| input_image = Image.open(INPUT_FILE_ORIGINAL_IMAGE).convert("RGB") | |
| perfume_image = Image.open(INPUT_FILE_PERFUME_BOTTLE).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| w, h = input_image.size | |
| inputs = { | |
| "image": [input_image, perfume_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": h, | |
| "width": w, | |
| "guidance_scale": cfg, | |
| # "negative_prompt": "", | |
| "num_inference_steps": 50, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=4) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import Flux2KleinPipeline | |
| def load_pipeline(model_path: str) -> Flux2KleinPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = Flux2KleinPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "black-forest-labs/FLUX.2-klein-base-9B" | |
| INPUT_FILE_ORIGINAL_IMAGE = "face_for_perfume.png" | |
| INPUT_FILE_PERFUME_BOTTLE = "417_radiant_see.png" | |
| # PROMPT = "Dress the model in the one-piece dress from Image 1. Match the same style and texture as in Image 1. The woman is in a minimalist studio. Her hair is fastened up. Background is seamless off-white #F5F5F5. The sharp focus is specifically on the fabric texture, neckline, and details of the reference dress. Soft studio light. Kodak film 400 grain." | |
| PROMPT = "high definition product photography of this woman holding up this perfume bottle, centered on her face with her hand in frame holding it up close. you can clearly read the text on the perfume bottle." | |
| # RESOLUTION = 1536 | |
| CFG_VALUES = [2.5, 3.5] | |
| SEEDS = [10, 20, 30, 40, 50, 60, 70, 80] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("klein_perfume_base_remake") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| input_image = Image.open(INPUT_FILE_ORIGINAL_IMAGE).convert("RGB") | |
| perfume_image = Image.open(INPUT_FILE_PERFUME_BOTTLE).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| w, h = input_image.size | |
| inputs = { | |
| "image": [input_image, perfume_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": h, | |
| "width": w, | |
| "guidance_scale": cfg, | |
| # "negative_prompt": "", | |
| "num_inference_steps": 50, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=4) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import Flux2KleinPipeline | |
| def load_pipeline(model_path: str) -> Flux2KleinPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = Flux2KleinPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "black-forest-labs/FLUX.2-klein-9B" | |
| INPUT_FILE_ORIGINAL_IMAGE = "417_radiant_see_combined.png" | |
| INPUT_FILE_PERFUME_BOTTLE = "417_radiant_see.png" | |
| # PROMPT = "Dress the model in the one-piece dress from Image 1. Match the same style and texture as in Image 1. The woman is in a minimalist studio. Her hair is fastened up. Background is seamless off-white #F5F5F5. The sharp focus is specifically on the fabric texture, neckline, and details of the reference dress. Soft studio light. Kodak film 400 grain." | |
| PROMPT = "Add proper bokeh for the woman's face and make the perfume bottle clearer. The image features a luxury skincare serum in a sleek, tapered glass bottle with a sophisticated dark amber gradient that fades toward a thick, clear base. The bottle is topped with a tiered, metallic gold dropper cap that adds an elegant, high-end feel. All the text is printed in a matching gold serif font, beginning with the brand logo \"-417\" at the top, followed by the underlined collection name \"RADIANT SEE\" Near the bottom, the product is identified as the \"EXTREME GLOW NOURISHING FACE SERUM\" in clear, all-caps lettering." | |
| # RESOLUTION = 1536 | |
| CFG_VALUES = [1.0] | |
| SEEDS = [10, 20, 30, 40, 50, 60, 70, 80] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("klein_perfume") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| input_image = Image.open(INPUT_FILE_ORIGINAL_IMAGE).convert("RGB") | |
| perfume_image = Image.open(INPUT_FILE_PERFUME_BOTTLE).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| w, h = input_image.size | |
| inputs = { | |
| "image": [input_image, perfume_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": h, | |
| "width": w, | |
| "guidance_scale": cfg, | |
| # "negative_prompt": "", | |
| "num_inference_steps": 4, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=4) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import torch | |
| from pathlib import Path | |
| from PIL import Image | |
| from diffusers import Flux2KleinPipeline | |
| def load_pipeline(model_path: str) -> Flux2KleinPipeline: | |
| """Load FireRed image edit pipeline.""" | |
| pipe = Flux2KleinPipeline.from_pretrained( | |
| model_path, | |
| torch_dtype=torch.bfloat16, | |
| cache_dir="./models", | |
| ) | |
| pipe.to("cuda") | |
| return pipe | |
| def create_grid(images, rows, cols): | |
| """Helper to create a single large image grid.""" | |
| w, h = images[0].size | |
| grid = Image.new('RGB', size=(cols * w, rows * h)) | |
| for i, img in enumerate(images): | |
| grid.paste(img, box=(i % cols * w, i // cols * h)) | |
| return grid | |
| def main(): | |
| # --- Configuration --- | |
| MODEL_ID = "black-forest-labs/FLUX.2-klein-base-9B" | |
| INPUT_FILE_FACE = "vton2/vton_face.png" | |
| INPUT_FILE_PANTSUIT = "vton2/vton_pants.jpeg" | |
| INPUT_FILE_BG = "vton2/vton_bg.jpeg" | |
| # PROMPT = "high definition product photography of this woman wearing this pantsuit on this background." | |
| # PROMPT = "176cm height woman\nwearing outfit\nfront full body\nbackground\na bit from the knee low shot" | |
| PROMPT = "176cm height woman\nwearing a two-piece loungewear set in a monochromatic black color, consisting of a short-sleeved t-shirt and matching wide-leg pants. Both garments are crafted from a textured fabric featuring an all-over, tonal embossed pattern of the \"DKNY\" logo repeated in horizontal rows. The top has a classic crew neckline and a standard fit, while the pants feature an elasticized waistband and a relaxed, straight-leg cut that drapes down to the ankles.\nfront full body\nbackground\na bit from the knee low shot" | |
| # RESOLUTION = 1536 | |
| CFG_VALUES = [2.5, 3.5] | |
| SEEDS = [10, 20, 30, 40] # 8 distinct seeds | |
| # Setup Output | |
| output_dir = Path("klein_perfume_base_vton") | |
| output_dir.mkdir(exist_ok=True) | |
| # Load Pipeline | |
| pipeline = load_pipeline(MODEL_ID) | |
| # Load Inputs | |
| face_image = Image.open(INPUT_FILE_FACE).convert("RGB") | |
| suit_image = Image.open(INPUT_FILE_PANTSUIT).convert("RGB") | |
| bg_image = Image.open(INPUT_FILE_BG).convert("RGB") | |
| for cfg in CFG_VALUES: | |
| cfg_images = [] | |
| print(f"\n--- Starting Sweep for CFG: {cfg} ---") | |
| for seed in SEEDS: | |
| file_name = f"cfg{cfg}_seed{seed}.png" | |
| save_path = output_dir / file_name | |
| print(f"Generating: {file_name}") | |
| inputs = { | |
| "image": [face_image, suit_image, bg_image], | |
| "prompt": PROMPT, | |
| "generator": torch.Generator(device="cuda").manual_seed(seed), | |
| "height": 2048, | |
| "width": 1536, | |
| "guidance_scale": cfg, | |
| # "negative_prompt": "", | |
| "num_inference_steps": 50, | |
| "num_images_per_prompt": 1, | |
| } | |
| with torch.inference_mode(): | |
| result = pipeline(**inputs) | |
| img = result.images[0] | |
| # Save individual image | |
| img.save(save_path) | |
| cfg_images.append(img) | |
| # Create and save the grid for this CFG (2 rows of 4 images) | |
| grid_img = create_grid(cfg_images, rows=2, cols=2) | |
| grid_path = output_dir / f"GRID_cfg{cfg}_all_seeds.jpg" | |
| grid_img.save(grid_path, quality=95) | |
| print(f"Grid saved for CFG {cfg} at: {grid_path}") | |
| print(f"\nAll tasks complete. Check the '{output_dir}' folder.") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from diffusers import QwenImageEditPlusPipeline | |
| import torch | |
| from PIL import Image | |
| # Load the pipeline | |
| pipeline = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511", cache_dir="./models") | |
| pipeline.to(torch.bfloat16) | |
| pipeline.to("cuda") | |
| # Load trained LoRA weights for in-scene editing | |
| pipeline.load_lora_weights("valiantcat/Qwen-Image-Edit-2511-Upscale2K", weight_name="qwen_image_edit_2511_upscale.safetensors", cache_dir="./models") | |
| # Load input image | |
| image = Image.open("vton2/vton_pants_512.png").convert("RGB") | |
| # Define in-scene editing prompt | |
| prompt = "Upscale this picture to 4K resolution." | |
| # Generate edited image with enhanced scene understanding | |
| inputs = { | |
| "image": image, | |
| "prompt": prompt, | |
| "generator": torch.manual_seed(12345), | |
| "true_cfg_scale": 2.5, | |
| "negative_prompt": " ", | |
| "num_inference_steps": 50, | |
| "height": 2048, | |
| "width": 1024, | |
| } | |
| with torch.inference_mode(): | |
| output = pipeline(**inputs) | |
| output_image = output.images[0] | |
| output_image.save("edited_image5.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment