Buckets:

mishig's picture
download
raw
98.7 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;FLUX 3 Image Klein&quot;,&quot;local&quot;:&quot;flux-3-image-klein&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;프롬프트 업샘플링&quot;,&quot;local&quot;:&quot;prompt-upsampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;이미지-이미지&quot;,&quot;local&quot;:&quot;image-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;레이아웃 제어&quot;,&quot;local&quot;:&quot;layout-control&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;가이던스 스케일&quot;,&quot;local&quot;:&quot;guidance-scale&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Step-distilled model&quot;,&quot;local&quot;:&quot;step-distilled-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;재현 가능한 생성&quot;,&quot;local&quot;:&quot;reproducible-generation&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;워크플로&quot;,&quot;local&quot;:&quot;workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;단계별 콜백&quot;,&quot;local&quot;:&quot;per-step-callbacks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;메모리&quot;,&quot;local&quot;:&quot;memory&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;단일 파일 로딩&quot;,&quot;local&quot;:&quot;single-file-loading&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3ModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.Flux3ModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3AutoBlocks&quot;,&quot;local&quot;:&quot;diffusers.Flux3AutoBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3DistilledAutoBlocks&quot;,&quot;local&quot;:&quot;diffusers.Flux3DistilledAutoBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3DistilledModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.Flux3DistilledModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/diffusers/main/en/_app/immutable/entry/start.vZc-dOUR.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/Bafuik5c.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/Bupkjr9f.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/entry/app.B6c3Ml05.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CyvZ3FS5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/l0QnnOED.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DnVIJfC5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/0.BQlx092V.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CoSrdQax.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/180.Dy0d8VKm.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B4AMoTAu.js" rel="modulepreload">
<!--hchutw--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;FLUX 3 Image Klein&quot;,&quot;local&quot;:&quot;flux-3-image-klein&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Prompt upsampling&quot;,&quot;local&quot;:&quot;prompt-upsampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Image-to-image&quot;,&quot;local&quot;:&quot;image-to-image&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Layout control&quot;,&quot;local&quot;:&quot;layout-control&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Guidance scale&quot;,&quot;local&quot;:&quot;guidance-scale&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Step-distilled model&quot;,&quot;local&quot;:&quot;step-distilled-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Reproducible generation&quot;,&quot;local&quot;:&quot;reproducible-generation&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Workflows&quot;,&quot;local&quot;:&quot;workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Per-step callbacks&quot;,&quot;local&quot;:&quot;per-step-callbacks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Memory&quot;,&quot;local&quot;:&quot;memory&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Single-file loading&quot;,&quot;local&quot;:&quot;single-file-loading&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3ModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.Flux3ModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3AutoBlocks&quot;,&quot;local&quot;:&quot;diffusers.Flux3AutoBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3DistilledAutoBlocks&quot;,&quot;local&quot;:&quot;diffusers.Flux3DistilledAutoBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Flux3DistilledModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.Flux3DistilledModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/diffusers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <!--[0--><h1 class="relative group"><a id="flux-3-image-klein" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#flux-3-image-klein"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->FLUX 3 Image Klein<!----></span></h1><!--]--><!----> <p>FLUX 3 Image Klein은 Black Forest Labs의 5.6B 이미지 생성 모델입니다. 단일 트랜스포머(<a href="/docs/diffusers/main/ko/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel">Flux3Transformer2DModel</a>)가 텍스트 프롬프트로부터 이미지를 생성하며, 단독으로 또는 하나 이상의 참조 이미지와 함께 사용할 수 있습니다. 텍스트 조건부는 Qwen3-VL에서 제공되며, 이미지는 FLUX.2 packed autoencoder(<code>AutoencoderKLFlux2</code>)를 사용합니다.</p> <p>FLUX 3 Image Klein은 <a href="../../modular_diffusers/overview">모듈형 파이프라인</a>으로 제공됩니다. 텍스트-이미지 생성으로 시작해 보세요:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipe(
prompt=<span class="hljs-string">&quot;A red fox in a snow-covered forest clearing at golden hour&quot;</span>,
generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>),
output=<span class="hljs-string">&quot;images&quot;</span>,
)[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;fox.png&quot;</span>)<!----></pre></div><!----> <p><code>prompt</code>는 유일한 필수 입력값입니다. 파이프라인은 권장 샘플링 설정(50 steps, guidance scale 3.5, scheduler shift 6.93)을 적용하고 기본적으로 1024 x 1024 크기의 이미지를 생성합니다. 호출당 하나의 프롬프트만 처리하며, 동일한 프롬프트로 여러 이미지를 생성하려면 <code>num_images_per_prompt</code>를 사용하세요.</p> <p>위 예시에서 볼 수 있듯이, 로딩 및 실행 방식이 <code>DiffusionPipeline</code>과 약간 다릅니다. 로딩은 지연됩니다: <a href="/docs/diffusers/main/ko/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained">from_pretrained()</a>는 파이프라인을 빌드할 뿐이며, 가중치를 로드하려면 <a href="/docs/diffusers/main/ko/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a>를 호출해야 합니다. 호출 시 파이프라인 상태가 반환되며, 필요한 항목을 <code>output</code>으로 요청합니다. 여기서는 <code>output="images"</code>를 사용하거나, 프롬프트 업샘플러가 작성한 캡션도 함께 얻으려면 <code>output=["images", "prompt"]</code>를 사용할 수 있습니다.</p> <blockquote class="tip"><p><code>ModularPipeline</code>를 처음 사용하신다면 <a href="../../modular_diffusers/quickstart">빠른 시작</a>을 읽고, 표준 파이프라인에 익숙하시다면 <a href="../../modular_diffusers/coming_from_diffusion_pipeline">DiffusionPipeline에서 넘어오신 분을 위한 안내</a>를 참고하세요. 로딩과 출력 외에도 몇 가지 다른 부분이 있습니다: <a href="#guidance-scale">가이던스</a>, <a href="#per-step-callbacks">콜백</a>, <a href="#memory">오프로딩</a>.</p></blockquote> <!--[1--><h2 class="relative group"><a id="prompt-upsampling" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#prompt-upsampling"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->프롬프트 업샘플링<!----></span></h2><!--]--><!----> <p>프롬프팅이 중요합니다: FLUX 3 Image Klein은 짧은 프롬프트가 아니라 주제, 구도, 조명, 분위기를 설명하는 전체 장면 캡션을 사용합니다. 입력한 대로 요청을 보내면 범용적인 결과가 생성됩니다. 이 때문에 파이프라인은 텍스트-이미지 생성과 편집을 가리지 않고 모든 요청에 대해 먼저 프롬프트 업샘플러를 실행합니다. 이는 Black Forest Labs의 <a href="https://huggingface.co/black-forest-labs/flux-3-image-klein-pup" rel="nofollow">black-forest-labs/flux-3-image-klein-pup</a>라는 별개의 9B 모델로, 텍스트 인코더에 전달하기 전에 <code>prompt</code>를 이러한 캡션으로 확장하며, 짧은 프롬프트만 있으면 충분합니다.</p> <p>The prompt upsampler turns a short request, together with the reference images when editing, into the full scene caption the model takes: medium and style, scene, lighting and camera, each subject with its colors, materials and position in the frame. One model covers text-to-image, editing with reference images and layout with boxes. The caption it wrote comes back as the <code>prompt</code> output. In the example above, ask for it alongside the images to see what the image model received:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->out = pipe(
prompt=<span class="hljs-string">&quot;A red fox in a snow-covered forest clearing at golden hour&quot;</span>,
generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>),
output=[<span class="hljs-string">&quot;images&quot;</span>, <span class="hljs-string">&quot;prompt&quot;</span>],
)
<span class="hljs-built_in">print</span>(out[<span class="hljs-string">&quot;prompt&quot;</span>])<!----></pre></div><!----> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class=" "><!---->Full-color outdoor wildlife photograph taken <span class="hljs-built_in">from</span> <span class="hljs-keyword">a</span> low eye-level perspective <span class="hljs-keyword">in</span> <span class="hljs-keyword">a</span> snow-covered forest clearing <span class="hljs-keyword">at</span> golden hour. In <span class="hljs-keyword">the</span> center foreground, <span class="hljs-keyword">a</span> red fox stands <span class="hljs-keyword">in</span> profile facing left, its body turned toward <span class="hljs-keyword">the</span> viewer <span class="hljs-keyword">and</span> its head raised <span class="hljs-keyword">as</span> <span class="hljs-keyword">it</span> looks across <span class="hljs-keyword">the</span> clearing. The fox has dense rust-red winter fur, <span class="hljs-keyword">a</span> white throat <span class="hljs-keyword">and</span> chest, <span class="hljs-keyword">black</span> <span class="hljs-built_in">lower</span> legs, pointed ears <span class="hljs-keyword">with</span> dark tips, <span class="hljs-keyword">and</span> <span class="hljs-keyword">a</span> <span class="hljs-keyword">long</span> bushy tail ending <span class="hljs-keyword">in</span> white. ...<!----></pre></div><!----> <p>전체 캡션은 약 240단어로 구성되며, <code>max_new_tokens</code>가 그 길이를 제한합니다(기본값은 3584).</p> <p>단계의 <code>doc</code>을 출력하여 해당 단계가 어떤 값을 입력받고 어떤 값을 작성하는지 확인할 수 있습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-built_in">print</span>(pipe.blocks.sub_blocks[<span class="hljs-string">&quot;prompt_upsampler&quot;</span>].doc)<!----></pre></div><!----> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class=" "><!----> <span class="hljs-symbol">Inputs</span>:
prompt (<span class="hljs-string">`str`</span>):
<span class="hljs-symbol">The</span> edit instruction to expand into the full caption (one per call).
image (<span class="hljs-string">`Image | list`</span>, *optional*):
<span class="hljs-symbol">The</span> reference image(s) of the edit, at most <span class="hljs-number">10</span>; the same ones the pipeline receives.
boxes (<span class="hljs-string">`list`</span>, *optional*):
<span class="hljs-symbol">Layout</span> boxes, each {<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;desc&#x27;</span>, <span class="hljs-string">&#x27;from&#x27;</span>, <span class="hljs-string">&#x27;src_bbox&#x27;</span>, <span class="hljs-string">&#x27;tgt_bbox&#x27;</span>} with the boxes as [y_min, x_min, y_max, x_max] in
<span class="hljs-number">0</span><span class="hljs-number">-1</span>: ...
max_new_tokens (<span class="hljs-string">`int`</span>, *optional*, defaults to <span class="hljs-number">3584</span>):
<span class="hljs-symbol">The</span> most tokens the upsampler may generate for the caption.
<span class="hljs-symbol">Outputs</span>:
prompt (<span class="hljs-string">`str`</span>):
<span class="hljs-symbol">The</span> full caption, replacing the request.<!----></pre></div><!----> <p>파이프라인의 다른 블록과 마찬가지로 <code>prompt_upsampler</code> 블록도 독립적으로 실행됩니다. 권장되는 방법은 블록에서 해당 블록을 분리(pop)하는 것입니다. 분리된 블록은 독립적인 업샘플러가 되고, 나머지 블록은 확장된 캡션을 <code>prompt</code>로 받는 파이프라인이 됩니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->blocks = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>).blocks
pup_block = blocks.sub_blocks.pop(<span class="hljs-string">&quot;prompt_upsampler&quot;</span>)
pup = pup_block.init_pipeline(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pup.load_components(dtype=torch.bfloat16)
pup.to(<span class="hljs-string">&quot;cuda&quot;</span>)
caption = pup(prompt=<span class="hljs-string">&quot;A red fox in a snow-covered forest clearing at golden hour&quot;</span>, output=<span class="hljs-string">&quot;prompt&quot;</span>)
pipe = blocks.init_pipeline(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipe(prompt=caption, generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>), output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>이렇게 하면 별도의 단계로, 자체 GPU에서 또는 자체 엔드포인트 뒤에 배치하여 서빙할 수 있으며, UI에서 생성된 캡션을 표시하고 생성 전에 사용자가 편집할 수 있습니다. 동일한 시스템 프롬프트를 사용하여 다른 LLM으로 업샘플러를 대체할 수 있습니다. 업샘플러 저장소에서 <code>system_prompts["t2i"]</code>(또는 <code>"i2i"</code>, 이 경우 참조 이미지가 사용자 메시지에 먼저 위치해야 함)를 시스템 프롬프트로, 요청을 사용자 메시지로 전달하고, 반환된 캡션을 <code>pipe</code>의 <code>prompt</code>로 전달하면 됩니다.</p> <!--[1--><h2 class="relative group"><a id="image-to-image" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#image-to-image"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->이미지-이미지<!----></span></h2><!--]--><!----> <p><code>image</code>로 하나 이상의 참조 이미지를 전달합니다. 단일 참조 이미지는 그대로 유지되며, 4메가픽셀을 초과할 경우에만 축소되고 16픽셀 그리드에 패딩되며, 생성은 기본적으로 해당 이미지의 크기를 따르므로 편집 결과가 입력 이미지와 동일한 크기로 반환됩니다. 여러 참조 이미지는 각각 1메가픽셀 이하로 조정되고 그리드에 맞게 크롭되며, 생성은 기본적으로 첫 번째 이미지의 크기를 따릅니다. 지정된 <code>height</code>/<code>width</code> 값은 기본값을 덮어씁니다. <em>대상</em> 이미지를 편집 지시문 한 줄이 아니라, 편집 내용을 참조 이미지의 캡션에 통합한 완전한 캡션으로 설명하거나, <a href="#prompt-upsampling">prompt upsampler</a>가 지시문과 참조 이미지를 바탕으로 캡션을 작성하도록 하세요:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->night = pipe(
prompt=<span class="hljs-string">&quot;the same scene at night under a full moon&quot;</span>,
image=image,
generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>),
output=[<span class="hljs-string">&quot;images&quot;</span>, <span class="hljs-string">&quot;prompt&quot;</span>],
)<!----></pre></div><!----> <p>여러 개의 참조 이미지가 있는 경우, <code>image</code>에 전달된 순서대로 첫 번째 이미지, 두 번째 이미지, …라고 지칭합니다. 이미지 모델에서는 캡션이 <code>&lt;ref_image_0></code>, <code>&lt;ref_image_1></code>, …로 이름을 붙입니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->combined = pipe(
prompt=<span class="hljs-string">&quot;the fox from the first image sitting on the wooden bench from the second image&quot;</span>,
image=[image, bench],
height=<span class="hljs-number">768</span>,
width=<span class="hljs-number">1360</span>,
output=<span class="hljs-string">&quot;images&quot;</span>,
)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>파생된 크기를 재정의하려면 <code>height</code> 및/또는 <code>width</code>를 전달하세요.</p> <!--[1--><h2 class="relative group"><a id="layout-control" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#layout-control"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->레이아웃 제어<!----></span></h2><!--]--><!----> <p>내용을 명시적으로 배치하려면 <code>boxes</code>를 전달합니다. 각 요소에 대해 <code>id</code>, 짧은 <code>desc</code>, 그리고 0-1 범위의 <code>bbox</code>인 <code>[y_min, x_min, y_max, x_max]</code>를 지정합니다(좌상단을 원점으로 하며, 출력 크기와 무관합니다). 업샘플러는 캡션을 해당 요소 주위에 작성하고 각 요소를 <code>&lt;id></code>로 인용하며, 제공된 박스 테이블을 그대로 유지하여 추가합니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->boxes = [
{<span class="hljs-string">&quot;id&quot;</span>: <span class="hljs-string">&quot;balloon_1&quot;</span>, <span class="hljs-string">&quot;desc&quot;</span>: <span class="hljs-string">&quot;a red and yellow striped hot-air balloon&quot;</span>, <span class="hljs-string">&quot;bbox&quot;</span>: [<span class="hljs-number">0.08</span>, <span class="hljs-number">0.06</span>, <span class="hljs-number">0.48</span>, <span class="hljs-number">0.38</span>]},
{<span class="hljs-string">&quot;id&quot;</span>: <span class="hljs-string">&quot;balloon_2&quot;</span>, <span class="hljs-string">&quot;desc&quot;</span>: <span class="hljs-string">&quot;a small blue hot-air balloon&quot;</span>, <span class="hljs-string">&quot;bbox&quot;</span>: [<span class="hljs-number">0.20</span>, <span class="hljs-number">0.62</span>, <span class="hljs-number">0.42</span>, <span class="hljs-number">0.80</span>]},
]
out = pipe(prompt=<span class="hljs-string">&quot;hot-air balloons over a green valley at sunrise&quot;</span>, boxes=boxes, output=[<span class="hljs-string">&quot;images&quot;</span>, <span class="hljs-string">&quot;prompt&quot;</span>])<!----></pre></div><!----> <p>편집 시, 박스는 <code>from</code>로 소스를 지정합니다. <code>"target"</code>에 <code>tgt_bbox</code>를 추가하면 해당 위치에 새 요소를 추가하고, <code>"ref_image_0"</code>에 <code>src_bbox</code>와 <code>tgt_bbox</code>를 지정하면 해당 참조 이미지의 요소를 이동합니다(상자 크기가 같으면 제자리에 유지):</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->boxes = [{<span class="hljs-string">&quot;id&quot;</span>: <span class="hljs-string">&quot;cactus&quot;</span>, <span class="hljs-string">&quot;desc&quot;</span>: <span class="hljs-string">&quot;a small potted cactus&quot;</span>, <span class="hljs-string">&quot;from&quot;</span>: <span class="hljs-string">&quot;target&quot;</span>, <span class="hljs-string">&quot;src_bbox&quot;</span>: <span class="hljs-literal">None</span>, <span class="hljs-string">&quot;tgt_bbox&quot;</span>: [<span class="hljs-number">0.55</span>, <span class="hljs-number">0.62</span>, <span class="hljs-number">0.85</span>, <span class="hljs-number">0.85</span>]}]
out = pipe(prompt=<span class="hljs-string">&quot;add a small potted cactus in the marked spot&quot;</span>, image=mug, boxes=boxes, output=[<span class="hljs-string">&quot;images&quot;</span>, <span class="hljs-string">&quot;prompt&quot;</span>])
boxes = [{<span class="hljs-string">&quot;id&quot;</span>: <span class="hljs-string">&quot;knight&quot;</span>, <span class="hljs-string">&quot;desc&quot;</span>: <span class="hljs-string">&quot;the knight figure&quot;</span>, <span class="hljs-string">&quot;from&quot;</span>: <span class="hljs-string">&quot;ref_image_0&quot;</span>, <span class="hljs-string">&quot;src_bbox&quot;</span>: [<span class="hljs-number">0.50</span>, <span class="hljs-number">0.15</span>, <span class="hljs-number">0.85</span>, <span class="hljs-number">0.35</span>], <span class="hljs-string">&quot;tgt_bbox&quot;</span>: [<span class="hljs-number">0.19</span>, <span class="hljs-number">0.06</span>, <span class="hljs-number">0.54</span>, <span class="hljs-number">0.26</span>]}]
out = pipe(prompt=<span class="hljs-string">&quot;move the knight up and to the left, keep the rest unchanged&quot;</span>, image=knight, boxes=boxes, output=[<span class="hljs-string">&quot;images&quot;</span>, <span class="hljs-string">&quot;prompt&quot;</span>])<!----></pre></div><!----> <p>이미지 모델이 읽는 캡션에는 텍스트에 <code>&lt;id></code>로 태그된 요소와 0-1000 캔버스에 박스가 매핑된 테이블이 JSON으로 추가되어 있습니다. <code>prompt</code> 출력을 출력하면 이를 확인할 수 있습니다. 해당 형식으로 수동으로 작성된 캡션은 <a href="#prompt-upsampling">Prompt upsampling</a>의 예와 같이 해당 단계 없이 파이프라인으로 전달됩니다.</p> <!--[1--><h2 class="relative group"><a id="guidance-scale" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#guidance-scale"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->가이던스 스케일<!----></span></h2><!--]--><!----> <p>pipeline은 <code>guider</code> 구성 요소를 통해 classifier-free guidance를 적용하며, 호출 시점에 <code>guidance_scale</code> 인수를 받지 않습니다. 기본 guider는 두 워크플로우 모두에 권장되는 설정인 <code>guidance_scale=3.5</code>를 가진 <a href="/docs/diffusers/main/ko/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance">ClassifierFreeGuidance</a>입니다. 이를 변경하려면 guider의 업데이트된 사본을 생성합니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->pipe.guider = pipe.guider.new(guidance_scale=<span class="hljs-number">5.0</span>)<!----></pre></div><!----> <p>다른 guidance 방식으로 전환하려면 <a href="../../using-diffusers/guiders">guiders 가이드</a>를 참조하세요.</p> <!--[1--><h2 class="relative group"><a id="step-distilled-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#step-distilled-model"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Step-distilled model<!----></span></h2><!--]--><!----> <p>Step-distilled 체크포인트는 classifier-free guidance 없이 16단계로 생성됩니다. 해당 transformer는 flow map입니다: 각 단계에서 현재 timestep과 해당 단계가 건너뛰는 대상 timestep을 전달받습니다. 베이스 모델과 동일한 방식으로 로드됩니다(리포지토리의 <code>modular_model_index.json</code>은 <a href="/docs/diffusers/main/ko/api/pipelines/flux3#diffusers.Flux3DistilledModularPipeline">Flux3DistilledModularPipeline</a>과 <a href="/docs/diffusers/main/ko/api/pipelines/flux3#diffusers.Flux3DistilledAutoBlocks">Flux3DistilledAutoBlocks</a>로 해석됩니다). 파이프라인에는 <code>guider</code>가 없으며 <code>negative_prompt</code>를 받지 않습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein&quot;</span>)
pipe.load_components(dtype=torch.bfloat16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipe(prompt=prompt, generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>), output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>기본 모델과 동일한 두 가지 워크플로를 제공합니다. <code>num_inference_steps</code>의 기본값은 16이며, 모델은 4~16단계로 학습됩니다.</p> <!--[1--><h2 class="relative group"><a id="reproducible-generation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#reproducible-generation"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->재현 가능한 생성<!----></span></h2><!--]--><!----> <p><code>generator</code>는 파이프라인이 추출하는 노이즈를 고정합니다(<a href="../../using-diffusers/reusing_seeds">재현성</a> 참조). 다른 곳에서 추출한 노이즈를 재사용하려면 <code>latents</code>로 <code>(batch_size, 128, height // 16, width // 16)</code> 형상의 값을 전달하세요. 예를 들어, <a href="https://github.com/black-forest-labs/flux-3" rel="nofollow">BFL 구현</a>은 CPU에서 노이즈를 이미지 토큰으로 추출하고 이를 bf16으로 캐스팅합니다. 이를 통해 주어진 시드에서 해당 샘플을 재현할 수 있습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->height, width = <span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>
h, w = height // <span class="hljs-number">16</span>, width // <span class="hljs-number">16</span>
noise = torch.randn((h * w, <span class="hljs-number">128</span>), generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>)).to(torch.bfloat16)
latents = noise.T.reshape(<span class="hljs-number">1</span>, <span class="hljs-number">128</span>, h, w)
image = pipe(prompt=prompt, latents=latents, height=height, width=width, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="workflows" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#workflows"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->워크플로<!----></span></h2><!--]--><!----> <p>The pipeline serves two workflows, <code>text2image</code> and <code>image_conditioned</code>; the one that runs is picked by the inputs (<code>image</code> selects image-to-image). <a href="/docs/diffusers/main/ko/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained">from_pretrained()</a> can also build a pipeline for one workflow with the <code>workflow</code> argument, which then only expects and loads the components that workflow needs:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> diffusers.modular_pipelines <span class="hljs-keyword">import</span> Flux3AutoBlocks
<span class="hljs-built_in">print</span>(Flux3AutoBlocks().available_workflows)
<span class="hljs-comment"># [&quot;text2image&quot;, &quot;image_conditioned&quot;]</span>
t2i = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>, workflow=<span class="hljs-string">&quot;text2image&quot;</span>)
<span class="hljs-built_in">print</span>(t2i.blocks.doc)<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="per-step-callbacks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#per-step-callbacks"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->단계별 콜백<!----></span></h2><!--]--><!----> <p>기존 콜백 함수를 사용하려면 디노이징 루프에 블록을 삽입합니다. <a href="../../using-diffusers/callback#modular-pipelines">콜백 가이드</a>에는 <code>CallbackOnStepEnd</code> 블록과 <code>walk_denoise_loops</code> 헬퍼를 사용한 간단한 예제가 있습니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->blocks = Flux3AutoBlocks() <span class="hljs-comment"># or Flux3DistilledAutoBlocks</span>
<span class="hljs-keyword">for</span> loop <span class="hljs-keyword">in</span> walk_denoise_loops(blocks):
loop.sub_blocks[<span class="hljs-string">&quot;callback&quot;</span>] = CallbackOnStepEnd()
pipe = blocks.init_pipeline(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
image = pipe(prompt=caption, callback_on_step_end=my_callback, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>조기 종료를 하려면 콜백에서 예외를 발생시키세요. <code>interrupt</code> 플래그는 없습니다.</p> <!--[1--><h2 class="relative group"><a id="memory" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#memory"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->메모리<!----></span></h2><!--]--><!----> <p>bf16로 모든 것을 로드하면 약 39 GB의 가중치가 필요합니다. 트랜스포머는 5.5B 파라미터, Qwen3-VL-4B 텍스트 인코더는 4B, <a href="#prompt-upsampling">prompt upsampler</a>는 9B(약 19 GB)이며, 이미지 VAE는 fp32로 로드됩니다. upsampler 단계 없이 빌드된 파이프라인(해당 섹션 참조)은 약 20 GB를 로드합니다. 메모리가 적은 GPU의 경우 구성 요소 오프로딩을 활성화하세요. 매니저는 각 단계가 필요할 때 구성 요소를 CPU와 GPU 사이로 이동하며, upsampler도 포함됩니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentsManager, ModularPipeline
manager = ComponentsManager()
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>, components_manager=manager)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
manager.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="single-file-loading" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#single-file-loading"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->단일 파일 로딩<!----></span></h2><!--]--><!----> <p><a href="/docs/diffusers/main/ko/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel">Flux3Transformer2DModel</a>은 <a href="/docs/diffusers/main/ko/api/loaders/single_file#diffusers.loaders.FromOriginalModelMixin.from_single_file">from_single_file()</a>을 통해 Black Forest Labs 모델 패키지에서 transformer를 직접 로드합니다. 패키지 내의 <code>config.json</code>는 읽지 않으므로, <code>config</code>와 <code>subfolder</code>를 전달하여 diffusers 설정을 지정해야 합니다.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Flux3Transformer2DModel, ModularPipeline
transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
dtype=torch.bfloat16,
)
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.update_components(transformer=transformer)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)<!----></pre></div><!----> <p><code>names</code> 없이 <a href="/docs/diffusers/main/ko/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a>를 호출하면 파이프라인 저장소에서 transformer도 함께 로드되므로, 먼저 이름으로 다른 구성 요소를 로드하세요:</p> <p>FP8r 및 NVFP4 단일 파일 체크포인트 로딩도 지원됩니다. 두 방식 모두 <a href="/docs/diffusers/main/ko/api/quantization#diffusers.BFLQuantizationConfig">BFLQuantizationConfig</a>를 사용하여 동일한 호출을 통해 로드됩니다. 각 스킴의 커널 요구 사항은 <a href="../../quantization/bfl">BFL 양자화 가이드</a>를 참조하세요.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> BFLQuantizationConfig
transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/variants/nvfp4/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)<!----></pre></div><!----> <p>step-distilled 체크포인트를 로드할 때, 해당 구성(<code>flow_map=True</code>)이 필요합니다:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!---->transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein/blob/main/variants/nvfp4/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="diffusers.Flux3ModularPipeline" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#diffusers.Flux3ModularPipeline"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Flux3ModularPipeline<!----></span></h2><!--]--><!----> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><div><span class="group flex space-x-1.5 items-center text-gray-800 bg-gradient-to-r rounded-tr-lg -mt-4 -ml-4 pt-3 px-2.5" id="diffusers.Flux3ModularPipeline"><!----><h3 class="!m-0"><span class="flex-1 break-all md:text-lg bg-gradient-to-r px-2.5 py-1.5 rounded-xl from-indigo-50/70 to-white dark:from-gray-900 dark:to-gray-950 dark:text-indigo-300 text-indigo-700"><svg class="mr-1.5 text-indigo-500 inline-block -mt-0.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width=".8em" height=".8em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path class="uim-quaternary" d="M20.23 7.24L12 12L3.77 7.24a1.98 1.98 0 0 1 .7-.71L11 2.76c.62-.35 1.38-.35 2 0l6.53 3.77c.29.173.531.418.7.71z" opacity=".25" fill="currentColor"></path><path class="uim-tertiary" d="M12 12v9.5a2.09 2.09 0 0 1-.91-.21L4.5 17.48a2.003 2.003 0 0 1-1-1.73v-7.5a2.06 2.06 0 0 1 .27-1.01L12 12z" opacity=".5" fill="currentColor"></path><path class="uim-primary" d="M20.5 8.25v7.5a2.003 2.003 0 0 1-1 1.73l-6.62 3.82c-.275.13-.576.198-.88.2V12l8.23-4.76c.175.308.268.656.27 1.01z" fill="currentColor"></path></svg><span class="font-light">클래스</span> <span class="font-medium">diffusers.</span><span class="font-semibold">Flux3ModularPipeline</span></span></h3><!----> <a id="diffusers.Flux3ModularPipeline" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.Flux3ModularPipeline"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></a> <!--[0--><a class="!ml-auto !text-gray-400 !no-underline text-sm flex items-center" href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L24" target="_blank"><span>&lt;</span> <span class="hidden md:block mx-0.5 hover:!underline">source</span> <span>></span></a><!--]--></span> <!--[0--><p class="font-mono text-xs md:text-sm !leading-relaxed !my-6"><span>(</span> <!--[--><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">blocks<span class="opacity-60">: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">pretrained_model_name_or_path<span class="opacity-60">: str | os.PathLike | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">components_manager<span class="opacity-60">: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">collection<span class="opacity-60">: str | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">workflow<span class="opacity-60">: str | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">modular_config_dict<span class="opacity-60">: dict[str, typing.Any] | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">config_dict<span class="opacity-60">: dict[str, typing.Any] | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">**kwargs<span class="opacity-60"></span></span></span><!--]--> <span>)</span> <!--[-1--><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--></div></div><!----> <p>FLUX.3용 ModularPipeline.</p></div> <!--[1--><h2 class="relative group"><a id="diffusers.Flux3AutoBlocks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#diffusers.Flux3AutoBlocks"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Flux3AutoBlocks<!----></span></h2><!--]--><!----> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><div><span class="group flex space-x-1.5 items-center text-gray-800 bg-gradient-to-r rounded-tr-lg -mt-4 -ml-4 pt-3 px-2.5" id="diffusers.Flux3AutoBlocks"><!----><h3 class="!m-0"><span class="flex-1 break-all md:text-lg bg-gradient-to-r px-2.5 py-1.5 rounded-xl from-indigo-50/70 to-white dark:from-gray-900 dark:to-gray-950 dark:text-indigo-300 text-indigo-700"><svg class="mr-1.5 text-indigo-500 inline-block -mt-0.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width=".8em" height=".8em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path class="uim-quaternary" d="M20.23 7.24L12 12L3.77 7.24a1.98 1.98 0 0 1 .7-.71L11 2.76c.62-.35 1.38-.35 2 0l6.53 3.77c.29.173.531.418.7.71z" opacity=".25" fill="currentColor"></path><path class="uim-tertiary" d="M12 12v9.5a2.09 2.09 0 0 1-.91-.21L4.5 17.48a2.003 2.003 0 0 1-1-1.73v-7.5a2.06 2.06 0 0 1 .27-1.01L12 12z" opacity=".5" fill="currentColor"></path><path class="uim-primary" d="M20.5 8.25v7.5a2.003 2.003 0 0 1-1 1.73l-6.62 3.82c-.275.13-.576.198-.88.2V12l8.23-4.76c.175.308.268.656.27 1.01z" fill="currentColor"></path></svg><span class="font-light">클래스</span> <span class="font-medium">diffusers.</span><span class="font-semibold">Flux3AutoBlocks</span></span></h3><!----> <a id="diffusers.Flux3AutoBlocks" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.Flux3AutoBlocks"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></a> <!--[0--><a class="!ml-auto !text-gray-400 !no-underline text-sm flex items-center" href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3.py#L339" target="_blank"><span>&lt;</span> <span class="hidden md:block mx-0.5 hover:!underline">source</span> <span>></span></a><!--]--></span> <!--[0--><p class="font-mono text-xs md:text-sm !leading-relaxed !my-6"><span>(</span> <!--[--><!--]--> <span>)</span> <!--[-1--><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--></div></div><!----> <p>FLUX.3를 사용하여 텍스트-이미지 및 이미지-이미지 생성을 수행하는 Auto 블록입니다. <code>prompt</code>는 먼저 프롬프트 업샘플러를 통과합니다. <code>prompt_upsampler</code> 단계를 제거하면 주어진 그대로 인코딩됩니다.</p> <p>지원되는 워크플로:</p> <ul><li><code>text2image</code>: <code>prompt</code> 필수</li> <li><code>image_conditioned</code>: <code>prompt</code>, <code>image</code> 필수</li></ul> <p>구성 요소:
prompt_upsampler (<code>Qwen3_5ForConditionalGeneration</code>): 프롬프트 업샘플러. prompt_upsampler_processor
(<code>AutoProcessor</code>): 해당 프로세서. text_encoder (<code>Qwen3VLForConditionalGeneration</code>) tokenizer
(<code>AutoProcessor</code>) image_processor (<code>Flux3ImageProcessor</code>) vae (<code>AutoencoderKLFlux2</code>) transformer
(<code>Flux3Transformer2DModel</code>) scheduler (<code>FlowMatchEulerDiscreteScheduler</code>) guider (<code>ClassifierFreeGuidance</code>)</p> <p>입력:
prompt (<code>str</code>):
완전한 캡션으로 확장할 편집 지침(호출당 하나).
image (<code>Image | list</code>, <em>선택 사항</em>):
편집의 참조 이미지(최대 10개). 파이프라인이 받는 이미지와 동일합니다.
boxes (<code>list</code>, <em>선택 사항</em>):
레이아웃 박스. 각 요소는 {‘id’, ‘desc’, ‘from’, ‘src_bbox’, ‘tgt_bbox’} 형식이며, 박스는 0-1 범위의 [y_min, x_min, y_max, x_max]입니다. ‘from’: ‘target’이고 <code>tgt_bbox</code>가 있으면 해당 위치에 요소를 추가하고, ‘from’: ‘ref_image_0’, …이고 <code>src_bbox</code> 및 <code>tgt_bbox</code>가 있으면 참조 이미지에서 요소를 이동합니다.
max_new_tokens (<code>int</code>, <em>선택 사항</em>, 기본값 3584):
업샘플러가 캡션을 생성할 때 생성할 수 있는 최대 토큰 수.
negative_prompt (<code>str</code>, <em>선택 사항</em>):
생성을 유도하지 않을 프롬프트.
max_sequence_length (<code>int</code>, <em>선택 사항</em>, 기본값 8192):
프롬프트 토큰의 최대 수. 더 긴 프롬프트는 잘립니다.
text_encoder_out_layers (<code>tuple</code>, <em>선택 사항</em>, 기본값 (4, 8, 12, 16, 20, 24, 28, 32)):
텍스트 임베딩을 형성하기 위해 상태가 스택되는 텍스트 인코더의 숨겨진 레이어 인덱스.
num_images_per_prompt (<code>int</code>, <em>선택 사항</em>, 기본값 1):
프롬프트당 생성할 이미지 수.
image_cond_latents (<code>list</code>, <em>선택 사항</em>):
참조 이미지의 정규화된 패킹된 잠재 변수. 이미지당 하나씩, 각 텐서의 형상은 (B, C, height_i//16, width_i//16)입니다.
height (<code>int</code>, <em>선택 사항</em>, 워크플로에 따라 기본값 None 또는 1024):
생성된 이미지의 픽셀 단위 높이. 기본값은 첫 번째 참조 이미지의 자체 높이입니다.
width (<code>int</code>, <em>선택 사항</em>, 워크플로에 따라 기본값 None 또는 1024):
생성된 이미지의 픽셀 단위 너비. 기본값은 첫 번째 참조 이미지의 자체 너비입니다.
reference_crop (<code>list | NoneType</code>, <em>선택 사항</em>):
참조 이미지별로, 패딩된 캔버스 안의 참조 이미지 박스 또는 None. 전처리 단계에서 가져온 값입니다.
latents (<code>Tensor</code>):
이미지 생성을 위한 사전 생성된 노이즈 잠재 변수.
generator (<code>Generator</code>, <em>선택 사항</em>):
결정론적 생성을 위한 Torch 생성기.
num_inference_steps (<code>int</code>):
노이즈 제거 단계 수.
timesteps (<code>Tensor</code>):
노이즈 제거 과정의 타임스텝. (지정되면 <code>num_inference_steps</code>를 무시합니다)
sigmas (<code>list</code>, <em>선택 사항</em>):
노이즈 제거 과정의 사용자 지정 시그마. (지정되면 <code>num_inference_steps</code>를 무시합니다)
*<em>denoiser_input_fields (<code>None</code>,</em>선택 사항<em>):
디노이저의 조건부 모델 입력: 예: prompt_embeds, negative_prompt_embeds 등.
attention_kwargs (<code>dict</code>,</em>선택 사항<em>):
어텐션 프로세서용 추가 kwargs.
output_type (<code>str</code>,</em>선택 사항*, 기본값 pil):
출력 형식: ‘pil’, ‘np’, ‘pt’.</p> <p>Outputs:
images (<code>list</code>):
생성된 이미지.
latents (<code>Tensor</code>):
노이즈가 제거된 latents.</p></div> <!--[1--><h2 class="relative group"><a id="diffusers.Flux3DistilledAutoBlocks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#diffusers.Flux3DistilledAutoBlocks"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Flux3DistilledAutoBlocks<!----></span></h2><!--]--><!----> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><div><span class="group flex space-x-1.5 items-center text-gray-800 bg-gradient-to-r rounded-tr-lg -mt-4 -ml-4 pt-3 px-2.5" id="diffusers.Flux3DistilledAutoBlocks"><!----><h3 class="!m-0"><span class="flex-1 break-all md:text-lg bg-gradient-to-r px-2.5 py-1.5 rounded-xl from-indigo-50/70 to-white dark:from-gray-900 dark:to-gray-950 dark:text-indigo-300 text-indigo-700"><svg class="mr-1.5 text-indigo-500 inline-block -mt-0.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width=".8em" height=".8em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path class="uim-quaternary" d="M20.23 7.24L12 12L3.77 7.24a1.98 1.98 0 0 1 .7-.71L11 2.76c.62-.35 1.38-.35 2 0l6.53 3.77c.29.173.531.418.7.71z" opacity=".25" fill="currentColor"></path><path class="uim-tertiary" d="M12 12v9.5a2.09 2.09 0 0 1-.91-.21L4.5 17.48a2.003 2.003 0 0 1-1-1.73v-7.5a2.06 2.06 0 0 1 .27-1.01L12 12z" opacity=".5" fill="currentColor"></path><path class="uim-primary" d="M20.5 8.25v7.5a2.003 2.003 0 0 1-1 1.73l-6.62 3.82c-.275.13-.576.198-.88.2V12l8.23-4.76c.175.308.268.656.27 1.01z" fill="currentColor"></path></svg><span class="font-light">class</span> <span class="font-medium">diffusers.</span><span class="font-semibold">Flux3DistilledAutoBlocks</span></span></h3><!----> <a id="diffusers.Flux3DistilledAutoBlocks" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.Flux3DistilledAutoBlocks"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></a> <!--[0--><a class="!ml-auto !text-gray-400 !no-underline text-sm flex items-center" href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3_distilled.py#L258" target="_blank"><span>&lt;</span> <span class="hidden md:block mx-0.5 hover:!underline">source</span> <span>></span></a><!--]--></span> <!--[0--><p class="font-mono text-xs md:text-sm !leading-relaxed !my-6"><span>(</span> <!--[--><!--]--> <span>)</span> <!--[-1--><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--></div></div><!----> <p><code>prompt</code>를 프롬프트 업샘플러를 먼저 통과시킨 후, 텍스트-이미지 및 이미지-이미지 생성을 수행하는 Auto 블록입니다. 스텝 증류된 FLUX.3 모델(16단계, classifier-free guidance 없음)을 사용합니다. <code>prompt_upsampler</code> 단계를 제거하면 주어진 그대로 인코딩됩니다.</p> <p>지원되는 워크플로:</p> <ul><li><code>text2image</code>: <code>prompt</code> 필수</li> <li><code>image_conditioned</code>: <code>prompt</code>, <code>image</code> 필수</li></ul> <p>Components:
prompt_upsampler (<code>Qwen3_5ForConditionalGeneration</code>): 프롬프트 업샘플러. prompt_upsampler_processor
(<code>AutoProcessor</code>): 해당 프로세서. text_encoder (<code>Qwen3VLForConditionalGeneration</code>) tokenizer
(<code>AutoProcessor</code>) image_processor (<code>Flux3ImageProcessor</code>) vae (<code>AutoencoderKLFlux2</code>) transformer
(<code>Flux3Transformer2DModel</code>) scheduler (<code>FlowMatchEulerDiscreteScheduler</code>)</p> <p>입력:
prompt (<code>str</code>):
완전한 캡션으로 확장할 편집 지침(호출당 하나).
image (<code>Image | list</code>, <em>선택 사항</em>):
편집의 참조 이미지(최대 10개). 파이프라인이 받는 이미지와 동일합니다.
boxes (<code>list</code>, <em>선택 사항</em>):
레이아웃 박스. 각 요소는 {‘id’, ‘desc’, ‘from’, ‘src_bbox’, ‘tgt_bbox’} 형식이며, 박스는 0-1 범위의 [y_min, x_min, y_max, x_max]입니다. ‘from’: ‘target’이고 <code>tgt_bbox</code>가 있으면 해당 위치에 요소를 추가하고, ‘from’: ‘ref_image_0’, …이고 <code>src_bbox</code> 및 <code>tgt_bbox</code>가 있으면 참조 이미지에서 요소를 이동합니다.
max_new_tokens (<code>int</code>, <em>선택 사항</em>, 기본값 3584):
업샘플러가 캡션을 생성할 수 있는 최대 토큰 수.
max_sequence_length (<code>int</code>, <em>선택 사항</em>, 기본값 8192):
프롬프트 토큰의 최대 수. 더 긴 프롬프트는 잘립니다.
text_encoder_out_layers (<code>tuple</code>, <em>선택 사항</em>, 기본값 (4, 8, 12, 16, 20, 24, 28, 32)):
텍스트 임베딩을 형성하기 위해 상태가 스택되는 텍스트 인코더의 숨겨진 레이어 인덱스
num_images_per_prompt (<code>int</code>, <em>선택 사항</em>, 기본값 1):
프롬프트당 생성할 이미지 수.
image_cond_latents (<code>list</code>, <em>선택 사항</em>):
참조 이미지의 정규화된 패킹된 잠재 변수. 이미지당 하나씩, 각 텐서의 형상은 (B, C, height_i//16, width_i//16)입니다.
height (<code>int</code>, <em>선택 사항</em>, 워크플로에 따라 기본값 None 또는 1024):
생성된 이미지의 픽셀 단위 높이. 기본값은 첫 번째 참조 이미지의 자체 높이입니다.
width (<code>int</code>, <em>선택 사항</em>, 워크플로에 따라 기본값 None 또는 1024):
생성된 이미지의 픽셀 단위 너비. 기본값은 첫 번째 참조 이미지의 자체 너비입니다.
reference_crop (<code>list | NoneType</code>, <em>선택 사항</em>):
각 참조에 대해, 패딩된 캔버스 안의 참조 박스 또는 None. 전처리 단계에서 가져온 값입니다.
latents (<code>Tensor</code>):
이미지 생성을 위한 사전 생성된 노이즈 잠재 변수.
generator (<code>Generator</code>, <em>선택 사항</em>):
결정론적 생성을 위한 Torch 생성기.
num_inference_steps (<code>int</code>):
노이즈 제거 단계 수.
timesteps (<code>Tensor</code>):
노이즈 제거 과정의 타임스텝. (지정되면 <code>num_inference_steps</code>를 무시합니다)
sigmas (<code>list</code>, <em>선택 사항</em>):
노이즈 제거 과정의 사용자 지정 시그마. (지정되면 <code>num_inference_steps</code>를 무시합니다)
*<em>denoiser_input_fields (<code>None</code>,</em>선택 사항<em>):
디노이저의 조건부 모델 입력: 예: prompt_embeds, negative_prompt_embeds 등.
output_type (<code>str</code>,</em>선택 사항*, 기본값 pil):
출력 형식: ‘pil’, ‘np’, ‘pt’.</p> <p>Outputs:
images (<code>list</code>):
생성된 이미지.
latents (<code>Tensor</code>):
노이즈가 제거된 latents.</p></div> <!--[1--><h2 class="relative group"><a id="diffusers.Flux3DistilledModularPipeline" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#diffusers.Flux3DistilledModularPipeline"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Flux3DistilledModularPipeline<!----></span></h2><!--]--><!----> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><div><span class="group flex space-x-1.5 items-center text-gray-800 bg-gradient-to-r rounded-tr-lg -mt-4 -ml-4 pt-3 px-2.5" id="diffusers.Flux3DistilledModularPipeline"><!----><h3 class="!m-0"><span class="flex-1 break-all md:text-lg bg-gradient-to-r px-2.5 py-1.5 rounded-xl from-indigo-50/70 to-white dark:from-gray-900 dark:to-gray-950 dark:text-indigo-300 text-indigo-700"><svg class="mr-1.5 text-indigo-500 inline-block -mt-0.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width=".8em" height=".8em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path class="uim-quaternary" d="M20.23 7.24L12 12L3.77 7.24a1.98 1.98 0 0 1 .7-.71L11 2.76c.62-.35 1.38-.35 2 0l6.53 3.77c.29.173.531.418.7.71z" opacity=".25" fill="currentColor"></path><path class="uim-tertiary" d="M12 12v9.5a2.09 2.09 0 0 1-.91-.21L4.5 17.48a2.003 2.003 0 0 1-1-1.73v-7.5a2.06 2.06 0 0 1 .27-1.01L12 12z" opacity=".5" fill="currentColor"></path><path class="uim-primary" d="M20.5 8.25v7.5a2.003 2.003 0 0 1-1 1.73l-6.62 3.82c-.275.13-.576.198-.88.2V12l8.23-4.76c.175.308.268.656.27 1.01z" fill="currentColor"></path></svg><span class="font-light">class</span> <span class="font-medium">diffusers.</span><span class="font-semibold">Flux3DistilledModularPipeline</span></span></h3><!----> <a id="diffusers.Flux3DistilledModularPipeline" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.Flux3DistilledModularPipeline"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></a> <!--[0--><a class="!ml-auto !text-gray-400 !no-underline text-sm flex items-center" href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L52" target="_blank"><span>&lt;</span> <span class="hidden md:block mx-0.5 hover:!underline">source</span> <span>></span></a><!--]--></span> <!--[0--><p class="font-mono text-xs md:text-sm !leading-relaxed !my-6"><span>(</span> <!--[--><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">blocks<span class="opacity-60">: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">pretrained_model_name_or_path<span class="opacity-60">: str | os.PathLike | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">components_manager<span class="opacity-60">: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">collection<span class="opacity-60">: str | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">workflow<span class="opacity-60">: str | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">modular_config_dict<span class="opacity-60">: dict[str, typing.Any] | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">config_dict<span class="opacity-60">: dict[str, typing.Any] | None = None</span></span></span><span class="comma cursor-default"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">**kwargs<span class="opacity-60"></span></span></span><!--]--> <span>)</span> <!--[-1--><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--></div></div><!----> <p>ModularPipeline는 단계 증류된 FLUX.3 모델(16단계, classifier-free guidance 없음)을 위한 것입니다.</p></div> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/flux3.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]-->
<script>
{
__sveltekit_1rjuniz = {
base: "/docs/diffusers/main/en",
assets: "/docs/diffusers/main/en"
};
const element = document.currentScript.parentElement;
Promise.all([
import("/docs/diffusers/main/en/_app/immutable/entry/start.vZc-dOUR.js"),
import("/docs/diffusers/main/en/_app/immutable/entry/app.B6c3Ml05.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 180],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
98.7 kB
·
Xet hash:
6139a66ef3da803d850b2745a5921530cc6e4d284e42f28239a4227c46a25f52

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.