Buckets:

mishig's picture
download
raw
56 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Hızlı Başlangıç&quot;,&quot;local&quot;:&quot;quickstart&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Bir pipeline çalıştırın&quot;,&quot;local&quot;:&quot;run-a-pipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Yapıyı anlama&quot;,&quot;local&quot;:&quot;understand-the-structure&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;İş Akışları&quot;,&quot;local&quot;:&quot;workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Alt bloklar&quot;,&quot;local&quot;:&quot;sub-blocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Yeni iş akışları oluşturun&quot;,&quot;local&quot;:&quot;compose-new-workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Sonraki adımlar&quot;,&quot;local&quot;:&quot;next-steps&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/324.CzQyPdjw.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B4AMoTAu.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B_Tpb3TG.js" rel="modulepreload">
<!--1x94atl--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Quickstart&quot;,&quot;local&quot;:&quot;quickstart&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Run a pipeline&quot;,&quot;local&quot;:&quot;run-a-pipeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Understand the structure&quot;,&quot;local&quot;:&quot;understand-the-structure&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Workflows&quot;,&quot;local&quot;:&quot;workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Sub-blocks&quot;,&quot;local&quot;:&quot;sub-blocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Compose new workflows&quot;,&quot;local&quot;:&quot;compose-new-workflows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Next steps&quot;,&quot;local&quot;:&quot;next-steps&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="quickstart" 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="#quickstart"><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><!---->Hızlı Başlangıç<!----></span></h1><!--]--><!----> <p>Modular Diffusers, esnek ve özelleştirilebilir pipeline'ları hızlı bir şekilde oluşturmak için bir çerçevedir. Bu pipeline'lar, standart <code>DiffusionPipeline</code>'ların yapabildiklerinin ötesine geçebilir. Modular Diffusers'ın çekirdeğinde, yeni iş akışlarına uyum sağlamak için diğer bloklarla birleştirilebilen <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a> bulunur. Bloklar, üretim görevlerini çalıştırmak için kullanıcı dostu bir arayüz olan <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline">ModularPipeline</a>'a dönüştürülür.</p> <p>Bu kılavuz, modüler bir hattın (pipeline) nasıl çalıştırılacağını, yapısının nasıl anlaşıldığını ve onu oluşturan blokları değiştirerek nasıl özelleştirileceğini gösterir. <a href="/docs/diffusers/main/tr/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> ile aşinalığınız varsa, farklı çalışan konular için önce <a href="./coming_from_diffusion_pipeline">DiffusionPipeline'dan Geliyorsanız</a> bölümünü okuyun.</p> <!--[1--><h2 class="relative group"><a id="run-a-pipeline" 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="#run-a-pipeline"><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><!---->Bir pipeline çalıştırın<!----></span></h2><!--]--><!----> <p><a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline">ModularPipeline</a>, modüler boru hatlarını yükleme, çalıştırma ve yönetme için ana arayüzdür.</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> Kopyalandı</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> ModularPipeline, ComponentsManager
<span class="hljs-comment"># Use ComponentsManager to enable auto CPU offloading for memory efficiency</span>
manager = ComponentsManager()
manager.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda:0&quot;</span>)
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
image = pipe(
prompt=<span class="hljs-string">&quot;cat wizard with red hat, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney&quot;</span>,
).images[<span class="hljs-number">0</span>]
image<!----></pre></div><!----> <p><a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained">from_pretrained()</a> tembel yükleme kullanır - her bileşenin nereden yükleneceğini öğrenmek için yapılandırmayı okur, ancak <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a> çağrılana kadar model ağırlıklarını gerçekten yüklemez. Bu, bileşenlerin ne zaman ve nasıl yükleneceği üzerinde size kontrol sağlar.</p> <blockquote class="tip"><p><code>ComponentsManager</code>, <code>enable_auto_cpu_offload</code> ile birlikte, büyük modeller (ör. Qwen-Image) için bellek kullanımını azaltmak amacıyla modelleri gerektiğinde otomatik olarak CPU ile GPU arasında taşır. Daha fazla bilgi için <a href="./components_manager">ComponentsManager</a> kılavuzuna göz atın.</p> <p>Offloading'e ihtiyacınız yoksa, <code>components_manager</code> argümanını kaldırın ve hattı <code>to("cuda")</code> ile cihazınıza manuel olarak taşıyın.</p></blockquote> <p><a href="https://huggingface.co/docs/diffusers/modular_diffusers/modular_pipeline#creating-a-pipeline" rel="nofollow">Pipeline oluşturma</a> ve <a href="https://huggingface.co/docs/diffusers/modular_diffusers/modular_pipeline#loading-components" rel="nofollow">Bileşenleri yükleme</a> kılavuzlarında pipeline oluşturma ve yükleme hakkında daha fazla bilgi edinin.</p> <!--[1--><h2 class="relative group"><a id="understand-the-structure" 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="#understand-the-structure"><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><!---->Yapıyı anlama<!----></span></h2><!--]--><!----> <p>Bir <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline">ModularPipeline</a> iki parçadan oluşur: bir <strong>tanım</strong> (bloklar) ve bir <strong>durum</strong> (yüklenmiş bileşenler ve yapılandırmalar).</p> <p>Halinizi görmek için pipeline'ı yazdırın — bileşenler ve yükleme durumları ile yapılandırmaları.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-built_in">print</span>(pipe)<!----></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> Kopyalandı</div><!----></button><!----></div> <pre class=" "><!----><span class="hljs-symbol">QwenImageModularPipeline</span> {
<span class="hljs-string">&quot;_blocks_class_name&quot;</span>: <span class="hljs-string">&quot;QwenImageAutoBlocks&quot;</span>,
<span class="hljs-string">&quot;_class_name&quot;</span>: <span class="hljs-string">&quot;QwenImageModularPipeline&quot;</span>,
<span class="hljs-string">&quot;_diffusers_version&quot;</span>: <span class="hljs-string">&quot;0.37.0.dev0&quot;</span>,
<span class="hljs-string">&quot;transformer&quot;</span>: [
<span class="hljs-string">&quot;diffusers&quot;</span>,
<span class="hljs-string">&quot;QwenImageTransformer2DModel&quot;</span>,
{
<span class="hljs-string">&quot;pretrained_model_name_or_path&quot;</span>: <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>,
<span class="hljs-string">&quot;revision&quot;</span>: null,
<span class="hljs-string">&quot;subfolder&quot;</span>: <span class="hljs-string">&quot;transformer&quot;</span>,
<span class="hljs-string">&quot;type_hint&quot;</span>: [
<span class="hljs-string">&quot;diffusers&quot;</span>,
<span class="hljs-string">&quot;QwenImageTransformer2DModel&quot;</span>
],
<span class="hljs-string">&quot;variant&quot;</span>: null
}
],
...
}<!----></pre></div><!----> <p>Tanıma <code>pipe.blocks</code> üzerinden erişin — bu, hattın iş akışlarını, girdilerini, çıktılarını ve hesaplama mantığını tanımlayan <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks">ModularPipelineBlocks</a>'tür.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-built_in">print</span>(pipe.blocks)<!----></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> Kopyalandı</div><!----></button><!----></div> <pre class=" "><!---->QwenImageAutoBlocks(
Class: SequentialPipelineBlocks
Description: Auto Modular pipeline <span class="hljs-keyword">for</span> <span class="hljs-keyword">text</span>-to-<span class="hljs-keyword">image</span>, <span class="hljs-keyword">image</span>-to-<span class="hljs-keyword">image</span>, inpainting, and controlnet tasks using QwenImage.
Supported workflows:
- <span class="hljs-string">`text2image`</span>: <span class="hljs-keyword">requires</span> <span class="hljs-string">`prompt`</span>
- <span class="hljs-string">`image2image`</span>: <span class="hljs-keyword">requires</span> <span class="hljs-string">`prompt`</span>, <span class="hljs-string">`image`</span>
- <span class="hljs-string">`inpainting`</span>: <span class="hljs-keyword">requires</span> <span class="hljs-string">`prompt`</span>, <span class="hljs-string">`mask_image`</span>, <span class="hljs-string">`image`</span>
- <span class="hljs-string">`controlnet_text2image`</span>: <span class="hljs-keyword">requires</span> <span class="hljs-string">`prompt`</span>, <span class="hljs-string">`control_image`</span>
...
Components:
text_encoder (<span class="hljs-string">`Qwen2_5_VLForConditionalGeneration`</span>)
vae (<span class="hljs-string">`AutoencoderKLQwenImage`</span>)
transformer (<span class="hljs-string">`QwenImageTransformer2DModel`</span>)
...
Sub-Blocks:
[<span class="hljs-number">0</span>] text_encoder (QwenImageAutoTextEncoderStep)
[<span class="hljs-number">1</span>] vae_encoder (QwenImageAutoVaeEncoderStep)
[<span class="hljs-number">2</span>] controlnet_vae_encoder (QwenImageOptionalControlNetVaeEncoderStep)
[<span class="hljs-number">3</span>] denoise (QwenImageAutoCoreDenoiseStep)
[<span class="hljs-number">4</span>] decode (QwenImageAutoDecodeStep)
)<!----></pre></div><!----> <p>Çıktı şunu döndürür:</p> <ul><li>Desteklenen iş akışları (text2image, image2image, inpainting vb.)</li> <li>Bileşen olarak içerdiği Alt-Bloklar (text_encoder, vae_encoder, denoise, decode)</li></ul> <!--[2--><h3 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><!---->İş Akışları<!----></span></h3><!--]--><!----> <p>Bu pipeline birden çok iş akışını destekler ve sağladığınız girdilere göre davranışını uyarlar. Örneğin, pipeline'a <code>image</code> geçirirseniz, metinden görüntüye değil, görüntüden görüntüye iş akışını çalıştırır. Bunun alt yapısında nasıl çalıştığı hakkında daha fazla bilgi için <a href="https://huggingface.co/docs/diffusers/modular_diffusers/auto_pipeline_blocks" rel="nofollow">AutoPipelineBlocks</a> kılavuzuna göz atın.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
input_image = load_image(<span class="hljs-string">&quot;https://github.com/Trgtuan10/Image_storage/blob/main/cute_cat.png?raw=true&quot;</span>)
image = pipe(
prompt=<span class="hljs-string">&quot;cat wizard with red hat, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney&quot;</span>,
image=input_image,
).images[<span class="hljs-number">0</span>]<!----></pre></div><!----> <p>Belirli bir iş akışının bloklarını çıkarmak için <code>get_workflow()</code> kullanın. Yalnızca o iş akışına ait blokları almak için iş akışı adını (ör. <code>"image2image"</code>, <code>"inpainting"</code>, <code>"controlnet_text2image"</code>) iletin. Bu, belirli bir iş akışını özelleştirmek veya hata ayıklamak istediğinizde kullanışlıdır. Kullanılabilir tüm iş akışlarını görmek için <code>pipe.blocks.available_workflows</code> öğesini kontrol edebilirsiniz.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!---->img2img_blocks = pipe.blocks.get_workflow(<span class="hljs-string">&quot;image2image&quot;</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="sub-blocks" 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="#sub-blocks"><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><!---->Alt bloklar<!----></span></h3><!--]--><!----> <p>Bloklar, diğer blokları içerebilir. <code>pipe.blocks</code> üst düzey blok tanımını (burada <code>QwenImageAutoBlocks</code>) size verirken, <code>sub_blocks</code> içindeki daha küçük bloklara erişmenizi sağlar.</p> <p><code>QwenImageAutoBlocks</code> şu bileşenlerden oluşur: <code>text_encoder</code>, <code>vae_encoder</code>, <code>controlnet_vae_encoder</code>, <code>denoise</code> ve <code>decode</code>.</p> <p>Bu alt bloklar sırayla çalışır ve veri bir bloktan diğerine doğrusal olarak akar — her bloğun <code>intermediate_outputs</code> değeri, bir sonraki blok için <code>inputs</code> olarak kullanılabilir hale gelir. <a href="./sequential_pipeline_blocks"><code>SequentialPipelineBlocks</code></a> tam olarak bu şekilde çalışır.</p> <p>Bunlara <code>sub_blocks</code> özelliği üzerinden erişebilirsiniz. <code>doc</code> özelliği, girdileri, çıktıları ve bileşenleri dahil olmak üzere herhangi bir bloğun tam dokümantasyonunu görmek için kullanışlıdır.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!---->vae_encoder_block = pipe.blocks.sub_blocks[<span class="hljs-string">&quot;vae_encoder&quot;</span>]
<span class="hljs-built_in">print</span>(vae_encoder_block.doc)<!----></pre></div><!----> <p>Bu blok, <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks.init_pipeline">init_pipeline()</a> ile kendi başına çalışabilmesi için bir pipeline'a dönüştürülebilir.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!---->vae_encoder_pipe = vae_encoder_block.init_pipeline()
<span class="hljs-comment"># Reuse the VAE we already loaded, we can reuse it with update_components() method</span>
vae_encoder_pipe.update_components(vae=pipe.vae)
<span class="hljs-comment"># Run just this block</span>
image_latents = vae_encoder_pipe(image=input_image).image_latents
<span class="hljs-built_in">print</span>(image_latents.shape)<!----></pre></div><!----> <p>Orijinal hattımızdaki VAE'yi yeniden yüklemek yerine yeniden kullanır ve bellek kullanımını verimli tutar. Daha fazla bilgi için <a href="https://huggingface.co/docs/diffusers/modular_diffusers/modular_pipeline#loading-components" rel="nofollow">Bileşenleri yükleme</a> kılavuzuna göz atın.</p> <p>Bloklar birleştirilebilir olduğundan, yeni iş akışları oluşturmak için hattın tanımına blok ekleyerek, çıkararak veya değiştirerek değişiklik yapabilirsiniz. Bir sonraki bölümde, ön işlenmiş bir canny kenar haritası yerine normal bir görsel geçebilmeniz için bir ControlNet hattına canny kenar algılama bloğu ekleyeceğiz.</p> <!--[1--><h2 class="relative group"><a id="compose-new-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="#compose-new-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><!---->Yeni iş akışları oluşturun<!----></span></h2><!--]--><!----> <p>Bir ControlNet hattına canny kenar algılama bloğu ekleyelim. Önce, Hub'dan hazır bir canny bloğu yükleyin (kendi bloğunuzu oluşturmak için <a href="https://huggingface.co/docs/diffusers/modular_diffusers/custom_blocks" rel="nofollow">Özel Blokların Oluşturulması</a> bölümüne bakın).</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> diffusers.modular_pipelines <span class="hljs-keyword">import</span> ModularPipelineBlocks
<span class="hljs-comment"># Load a canny block from the Hub</span>
canny_block = ModularPipelineBlocks.from_pretrained(
<span class="hljs-string">&quot;diffusers-internal-dev/canny-filtering&quot;</span>,
trust_remote_code=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(canny_block.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> Kopyalandı</div><!----></button><!----></div> <pre class=" "><!---->class CannyBlock
Inputs:
image (`Union[Image, ndarray]`):
Image <span class="hljs-keyword">to</span> compute canny <span class="hljs-built_in">filter</span> <span class="hljs-keyword">on</span>
low_threshold (`<span class="hljs-keyword">int</span>`, *optional*, defaults <span class="hljs-keyword">to</span> <span class="hljs-number">50</span>):
Low threshold <span class="hljs-keyword">for</span> the canny <span class="hljs-built_in">filter</span>.
high_threshold (`<span class="hljs-keyword">int</span>`, *optional*, defaults <span class="hljs-keyword">to</span> <span class="hljs-number">200</span>):
High threshold <span class="hljs-keyword">for</span> the canny <span class="hljs-built_in">filter</span>.
...
Outputs:
control_image (`PIL.Image`):
Canny <span class="hljs-keyword">map</span> <span class="hljs-keyword">for</span> <span class="hljs-built_in">input</span> image<!----></pre></div><!----> <p><code>get_workflow</code> işlevini kullanarak <code>QwenImageAutoBlocks</code> içinden ControlNet iş akışını çıkarın.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-comment"># Get the controlnet workflow that we want to work with</span>
blocks = pipe.blocks.get_workflow(<span class="hljs-string">&quot;controlnet_text2image&quot;</span>)
<span class="hljs-built_in">print</span>(blocks.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> Kopyalandı</div><!----></button><!----></div> <pre class=" "><!---->class <span class="hljs-symbol">SequentialPipelineBlocks</span>
<span class="hljs-symbol">Inputs</span>:
prompt (<span class="hljs-string">`str`</span>):
<span class="hljs-symbol">The</span> prompt or prompts to guide image generation.
control_image (<span class="hljs-string">`Image`</span>):
<span class="hljs-symbol">Control</span> image for <span class="hljs-symbol">ControlNet</span> conditioning.
...<!----></pre></div><!----> <p>Çıkarılan iş akışı bir <a href="./sequential_pipeline_blocks"><code>SequentialPipelineBlocks</code></a> olup şu anda girdi olarak <code>control_image</code> gerektirir. Hattın bir düzenli görüntü kabul etmesi için canny bloğunu başa ekleyin.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-comment"># Insert canny at the beginning</span>
blocks.sub_blocks.insert(<span class="hljs-string">&quot;canny&quot;</span>, canny_block, <span class="hljs-number">0</span>)
<span class="hljs-comment"># Check the updated structure: CannyBlock is now listed as first sub-block</span>
<span class="hljs-built_in">print</span>(blocks)
<span class="hljs-comment"># Check the updated doc</span>
<span class="hljs-built_in">print</span>(blocks.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> Kopyalandı</div><!----></button><!----></div> <pre class=" "><!---->class SequentialPipelineBlocks
Inputs:
image (<span class="hljs-string">`Union[Image, ndarray]`</span>):
Image <span class="hljs-keyword">to</span> compute canny filter <span class="hljs-keyword">on</span>
low_threshold (<span class="hljs-string">`int`</span>, *optional*, defaults <span class="hljs-keyword">to</span> <span class="hljs-number">50</span>):
Low threshold for the canny filter.
high_threshold (<span class="hljs-string">`int`</span>, *optional*, defaults <span class="hljs-keyword">to</span> <span class="hljs-number">200</span>):
High threshold for the canny filter.
prompt (<span class="hljs-string">`str`</span>):
The prompt <span class="hljs-literal">or</span> prompts <span class="hljs-keyword">to</span> guide image generation.
<span class="hljs-params">...</span><!----></pre></div><!----> <p>Artık pipeline, <code>control_image</code> yerine <code>image</code> girdisi alır. Bir dizideki bloklar verileri otomatik olarak paylaştığı için, canny bloğunun çıktısı (<code>control_image</code>) buna ihtiyaç duyan denoise bloğuna akar ve canny bloğunun girdisi (<code>image</code>), daha önceki bir blok tarafından sağlanmadığı için bir pipeline girdisi haline gelir.</p> <p>Değiştirilen bloklardan bir pipeline oluşturun ve bir ControlNet modeli yükleyin. ControlNet, orijinal model deposunun bir parçası değildir, bu nedenle ayrı olarak yükleyin ve <a href="/docs/diffusers/main/tr/api/modular_diffusers/pipeline#diffusers.ModularPipeline.update_components">update_components()</a> ile ekleyin.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!---->pipeline = blocks.init_pipeline(<span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, components_manager=manager)
pipeline.load_components(dtype=torch.bfloat16)
<span class="hljs-comment"># Load the ControlNet model</span>
controlnet_spec = pipeline.get_component_spec(<span class="hljs-string">&quot;controlnet&quot;</span>)
controlnet_spec.pretrained_model_name_or_path = <span class="hljs-string">&quot;InstantX/Qwen-Image-ControlNet-Union&quot;</span>
controlnet = controlnet_spec.load(dtype=torch.bfloat16)
pipeline.update_components(controlnet=controlnet)<!----></pre></div><!----> <p>Şimdi hattı çalıştırın - canny bloğu, görüntüyü ControlNet için ön işler.</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> Kopyalandı</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
prompt = <span class="hljs-string">&quot;cat wizard with red hat, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney&quot;</span>
image = load_image(<span class="hljs-string">&quot;https://github.com/Trgtuan10/Image_storage/blob/main/cute_cat.png?raw=true&quot;</span>)
output = pipeline(
prompt=prompt,
image=image,
).images[<span class="hljs-number">0</span>]
output<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="next-steps" 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="#next-steps"><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><!---->Sonraki adımlar<!----></span></h2><!--]--><!----> <div class="flex space-x-2 items-center my-1.5 mr-8 h-7 !pl-0 -mx-3 md:mx-0"><!--[--><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd border-gray-800 bg-black dark:bg-gray-700 text-white">Temelleri öğrenin</div><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm">Özel bloklar oluşturun</div><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm">Bileşenleri paylaş</div><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm">Görsel arayüz</div><!--]--></div> <div class="language-select"><div><p>Modular Diffusers'ın temel yapı taşlarını anlayın:</p> <ul><li><a href="./pipeline_block">ModularPipelineBlocks</a>: Bir pipeline'da bir adım tanımlamak için temel birim.</li> <li><a href="./sequential_pipeline_blocks">SequentialPipelineBlocks</a>: Blokları sırayla çalışacak şekilde zincirle.</li> <li><a href="./auto_pipeline_blocks">AutoPipelineBlocks</a>: Birden fazla iş akışını destekleyen boru hatları oluşturun.</li> <li><a href="./modular_diffusers_states">Durumlar</a>: Bloklar arasında verilerin nasıl paylaşıldığı.</li></ul><!----></div><!----> <div hidden=""><p>Özel mantık içeren kendi bloklarınızı nasıl oluşturacağınızı <a href="./custom_blocks">Özel Bloklar Oluşturma</a> kılavuzunda öğrenin.</p><!----></div><!----> <div hidden=""><p>Birden çok hattın arasında modelleri paylaşmak ve belleği verimli bir şekilde yönetmek için <a href="./components_manager"><code>ComponentsManager</code></a> kullanın.</p><!----></div><!----> <div hidden=""><p>Modüler boru hatlarını, iş akışları oluşturmak için görsel, düğüme dayalı bir arayüz olan <a href="https://github.com/cubiq/Mellon" rel="nofollow">Mellon</a> ile bağlayın. Modular Diffusers ile oluşturulan özel bloklar, Mellon ile hazır olarak çalışır - arayüz kodu gerekmez. Daha fazla bilgi için Mellon kılavuzunu okuyun.</p><!----></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/modular_diffusers/quickstart.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, 324],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
56 kB
·
Xet hash:
f718bc8cbd7bfd912f732f96b29990942ff531b5d3a2f752da9677a48dc8116f

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