はじめに
「anzu_flux」はこちらです。huggingface.co
結果
左がbeta01、右がbeta02です。個人的にはbeta02が好みです(笑)。
Pythonスクリプト
使い方はこちらを見て下さい。touch-sp.hatenablog.com
VRAM 12GBで実行可能です。
import torch from diffusers import BitsAndBytesConfig, FluxTransformer2DModel, FluxPipeline from decorator import gpu_monitor, time_monitor from pathlib import Path def main(model_id:str) -> None: nf4_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16, ) model_nf4 = FluxTransformer2DModel.from_pretrained( model_id, subfolder="transformer", quantization_config=nf4_config, torch_dtype=torch.bfloat16 ) pipe = FluxPipeline.from_pretrained( model_id, transformer=model_nf4, torch_dtype=torch.bfloat16 ) pipe.enable_model_cpu_offload() save_folder = f"image_from_{model_id}" Path(save_folder).mkdir(exist_ok=True) for i, seed in enumerate([12345, 67890, 123456]): generator = torch.Generator().manual_seed(seed) image = pipe( prompt="A photorealistic portrait of a young Japanese woman with long black hair and natural makeup, wearing a casual white blouse, sitting in a modern Tokyo cafe with soft window light", width=1360, height=768, num_inference_steps=50, generator=generator, guidance_scale=3.5, ).images[0] file_name = f"{i}.jpg" image.save(Path(save_folder, file_name).as_posix()) if __name__ == "__main__": main("anzu_flux_mix_beta01") main("anzu_flux_mix_beta02")