はじめに
Z Image Truboに関してはこちら。 github.com
NVlabs/Sanaに関してはこちら。 github.com
結果
Z Image Turboの結果

NVlabs/Sanaの結果

「HuggingFace」の文字が破綻しています。
しかも文字が浮いています。
Pythonスクリプト
Z Image Turbo
import os os.environ["UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS"] = "1" import torch from diffusers import ZImagePipeline pipe = ZImagePipeline.from_pretrained( "Tongyi-MAI/Z-Image-Turbo", torch_dtype=torch.bfloat16 ) pipe.enable_model_cpu_offload(device="xpu") prompt = 'Ultra-realistic, high-quality photo of an anthropomorphic capybara with a tough, streetwise attitude, wearing a worn black leather jacket, dark sunglasses, and ripped jeans. The capybara is leaning casually against a gritty urban wall covered in vibrant graffiti. Behind it, in bold, dripping yellow spray paint, the word "HuggingFace" is scrawled in large street-art style letters. The scene is set in a dimly lit alleyway with moody lighting, scattered trash, and an edgy, rebellious vibe — like a character straight out of an underground comic book.' image = pipe( prompt, height=1024, width=1024, num_inference_steps=9, guidance_scale=0.0, generator=torch.manual_seed(42), ).images[0] image.save("zimage.png")
Sana
import torch from diffusers import SanaPAGPipeline pipe = SanaPAGPipeline.from_pretrained( "Efficient-Large-Model/Sana_1600M_1024px_BF16_diffusers", variant="bf16", torch_dtype=torch.bfloat16, pag_applied_layers="transformer_blocks.8", ).to("xpu") prompt = 'Ultra-realistic, high-quality photo of an anthropomorphic capybara with a tough, streetwise attitude, wearing a worn black leather jacket, dark sunglasses, and ripped jeans. The capybara is leaning casually against a gritty urban wall covered in vibrant graffiti. Behind it, in bold, dripping yellow spray paint, the word "HuggingFace" is scrawled in large street-art style letters. The scene is set in a dimly lit alleyway with moody lighting, scattered trash, and an edgy, rebellious vibe — like a character straight out of an underground comic book.' image = pipe( prompt=prompt, guidance_scale=5.0, pag_scale=2.0, num_inference_steps=20, generator=torch.manual_seed(42), )[0] image[0].save("with_pag.jpg")
環境構築
それぞれのpyproject.tomlを示します。
Z Image Turbo
[project] name = "zimage" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.13" dependencies = [ "accelerate==1.12.0", "diffusers==0.36.0", "hf-xet==1.2.0", "pytorch-triton-xpu==3.5.0", "torch==2.9.1+xpu", "transformers==4.57.3", ] [[tool.uv.index]] name = "torch-xpu" url = "https://download.pytorch.org/whl/xpu" explicit = true [tool.uv.sources] torch = [{ index = "torch-xpu" }] pytorch-triton-xpu = [{ index = "torch-xpu" }]
Sana
[project] name = "sana" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.13" dependencies = [ "accelerate==1.12.0", "beautifulsoup4==4.14.3", "diffusers==0.35.2", "ftfy==6.3.1", "hf-xet==1.2.0", "pytorch-triton-xpu==3.5.0", "torch==2.9.1+xpu", "transformers==4.57.3", ] [[tool.uv.index]] name = "torch-xpu" url = "https://download.pytorch.org/whl/xpu" explicit = true [tool.uv.sources] torch = [{ index = "torch-xpu" }] pytorch-triton-xpu = [{ index = "torch-xpu" }]