From 5e10e11dfc25e557cb3cee1773d94e8e193ad9cc Mon Sep 17 00:00:00 2001 From: Artiprocher Date: Mon, 20 Apr 2026 14:31:26 +0800 Subject: [PATCH] refine code --- .../Template-KleinBase4B-Age.py | 36 ++++++++++++------ .../Template-KleinBase4B-Age.py | 37 +++++++++++++------ 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/examples/flux2/model_inference/Template-KleinBase4B-Age.py b/examples/flux2/model_inference/Template-KleinBase4B-Age.py index e01268e..f1d1bef 100644 --- a/examples/flux2/model_inference/Template-KleinBase4B-Age.py +++ b/examples/flux2/model_inference/Template-KleinBase4B-Age.py @@ -17,15 +17,27 @@ template = TemplatePipeline.from_pretrained( device="cuda", model_configs=[ModelConfig(model_id="DiffSynth-Studio/Template-KleinBase4B-Age")], ) -prompt = "Half body color photograph of a single woman, head and torso with visible arms and hands resting gently in front of the body, looking directly at the camera, centered composition, colorful studio background with soft gradient of warm pastel tones, vibrant studio lighting, wearing a plain red short-sleeve t-shirt, straight black shoulder-length hair, photorealistic, high quality"# prompt = "Full body photograph of a single woman standing, looking directly at the camera, centered composition, plain neutral gray background, soft even studio lighting, wearing a plain white short-sleeve t-shirt and blue jeans, barefoot, arms resting naturally at sides, straight black shoulder-length hair, photorealistic, high quality" -negative_age = 45 -for age in range(10, 91, 5): - print(f"Generating age {age}...") - image = template( - pipe, - prompt=prompt, - seed=0, cfg_scale=4, num_inference_steps=50, - template_inputs=[{"age": age}], - negative_template_inputs=[{"age": negative_age}], - ) - image.save(f"image_age_{age}.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 20}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_20.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 50}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_50.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 80}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_80.jpg") diff --git a/examples/flux2/model_inference_low_vram/Template-KleinBase4B-Age.py b/examples/flux2/model_inference_low_vram/Template-KleinBase4B-Age.py index 8cc6342..6fbbdf0 100644 --- a/examples/flux2/model_inference_low_vram/Template-KleinBase4B-Age.py +++ b/examples/flux2/model_inference_low_vram/Template-KleinBase4B-Age.py @@ -1,6 +1,7 @@ from diffsynth.diffusion.template import TemplatePipeline from diffsynth.pipelines.flux2_image import Flux2ImagePipeline, ModelConfig import torch + vram_config = { "offload_dtype": "disk", "offload_device": "disk", @@ -28,15 +29,27 @@ template = TemplatePipeline.from_pretrained( model_configs=[ModelConfig(model_id="DiffSynth-Studio/Template-KleinBase4B-Age")], lazy_loading=True, ) -prompt = "Half body color photograph of a single woman, head and torso with visible arms and hands resting gently in front of the body, looking directly at the camera, centered composition, colorful studio background with soft gradient of warm pastel tones, vibrant studio lighting, wearing a plain red short-sleeve t-shirt, straight black shoulder-length hair, photorealistic, high quality" -negative_age = 45 -for age in range(10, 91, 5): - print(f"Generating age {age}...") - image = template( - pipe, - prompt=prompt, - seed=0, cfg_scale=4, num_inference_steps=50, - template_inputs=[{"age": age}], - negative_template_inputs=[{"age": negative_age}], - ) - image.save(f"image_age_{age}.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 20}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_20.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 50}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_50.jpg") +image = template( + pipe, + prompt="A portrait of a woman with black hair, wearing a suit.", + seed=0, cfg_scale=4, num_inference_steps=50, + template_inputs=[{"age": 80}], + negative_template_inputs=[{"age": 45}], +) +image.save(f"image_age_80.jpg")