Buckets:

hf-doc-build/doc / diffusers /main /ko /api /pipelines /p_image_oss.html
mishig's picture
download
raw
58.7 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;P-Image-OSS&quot;,&quot;local&quot;:&quot;p-image-oss&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;구성 요소&quot;,&quot;local&quot;:&quot;components&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;prompt-upsampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;샘플링&quot;,&quot;local&quot;:&quot;sampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSBlocks&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSTextConnector&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSTextConnector&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/diffusers/main/en/_app/immutable/entry/start.BPJAwJcs.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/tkw1XTUu.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/BxrqFSCq.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/entry/app.B9b4EUPx.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/BxHPRFe5.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/chunks/f6ZfvXQ7.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/0.C4PQXGE1.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CVE88MXi.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/3.DjfZZLu6.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DMfD_u2u.js" rel="modulepreload">
<!--150bz02--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;P-Image-OSS&quot;,&quot;local&quot;:&quot;p-image-oss&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Components&quot;,&quot;local&quot;:&quot;components&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;Prompt upsampling&quot;,&quot;local&quot;:&quot;prompt-upsampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Sampling&quot;,&quot;local&quot;:&quot;sampling&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSModularPipeline&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSModularPipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSBlocks&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSBlocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;PImageOSSTextConnector&quot;,&quot;local&quot;:&quot;diffusers.PImageOSSTextConnector&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> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" 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><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="p-image-oss" 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="#p-image-oss"><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><!---->P-Image-OSS<!----></span></h1><!--]--><!----> <p>P-Image-OSS는 <a href="./minimax_h3">MiniMax-H3</a>를 기반으로 한 Pruna AI의 이미지 모델로, 텍스트 기반 이미지 생성 및 지시 기반 이미지 편집에 사용됩니다. 체크포인트는 <a href="https://huggingface.co/PrunaAI/P-Image-OSS" rel="nofollow">PrunaAI/P-Image-OSS</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-py "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentsManager, ModularPipeline
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;</span>
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;PrunaAI/P-Image-OSS&quot;</span>, components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
prompt = (
<span class="hljs-string">&quot;A German Expressionist oil painting of a Berlin street at night in the manner of Ernst Ludwig Kirchner, &quot;</span>
<span class="hljs-string">&quot;with gaunt figures hurrying past a glowing gas lamp.&quot;</span>
)
image = pipe(prompt=prompt, height=<span class="hljs-number">3360</span>, width=<span class="hljs-number">2496</span>, generator=torch.Generator().manual_seed(<span class="hljs-number">3</span>), output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]
edited = pipe(prompt=<span class="hljs-string">&quot;let it snow on the street&quot;</span>, image=image, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>모든 요청은 먼저 <a href="#prompt-upsampling">prompt upsampler</a>를 거칩니다. 가속기에 모든 구성 요소를 배치할 경우, 8 메가픽셀에서 bfloat16으로 파이프라인에 약 101 GB가 필요하므로 예제는 자동 오프로딩을 사용합니다. <a href="/docs/diffusers/main/ko/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a>는 블록이 구성 요소를 필요로 할 때 해당 구성 요소를 가속기로 이동시키고, 파이프라인은 80 GB GPU에서 실행됩니다.</p> <!--[1--><h2 class="relative group"><a id="components" 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="#components"><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><!--]--><!----> <table><thead><tr><th>컴포넌트</th><th>클래스</th></tr></thead><tbody><tr><td><code>transformer</code></td><td><a href="/docs/diffusers/main/ko/api/models/minimax_h3_transformer3d#diffusers.MiniMaxH3Transformer3DModel">MiniMaxH3Transformer3DModel</a></td></tr><tr><td><code>text_encoder</code></td><td><code>Qwen3VLForConditionalGeneration</code> (Qwen3-VL-4B)</td></tr><tr><td><code>text_connector</code></td><td><a href="/docs/diffusers/main/ko/api/pipelines/p_image_oss#diffusers.PImageOSSTextConnector">PImageOSSTextConnector</a></td></tr><tr><td><code>vae</code></td><td><a href="/docs/diffusers/main/ko/api/models/autoencoderkl_p_image_oss#diffusers.AutoencoderKLPImageOSS">AutoencoderKLPImageOSS</a></td></tr><tr><td><code>tokenizer</code>, <code>processor</code></td><td>텍스트 인코더의 토크나이저와 MiniMax-H3의 이미지 프로세서를 갖춘 <code>Qwen3VLProcessor</code></td></tr><tr><td><code>scheduler</code>, <code>audio_scheduler</code></td><td><a href="/docs/diffusers/main/ko/api/schedulers/minimax_h3#diffusers.MiniMaxH3Scheduler">MiniMaxH3Scheduler</a></td></tr><tr><td><code>prompt_upsampler</code>, <code>prompt_upsampler_processor</code></td><td><code>Qwen3_5ForConditionalGeneration</code> (Qwen3.5-9B 기반) 및 해당 프로세서</td></tr></tbody></table> <!--[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>워크플로우는 <code>image</code> 입력에서 선택됩니다:</p> <ul><li><strong><code>text2image</code></strong>는 <code>prompt</code>로부터 생성합니다. <code>height</code>와 <code>width</code>의 기본값은 2912이며 32의 배수로 반올림됩니다. 이 모델은 8메가픽셀에서 가장 잘 작동하며, 예를 들어 2912x2912, 3872x2176 또는 2176x3872와 같은 해상도입니다.</li> <li><strong><code>image_conditioned</code></strong>는 <code>prompt</code>의 지시에 따라 <code>image</code>를 편집하며, 4메가픽셀 또는 8메가픽셀에서 가장 잘 작동합니다. 이미지는 텍스트 인코더를 위해 약 <code>vision_pixels</code>(1메가픽셀)로 인코딩되고, VAE를 위해 자체 크기로 인코딩되며, 해당 범위를 벗어나면 <code>reference_min_pixels</code>(1메가픽셀)로 확대하거나 <code>reference_max_pixels</code>(8메가픽셀)로 축소됩니다. <code>height</code>와 <code>width</code>가 지정되지 않으면, 편집은 첫 번째 이미지의 크기로 생성되며, 이 크기가 더 작으면 <code>canvas_min_pixels</code>(4메가픽셀)로 확대됩니다. 32의 배수로 반올림된 <code>height</code>와 <code>width</code>가 전달되면 캔버스는 변경되지만 이미지는 변경되지 않습니다. <code>image</code>는 최대 8개의 이미지 목록일 수도 있습니다: 첫 번째 이미지는 편집되고, 나머지 이미지는 <code>&lt;Picture 2></code>, <code>&lt;Picture 3></code> 등으로 참조됩니다.</li></ul> <!--[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>P-Image-OSS는 짧은 요청이 아닌 전체 프롬프트를 렌더링하도록 설계되어 있으므로, 파이프라인은 모든 요청에 대해 먼저 프롬프트 업샘플러를 실행합니다. 요청을 분석한 후 프롬프트를 작성합니다. <code>height</code>와 <code>width</code>의 종횡비에 맞는 상세한 텍스트-이미지 프롬프트를 작성하거나, 편집의 경우 이미지에서 유지할 부분과 변경할 부분에 대한 개요를 작성합니다. 작성된 프롬프트는 <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-py "><!---->out = pipe(prompt=prompt, height=<span class="hljs-number">3360</span>, width=<span class="hljs-number">2496</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><!----> <p><code>max_new_tokens</code>는 추론과 프롬프트를 합산하여 제한하며, 기본값은 텍스트-이미지 생성의 경우 1024 토큰, 편집의 경우 1536 토큰입니다. 업샘플러가 사용 가능한 프롬프트를 반환하지 않으면 파이프라인은 렌더링을 수행하지 않고 오류를 발생시킵니다.</p> <p><code>prompt</code>를 주어진 그대로 렌더링하려면 블록에서 스텝을 pop합니다. pop된 블록은 단독으로 실행되기도 하며, 예를 들어 렌더링 전에 프롬프트를 사용자에게 표시하는 용도로 사용할 수 있습니다:</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-py "><!---->manager = ComponentsManager()
manager.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)
blocks = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;PrunaAI/P-Image-OSS&quot;</span>).blocks
upsampler_block = blocks.sub_blocks.pop(<span class="hljs-string">&quot;prompt_upsampler&quot;</span>)
upsampler = upsampler_block.init_pipeline(<span class="hljs-string">&quot;PrunaAI/P-Image-OSS&quot;</span>, components_manager=manager)
upsampler.load_components(dtype=torch.bfloat16)
upsampled = upsampler(prompt=prompt, height=<span class="hljs-number">3360</span>, width=<span class="hljs-number">2496</span>, output=<span class="hljs-string">&quot;prompt&quot;</span>)
pipe = blocks.init_pipeline(<span class="hljs-string">&quot;PrunaAI/P-Image-OSS&quot;</span>, components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
image = pipe(prompt=upsampled, height=<span class="hljs-number">3360</span>, width=<span class="hljs-number">2496</span>, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>step이 없으면, 업샘플러가 작성하는 편집 프롬프트의 어떤 형태이든, 6개 섹션으로 구성된 브리프이든 <code>Edit &lt;Picture 1>.</code>으로 시작하는 단락이든, 작성된 그대로 인코딩됩니다. 다른 모든 지시문에는 해당 접두사가 붙습니다.</p> <!--[1--><h2 class="relative group"><a id="sampling" 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="#sampling"><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><!--]--><!----> <ul><li>8단계는 체크포인트의 <code>sample_sigmas</code>를 기반으로 실행됩니다. 다른 그리드를 사용하려면 <code>sigmas</code>를 전달하세요.</li> <li>모델은 guidance-distilled이므로 guider, <code>negative_prompt</code> 또는 <code>guidance_scale</code>이 없습니다.</li></ul> <!--[1--><h2 class="relative group"><a id="diffusers.PImageOSSModularPipeline" 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.PImageOSSModularPipeline"><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><!---->PImageOSSModularPipeline<!----></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.PImageOSSModularPipeline"><!----><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">PImageOSSModularPipeline</span></span></h3><!----> <a id="diffusers.PImageOSSModularPipeline" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.PImageOSSModularPipeline"><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/p_image_oss/modular_pipeline.py#L22" 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>MiniMax-H3 기반 이미지 모델인 P-Image-OSS의 텍스트-이미지 생성(<code>text2image</code>) 및 지시 기반 편집(<code>image_conditioned</code>)을 위한 ModularPipeline입니다.</p> <p>이미지는 단일 잠재 프레임이며, 두 개의 오디오 잠재 변수가 폐기된 채 하나의 패킹된 시퀀스에서 노이즈 제거됩니다.</p> <div class="relative group rounded-md"><a id="diffusers.PImageOSSModularPipeline.example" class="header-link block pr-0.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.PImageOSSModularPipeline.example"><span><svg class="text-smd" 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> <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-py "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentsManager, ModularPipeline
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;PrunaAI/P-Image-OSS&quot;</span>, components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
prompt = (
<span class="hljs-string">&quot;A German Expressionist oil painting of a Berlin street at night in the manner of Ernst Ludwig Kirchner, &quot;</span>
<span class="hljs-string">&quot;with gaunt figures hurrying past a glowing gas lamp.&quot;</span>
)
image = pipe(prompt=prompt, height=<span class="hljs-number">3360</span>, width=<span class="hljs-number">2496</span>, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]<!----></pre></div><!----></div><!----></div> <!--[1--><h2 class="relative group"><a id="diffusers.PImageOSSBlocks" 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.PImageOSSBlocks"><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><!---->PImageOSSBlocks<!----></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.PImageOSSBlocks"><!----><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">PImageOSSBlocks</span></span></h3><!----> <a id="diffusers.PImageOSSBlocks" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.PImageOSSBlocks"><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/p_image_oss/modular_blocks_p_image_oss.py#L383" 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>P-Image-OSS의 모듈형 파이프라인 블록: <code>text2image</code> 및 <code>image</code>가 전달될 때의 지시 기반 편집(<code>image_conditioned</code>). <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>구성 요소:</p> <ul><li>image_processor (<code>VaeImageProcessor</code>)</li> <li>prompt_upsampler (<code>Qwen3_5ForConditionalGeneration</code>): 프롬프트 업샘플러입니다.</li> <li>prompt_upsampler_processor (<code>AutoProcessor</code>): 해당 프로세서입니다.</li> <li>text_encoder (<code>Qwen3VLForConditionalGeneration</code>)</li> <li>text_connector (<code>PImageOSSTextConnector</code>)</li> <li>토크나이저 (<code>Qwen2Tokenizer</code>)</li> <li>프로세서 (<code>Qwen3VLProcessor</code>)</li> <li>(<code>AutoencoderKLPImageOSS</code>)</li> <li>scheduler (<code>MiniMaxH3Scheduler</code>)</li> <li>audio_scheduler (<code>MiniMaxH3Scheduler</code>)</li> <li>transformer (<code>MiniMaxH3Transformer3DModel</code>)</li></ul> <p>설정:</p> <ul><li>reference_min_pixels (기본값: 1048576)</li> <li>reference_max_pixels (기본값: 8388608)</li> <li>canvas_min_pixels (기본값: 4194304)</li> <li>vision_pixels (기본값: 1000000)</li> <li>sample_sigmas (기본값: [1.0, 0.984753, 0.967905, 0.951688, 0.925372, 0.881923, 0.810083, 0.528718, 0.0]):
<code>sigmas</code>가 전달되지 않을 때 사용되는 체크포인트의 샘플링 그리드입니다.</li></ul> <p>입력:
image (<code>Image | list</code>, <em>선택 사항</em>):
편집할 이미지 또는 최대 8개의 이미지 목록입니다. 첫 번째 이미지는 편집 대상이며, 나머지는 참조 이미지입니다.
height (<code>int</code>, <em>선택 사항</em>):
생성된 이미지의 픽셀 단위 높이로, 32의 배수로 반올림됩니다. <code>text2image</code>의 기본값은 2912이며, 8메가픽셀에서 가장 잘 작동합니다. 편집 작업의 기본값은 첫 번째 이미지의 크기이며, 최소 <code>canvas_min_pixels</code> 이상이어야 하며, 4메가픽셀 또는 8메가픽셀에서 가장 잘 작동합니다.
width (<code>int</code>, <em>선택 사항</em>):
생성된 이미지의 픽셀 단위 너비로, 32의 배수로 반올림됩니다. <code>text2image</code>의 기본값은 2912이며, 8메가픽셀에서 가장 잘 작동합니다. 편집 작업의 기본값은 첫 번째 이미지의 크기이며, 최소 <code>canvas_min_pixels</code> 이상이어야 하며, 4메가픽셀 또는 8메가픽셀에서 가장 잘 작동합니다.
prompt (<code>str</code>):
프롬프트 또는 <code>image</code>가 전달될 때의 편집 지침입니다. 단일 문자열입니다.
max_new_tokens (<code>int</code>, <em>선택 사항</em>, 워크플로에 따라 기본값이 1536 또는 1024):
업샘플러가 생성할 수 있는 최대 토큰 수로, 추론 과정이 포함됩니다.
vision_images (<code>list</code>, <em>선택 사항</em>):
텍스트 인코더를 위해 리사이즈된 편집 이미지 목록으로, 편집할 이미지가 맨 앞에 위치합니다.
reference_images (<code>list</code>, <em>선택 사항</em>):
VAE를 위해 리사이즈된 편집 이미지 목록으로, 편집할 이미지가 맨 앞에 위치합니다.
condition_latents (<code>list</code>, <em>선택 사항</em>):
편집 이미지의 조건부 잠긴 값(latents)입니다. 이들의 형태(shape)는 참조 블록의 기하학적 구조를 결정합니다.
generator (<code>Generator</code>, <em>선택 사항</em>):
요청의 생성기입니다. 생성된 행의 노이즈보다 먼저, 조건부 노이즈가 여기서 추출되며, 조건마다 한 번씩 추출됩니다.
latents (<code>Tensor</code>):
<code>(1, latent_channels, 1, latent_height, latent_width)</code> 형태의 사전 생성된 이미지 노이즈로, 추출(draw) 대신 사용됩니다.
sigmas (<code>list</code>, <em>선택 사항</em>):
0으로 끝나는 엄격히 감소하는 커스텀 샘플링 그리드입니다. 기본값은 체크포인트의 <code>sample_sigmas</code>입니다.
*<em>denoiser_input_fields (<code>None</code>,</em>선택 사항<em>):
트랜스포머가 이름으로 읽는 패킹된 시퀀스의 구조적 설명입니다: <code>token_tags</code>, <code>position_ids</code> 및 세 개의 행 인덱스 텐서.
attention_kwargs (<code>dict</code>,</em>선택 사항<em>):
어텐션 프로세서에 대한 추가 kwargs입니다.
output_type (<code>str</code>,</em>선택 사항*, 기본값 pil):
출력 형식: ‘pil’, ‘np’, ‘pt’.</p> <p>출력:
images (<code>list</code>):
생성된 이미지.</p></div> <!--[1--><h2 class="relative group"><a id="diffusers.PImageOSSTextConnector" 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.PImageOSSTextConnector"><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><!---->PImageOSSTextConnector<!----></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.PImageOSSTextConnector"><!----><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">PImageOSSTextConnector</span></span></h3><!----> <a id="diffusers.PImageOSSTextConnector" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.PImageOSSTextConnector"><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/models/condition_embedders/condition_embedder_p_image_oss.py#L22" 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-pointer"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">hidden_state_indices<span class="opacity-60">: tuple[int, ...] = (13, 19, 25, 31, 36)</span></span></span><span class="comma cursor-pointer"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">text_hidden_size<span class="opacity-60">: int = 2560</span></span></span><span class="comma cursor-pointer"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">out_channels<span class="opacity-60">: int = 5120</span></span></span><!--]--> <span>)</span> <!--[-1--><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[0--><p class="flex items-center font-semibold !mt-2 !mb-2 text-gray-800">매개변수 <span class="flex-auto border-t-2 border-gray-100 dark:border-gray-700 ml-3"></span></p> <ul class="px-2"><!--[--><li class="text-base !pl-4 my-3 rounded "><span class="group flex space-x-1.5 items-start"><a id="diffusers.PImageOSSTextConnector.hidden_state_indices" class="header-link block pr-0.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.PImageOSSTextConnector.hidden_state_indices"><span><svg class="text-smd" 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><!----><strong>hidden_state_indices</strong> (<code>tuple[int, ...]</code>, 기본값 <code>(13, 19, 25, 31, 36)</code>) —
<code>output_hidden_states</code>의 번호 체계에 따라 텍스트 인코더의 <code>hidden_states</code> 중 어떤 항목을 읽을지 지정합니다.
(<code>0</code>은 임베딩 출력, <code>i</code>는 디코더 레이어 <code>i</code>의 출력, 마지막은 최종 정규화 된 히든 상태입니다.)<!----></span></span></li><li class="text-base !pl-4 my-3 rounded "><span class="group flex space-x-1.5 items-start"><a id="diffusers.PImageOSSTextConnector.text_hidden_size" class="header-link block pr-0.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.PImageOSSTextConnector.text_hidden_size"><span><svg class="text-smd" 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><!----><strong>text_hidden_size</strong> (<code>int</code>, 기본값 <code>2560</code>) —
텍스트 인코더의 hidden size입니다.<!----></span></span></li><li class="text-base !pl-4 my-3 rounded "><span class="group flex space-x-1.5 items-start"><a id="diffusers.PImageOSSTextConnector.out_channels" class="header-link block pr-0.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.PImageOSSTextConnector.out_channels"><span><svg class="text-smd" 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><!----><strong>out_channels</strong> (<code>int</code>, 기본값 <code>5120</code>) —
MiniMax-H3의 transformer가 읽는 conditioning의 채널 수입니다.<!----></span></span></li><!--]--></ul><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--> <!--[-1--><!--]--></div></div><!----> <p>P-Image-OSS의 Qwen3-VL 텍스트 인코더의 숨겨진 상태를 해당 Transformer가 읽는 텍스트 조건으로 매핑합니다.</p> <p><code>hidden_state_indices</code>에 나열된 hidden states는 연결(concatenate)되고, 표준화되며, 선형 투사(linear projection)된 후, 표준화 해제(destandardize)됩니다. 첫 번째 토큰은 모든 프롬프트에 대해 동일한 조건부(conditioning)를 갖는 attention sink이므로 <code>sink_embedding</code>으로 대체됩니다.</p> <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.PImageOSSTextConnector.forward"><!----><h4 class="!m-0"><span class="flex-1 rounded-xl py-0.5 break-all bg-gradient-to-r from-blue-50/60 to-white dark:from-gray-900 dark:to-gray-950 text-blue-700 dark:text-blue-300 font-medium px-2"><svg width="1em" height="1em" viewBox="0 0 32 33" class="mr-1 inline-block -mt-0.5" xmlns="http://www.w3.org/2000/svg"><path d="M5.80566 18.3545C4.90766 17.4565 4.90766 16.0005 5.80566 15.1025L14.3768 6.53142C15.2748 5.63342 16.7307 5.63342 17.6287 6.53142L26.1999 15.1025C27.0979 16.0005 27.0979 17.4565 26.1999 18.3545L17.6287 26.9256C16.7307 27.8236 15.2748 27.8236 14.3768 26.9256L5.80566 18.3545Z" fill="currentColor" fill-opacity="0.25"/><path fill-rule="evenodd" clip-rule="evenodd" d="M16.4801 13.9619C16.4801 12.9761 16.7467 12.5436 16.9443 12.3296C17.1764 12.078 17.5731 11.8517 18.2275 11.707C18.8821 11.5623 19.638 11.5342 20.4038 11.5582C20.7804 11.57 21.1341 11.5932 21.4719 11.6156L21.5263 11.6193C21.8195 11.6389 22.1626 11.6618 22.4429 11.6618V7.40825C22.3209 7.40825 22.1219 7.39596 21.7544 7.37149C21.4202 7.34925 20.9976 7.32115 20.5371 7.30672C19.6286 7.27824 18.4672 7.29779 17.3093 7.55377C16.1512 7.8098 14.8404 8.33724 13.8181 9.4452C12.7612 10.5907 12.2266 12.1236 12.2266 13.9619V15.0127H10.6836V19.2662H12.2266V26.6332H16.4801V19.2662H20.3394V15.0127H16.4801V13.9619Z" fill="currentColor"/></svg>forward</span></h4><!----> <a id="diffusers.PImageOSSTextConnector.forward" class="header-link invisible with-hover:group-hover:visible pr-2" href="#diffusers.PImageOSSTextConnector.forward"><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/models/condition_embedders/condition_embedder_p_image_oss.py#L61" 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-pointer"><span class="rounded hover:bg-black hover:text-white dark:hover:bg-white dark:hover:text-black">hidden_states<span class="opacity-60">: tuple[torch.Tensor, ...]</span></span></span><!--]--> <span>)</span> <!--[0--><span class="font-bold">→</span> <span class="rounded hover:bg-gray-400 cursor-pointer"><!----><span><code>torch.Tensor</code></span><!----></span><!--]--></p><!--]--> <div class="!mb-10 relative docstring-details "><!--[-1--><!--]--> <!--[0--><p class="flex items-center font-semibold !mt-2 !mb-2 text-gray-800">매개변수 <span class="flex-auto border-t-2 border-gray-100 dark:border-gray-700 ml-3"></span></p> <ul class="px-2"><!--[--><li class="text-base !pl-4 my-3 rounded "><span class="group flex space-x-1.5 items-start"><a id="diffusers.PImageOSSTextConnector.forward.hidden_states" class="header-link block pr-0.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.PImageOSSTextConnector.forward.hidden_states"><span><svg class="text-smd" 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><!----><strong>hidden_states</strong> (<code>tuple[torch.Tensor, ...]</code>) —
<code>output_hidden_states=True</code>가 반환하는 텍스트 인코더의 hidden states입니다. 각 항목마다 <code>(batch_size, num_tokens, text_hidden_size)</code> 모양의 텐서 하나씩 포함됩니다.<!----></span></span></li><!--]--></ul><!--]--> <!--[-1--><!--]--> <!--[0--><div id="diffusers.PImageOSSTextConnector.forward.returns" class="flex items-center font-semibold space-x-3 text-base !mt-0 !mb-0 text-gray-800 rounded "><p class="text-base"><!---->반환값<!----></p> <!--[0--><!---->
<p><code>torch.Tensor</code></p>
<!----><!--]--> <span class="flex-auto border-t-2 border-gray-100 dark:border-gray-700"></span></div> <div class="text-base"><!---->
<p><code>(batch_size, num_tokens, out_channels)</code> 모양의 conditioning으로, dtype은 커넥터의 파라미터와 동일합니다.</p>
<!----></div><!--]--> <!--[-1--><!--]--></div></div><!----></div></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/p_image_oss.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_h25trk = {
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.BPJAwJcs.js"),
import("/docs/diffusers/main/en/_app/immutable/entry/app.B9b4EUPx.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 3],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
58.7 kB
·
Xet hash:
a984912d3657d4a76f7f8ced73225d0593fc03653c5001bc1f5002163e0bd77a

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