以下の内容はhttps://touch-sp.hateblo.jp/entry/2026/02/22/141540より取得しました。


【Arc B580】FLUX.2 klein-4B を使ってみる

はじめに

Arc A770を使った時のfloat64の問題には遭遇しませんでした。

touch-sp.hateblo.jp

PC環境

Ubuntu 25.10

Python環境構築

uvを使っています。pyproject.tomlを載せておきます。

uv sync で環境構築できると思います。

[project]
name = "flux2klein"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "accelerate==1.12.0",
    "diffusers @ git+https://github.com/huggingface/diffusers",
    "hf-xet==1.2.0",
    "torch==2.10.0+xpu",
    "torchvision==0.25.0+xpu",
    "triton-xpu==3.6.0",
    "transformers==5.2.0"
]

[[tool.uv.index]]
name = "torch-xpu"
url = "https://download.pytorch.org/whl/xpu"
explicit = true

[tool.uv.sources]
torch = [{ index = "torch-xpu" }]
torchvision = [{ index = "torch-xpu" }]
triton-xpu = [{ index = "torch-xpu" }]

Pythonコード

import torch
from diffusers import Flux2KleinPipeline

pipe = Flux2KleinPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein-4B",
    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. 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,
    height=1024,
    width=1024,
    guidance_scale=1.0,
    num_inference_steps=4,
    generator=torch.manual_seed(0)
).images[0]

image.save("klein4b-result.jpg")




以上の内容はhttps://touch-sp.hateblo.jp/entry/2026/02/22/141540より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14