Buckets:

hf-doc-build/doc / diffusers /main /tr /training /cogvideox.html
mishig's picture
download
raw
56 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;CogVideoX&quot;,&quot;local&quot;:&quot;cogvideox&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Veri Hazırlama&quot;,&quot;local&quot;:&quot;data-preparation&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Küçük format&quot;,&quot;local&quot;:&quot;small-format&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Akış biçimi&quot;,&quot;local&quot;:&quot;stream-format&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Eğitim&quot;,&quot;local&quot;:&quot;training&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Çıkarım&quot;,&quot;local&quot;:&quot;inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Bellek kullanımını azaltın&quot;,&quot;local&quot;:&quot;reduce-memory-usage&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/355.CO-zYgaF.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B4AMoTAu.js" rel="modulepreload">
<!--26s02k--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;CogVideoX&quot;,&quot;local&quot;:&quot;cogvideox&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Data Preparation&quot;,&quot;local&quot;:&quot;data-preparation&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Small format&quot;,&quot;local&quot;:&quot;small-format&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Stream format&quot;,&quot;local&quot;:&quot;stream-format&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Training&quot;,&quot;local&quot;:&quot;training&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Inference&quot;,&quot;local&quot;:&quot;inference&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Reduce memory usage&quot;,&quot;local&quot;:&quot;reduce-memory-usage&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="cogvideox" 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="#cogvideox"><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><!---->CogVideoX<!----></span></h1><!--]--><!----> <p>CogVideoX, bir istemle daha tutarlı videolar oluşturulmasına odaklanan metinden videoya üretim modelidir. Bunu çeşitli yöntemler kullanarak başarır.</p> <ul><li><p>videoları uzamsal ve zamansal olarak sıkıştıran, sıkıştırma oranını ve video doğruluğunu iyileştiren 3B varyasyonel oto-encoder</p></li> <li><p>metin ve videoyu hizalamaya yardımcı olmak için uzman bir transformer bloğu ve uzamsal ve zamansal olarak doğru videoları yakalamak ve oluşturmak için 3B tam dikkat modülü.</p></li></ul> <p>Video talimat boyutunun gerçek testi, CogVideoX'in tutarlı tema, dinamik bilgi, tutarlı arka plan, nesne bilgisi, akıcı hareket, renk, sahne, görünüm stili ve zamansal stil konularında iyi sonuçlar verdiğini, ancak insan eylemi, uzamsal ilişki ve birden fazla nesne konularında iyi sonuçlar elde edemediğini ortaya koymuştur.</p> <p>Diffusers ile ince ayar yapmak, bu kötü sonuçları telafi etmeye yardımcı olabilir.</p> <!--[1--><h2 class="relative group"><a id="data-preparation" 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="#data-preparation"><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><!---->Veri Hazırlama<!----></span></h2><!--]--><!----> <p>Eğitim betikleri veriyi iki formatta kabul eder.</p> <p>İlk format küçük ölçekli eğitim için uygundur, ikinci format ise büyük ölçekli eğitimde veri akışı için daha uygun olan CSV formatını kullanır. Gelecekte Diffusers, <code>&lt;Video></code> etiketini destekleyecektir.</p> <!--[2--><h3 class="relative group"><a id="small-format" 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="#small-format"><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><!---->Küçük format<!----></span></h3><!--]--><!----> <p>Bir dosyada satır satır ayrılmış istemler, diğer dosyada ise satır satır ayrılmış video verisi yolları içeren iki dosya (video dosyalarının yolları, <code>--instance_data_root</code> belirtirken geçirdiğiniz yola göre göreli olmalıdır). Bunu daha iyi anlamak için bir örneğe bakalım!</p> <p><code>--instance_data_root</code> parametresini <code>/dataset</code> olarak belirttiğinizi ve bu dizinin <code>prompts.txt</code> ile <code>videos.txt</code> dosyalarını içerdiğini varsayalım.</p> <p><code>prompts.txt</code> dosyası satır satır ayrılmış istekler içermelidir:</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=" "><!---->A <span class="hljs-keyword">black </span><span class="hljs-keyword">and </span>white animated sequence featuring a rabbit, named Rabbity Ribfried, <span class="hljs-keyword">and </span>an anthropomorphic goat in a musical, playful environment, <span class="hljs-keyword">showcasing </span>their evolving interaction.
A <span class="hljs-keyword">black </span><span class="hljs-keyword">and </span>white animated sequence on a <span class="hljs-keyword">ship&#x27;s </span>deck features a <span class="hljs-keyword">bulldog </span>character, named <span class="hljs-keyword">Bully </span><span class="hljs-keyword">Bulldoger, </span><span class="hljs-keyword">showcasing </span>exaggerated facial expressions <span class="hljs-keyword">and </span><span class="hljs-keyword">body </span>language. The character progresses from confident to focused, then to strained <span class="hljs-keyword">and </span><span class="hljs-keyword">distressed, </span><span class="hljs-keyword">displaying </span>a range of emotions as it navigates challenges. The <span class="hljs-keyword">ship&#x27;s </span>interior remains static in the <span class="hljs-keyword">background, </span>with minimalistic details such as a <span class="hljs-keyword">bell </span><span class="hljs-keyword">and </span>open door. The character<span class="hljs-string">&#x27;s dynamic movements and changing expressions drive the narrative, with no camera movement to distract from its evolving reactions and physical gestures.
...</span><!----></pre></div><!----> <p><code>videos.txt</code> dosyası, video dosyalarına giden satır satır yolları içermelidir. Yolun <code>--instance_data_root</code> dizinine <em>göreli</em> olması gerektiğini unutmayı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=" "><!---->videos<span class="hljs-symbol">/00000.mp4</span>
videos<span class="hljs-symbol">/00001.mp4</span>
...<!----></pre></div><!----> <p>Genel olarak, veri seti kök dizininde <code>tree</code> komutunu çalıştırdığınızda veri setiniz aşağıdaki gibi görünü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=" "><!---->/dataset
├── prompts<span class="hljs-selector-class">.txt</span>
├── videos<span class="hljs-selector-class">.txt</span>
├── videos
├── videos/<span class="hljs-number">00000</span><span class="hljs-selector-class">.mp4</span>
├── videos/<span class="hljs-number">00001</span><span class="hljs-selector-class">.mp4</span>
├── ...<!----></pre></div><!----> <p>Bu formatı kullanırken <code>--caption_column</code> <code>prompts.txt</code> ve <code>--video_column</code> <code>videos.txt</code> olmalıdır.</p> <!--[2--><h3 class="relative group"><a id="stream-format" 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="#stream-format"><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ış biçimi<!----></span></h3><!--]--><!----> <p>Tek bir CSV dosyası kullanabilirsiniz. Bu örneğin amacı için <code>metadata.csv</code> adında bir dosyanız olduğunu varsayalım. Beklenen biçim şudur:</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=" "><!---->&lt;CAPTION_COLUMN&gt;,&lt;PATH_TO_VIDEO_COLUMN&gt;
<span class="hljs-string">&quot;&quot;&quot;A black and white animated sequence featuring a rabbit, named Rabbity Ribfried, and an anthropomorphic goat in a musical, playful environment, showcasing their evolving interaction.&quot;&quot;&quot;</span>,<span class="hljs-string">&quot;&quot;&quot;00000.mp4&quot;&quot;&quot;</span>
<span class="hljs-string">&quot;&quot;&quot;A black and white animated sequence on a ship&#x27;s deck features a bulldog character, named Bully Bulldoger, showcasing exaggerated facial expressions and body language. The character progresses from confident to focused, then to strained and distressed, displaying a range of emotions as it navigates challenges. The ship&#x27;s interior remains static in the background, with minimalistic details such as a bell and open door. The character&#x27;s dynamic movements and changing expressions drive the narrative, with no camera movement to distract from its evolving reactions and physical gestures.&quot;&quot;&quot;</span>,<span class="hljs-string">&quot;&quot;&quot;00001.mp4&quot;&quot;&quot;</span>
...<!----></pre></div><!----> <p>Bu durumda, <code>--instance_data_root</code> videoların saklandığı konum olmalı ve <code>--dataset_name</code> yerel bir klasöre giden bir yol veya Hub üzerinde barındırılan <a href="https://huggingface.co/docs/datasets/main/en/package_reference/loading_methods#datasets.load_dataset" rel="nofollow">load_dataset</a> ile uyumlu bir veri seti olmalıdır. Minecraft oyun videolarınızın <code>https://huggingface.co/datasets/my-awesome-username/minecraft-videos</code> adresinde olduğunu varsayarsak, <code>my-awesome-username/minecraft-videos</code> değerini belirtmeniz gerekir.</p> <p>Bu formatı kullanırken <code>--caption_column</code> <code>&lt;CAPTION_COLUMN></code> ve <code>--video_column</code> <code>&lt;PATH_TO_VIDEO_COLUMN></code> olmalıdır.</p> <p>CSV formatına kesin olarak bağlı değilsiniz. <code>load_dataset</code> yöntemi, temel bir <code>&lt;PATH_TO_VIDEO_COLUMN></code> ve <code>&lt;CAPTION_COLUMN></code> yüklemek için dosya formatını desteklediği sürece herhangi bir format işe yarar. Video verilerini yüklemek için bu veri seti organizasyon jimnastiğinden geçme nedeni, <code>load_dataset</code>'in tüm video formatlarını tam olarak desteklememesidir.</p> <blockquote class="note"><p>CogVideoX, video üretimi için uzun ve açıklayıcı, LLM destekli istemlerle en iyi sonucu verir. Videolarınızı ön işlemeye tabi tutmanızı, önce bir VLM kullanarak özet üretip ardından istemleri bir LLM ile zenginleştirmenizi öneririz. Yukarıdaki altyazıları üretmek için <a href="https://huggingface.co/openbmb/MiniCPM-V-2_6" rel="nofollow">MiniCPM-V-26</a> ve <a href="https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct" rel="nofollow">Llama-3.1-8B-Instruct</a> kullanıyoruz. Bunun için çok sade ve gereksiz detaylardan arındırılmış bir örnek <a href="https://gist.github.com/a-r-r-o-w/4dee20250e82f4e44690a02351324a4a" rel="nofollow">burada</a> mevcuttur. İstemleri zenginleştirmek için resmi öneri <a href="https://huggingface.co/THUDM?search_models=chatglm" rel="nofollow">ChatGLM</a>'dir ve 50-100 kelimelik uzunluk iyi kabul edilir.</p></blockquote> <blockquote><p>![NOTE]
Veri setinizin zaten ön işlenmiş olması beklenir. Değilse, aşağıdaki parametrelerle oynayarak bazı temel ön işlemler yapılabilir: <code>--height</code>, <code>--width</code>, <code>--fps</code>, <code>--max_num_frames</code>, <code>--skip_frames_start</code> ve <code>--skip_frames_end</code>.
Şu anda, eğitim parti boyutu &gt; 1 olduğunda veri setinizdeki tüm videoların aynı sayıda video karesi içermesi gerekir.</p></blockquote> <!--[1--><h2 class="relative group"><a id="training" 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="#training"><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><!---->Eğitim<!----></span></h2><!--]--><!----> <p>Geliştirme ortamınızı gerekli gereksinimleri kurarak yapılandırmanız gerekir. Aşağıdaki paketler gereklidir:</p> <ul><li>Kullandığınız eğitim özelliklerine bağlı olarak Torch 2.0 veya üzeri (kuantize/deepspeed eğitimi için en son veya nightly sürümleri gerekebilir)</li> <li>Modelleme ve eğitimle ilgili her şey için <code>pip install diffusers transformers accelerate peft huggingface_hub</code></li> <li>Video eğitim verilerini yüklemek için <code>pip install datasets decord</code></li> <li>Bellek optimizasyonlu eğitim için 8-bit Adam veya AdamW optimizatörlerini kullanmak için <code>pip install bitsandbytes</code></li> <li>eğitim günlüklerini izlemek için isteğe bağlı olarak <code>pip install wandb</code></li> <li><code>pip install deepspeed</code> isteğe bağlı olarak <a href="https://github.com/microsoft/DeepSpeed" rel="nofollow">DeepSpeed</a> eğitimi için</li> <li>Eğitim için Prodigy optimizatörünü kullanmak isterseniz isteğe bağlı olarak <code>pip install prodigyopt</code></li></ul> <p>Örnek betiklerinin en güncel sürümlerini başarıyla çalıştırabildiğinizden emin olmak için, örnek betiklerini sık sık güncellediğimiz ve bazı örnek özel gereksinimleri yüklediğimiz için <strong>kaynaktan kurulum</strong> yapmanızı ve kurulumu güncel tutmanızı şiddetle öneririz. Bunu yapmak için yeni bir sanal ortamda aşağıdaki adımları uygulayın:</p> <p>Betik çalıştırmadan önce, kütüphanenin kaynak kodundan yüklendiğinden emin olun:</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-bash "><!---->git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install -e .<!----></pre></div><!----> <p>Ardından, eğitim betiğini içeren örnek klasörüne gidin ve kullandığınız betik için gerekli bağımlılıkları yükleyin:</p> <ul><li>PyTorch</li></ul> <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-bash "><!----><span class="hljs-built_in">cd</span> examples/cogvideo
pip install -r requirements.txt<!----></pre></div><!----> <p>Ve bir <a href="https://github.com/huggingface/accelerate/" rel="nofollow">🤗 Accelerate</a> ortamını şu şekilde başlatı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-bash "><!---->accelerate config<!----></pre></div><!----> <p>Ya da ortamınızla ilgili soruları yanıtlamadan varsayılan bir accelerate yapılandırması için</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-bash "><!---->accelerate config default<!----></pre></div><!----> <p>Ya da ortamınız etkileşimli bir kabuğu desteklemiyorsa (örneğin, bir defter)</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-python "><!----><span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config
write_basic_config()<!----></pre></div><!----> <p><code>accelerate config</code> çalıştırıldığında, torch.compile kullanılıyorsa dramatik hızlanmalar görülebilir. PEFT kütüphanesi LoRA eğitimi için bir arka uç olarak kullanıldığından, ortamınızda <code>peft>=0.6.0</code> yüklü olduğundan emin olun.</p> <p>Eğitim tamamlandıktan sonra modelinizi düzenli bir model kartıyla Hub'a göndermek istiyorsanız, oturum açtığınızdan emin olun:</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-bash "><!---->hf auth login
<span class="hljs-comment"># Alternatively, you could upload your model manually using:</span>
<span class="hljs-comment"># hf upload my-cool-account-name/my-cool-lora-name /path/to/awesome/lora</span><!----></pre></div><!----> <p>Verilerinizin <a href="#data-preparation">Veri Hazırlama</a> bölümünde belirtildiği gibi hazır olduğundan emin olun. Hazır olduğunuzda eğitime başlayabilirsiniz!</p> <p>Benzer bir kavramın 50 videosu üzerinde eğitim yaptığınızı varsayarsak, 1500-2000 adımın iyi çalıştığını tespit ettik. Ancak resmi öneri, toplam 4000 adım ile 100 videodur. Tek bir GPU üzerinde <code>--train_batch_size</code> değeri <code>1</code> olacak şekilde eğitim yaptığınızı varsayarsak:</p> <ul><li>50 videoda 1500 adım, <code>30</code> eğitim epokuna karşılık gelir</li> <li>100 videoda 4000 adım, <code>40</code> eğitim epokuna karşılık gelir</li></ul> <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-bash "><!----><span class="hljs-meta">#!/bin/bash</span>
GPU_IDS=<span class="hljs-string">&quot;0&quot;</span>
accelerate launch --gpu_ids <span class="hljs-variable">$GPU_IDS</span> examples/cogvideo/train_cogvideox_lora.py \
--pretrained_model_name_or_path THUDM/CogVideoX-2b \
--cache_dir &lt;CACHE_DIR&gt; \
--instance_data_root &lt;PATH_TO_WHERE_VIDEO_FILES_ARE_STORED&gt; \
--dataset_name my-awesome-name/my-awesome-dataset \
--caption_column &lt;CAPTION_COLUMN&gt; \
--video_column &lt;PATH_TO_VIDEO_COLUMN&gt; \
--id_token &lt;ID_TOKEN&gt; \
--validation_prompt <span class="hljs-string">&quot;&lt;ID_TOKEN&gt; Spiderman swinging over buildings:::A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. The panda&#x27;s fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, casting a gentle glow on the scene. The panda&#x27;s face is expressive, showing concentration and joy as it plays. The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical atmosphere of this unique musical performance&quot;</span> \
--validation_prompt_separator ::: \
--num_validation_videos 1 \
--validation_epochs 10 \
--seed 42 \
--rank 64 \
--lora_alpha 64 \
--mixed_precision fp16 \
--output_dir /raid/aryan/cogvideox-lora \
--height 480 --width 720 --fps 8 --max_num_frames 49 --skip_frames_start 0 --skip_frames_end 0 \
--train_batch_size 1 \
--num_train_epochs 30 \
--checkpointing_steps 1000 \
--gradient_accumulation_steps 1 \
--learning_rate 1e-3 \
--lr_scheduler cosine_with_restarts \
--lr_warmup_steps 200 \
--lr_num_cycles 1 \
--enable_slicing \
--enable_tiling \
--optimizer Adam \
--adam_beta1 0.9 \
--adam_beta2 0.95 \
--max_grad_norm 1.0 \
--report_to wandb<!----></pre></div><!----> <p>Eğitim deneylerimizi daha iyi izleyebilmek için yukarıdaki komutta aşağıdaki bayrakları kullanıyoruz:</p> <ul><li><code>--report_to wandb</code>, eğitim çalıştırmalarının Weights and Biases üzerinde izlenmesini sağlar. Bunu kullanmak için <code>wandb</code> paketini <code>pip install wandb</code> komutuyla kurduğunuzdan emin olun.</li> <li><code>validation_prompt</code> ve <code>validation_epochs</code> parametrelerini ekleyerek betiğin birkaç doğrulama çıkarım çalışması yapmasını sağlayın. Bu sayede eğitimin beklenen şekilde ilerleyip ilerlemediğini nitel olarak kontrol edebiliriz.</li></ul> <p><code>&lt;ID_TOKEN></code> ayarlamak zorunlu değildir. Sınırlı deneyimlerimizde, <a href="https://huggingface.co/docs/diffusers/en/training/dreambooth" rel="nofollow">Dreambooth</a> eğitimine benzediği için, bu belirtecin kullanılmadığı duruma kıyasla kullanıldığında daha iyi sonuç verdiğini gözlemledik. Sağlandığında, <code>&lt;ID_TOKEN></code> her istemin başına eklenir. Dolayısıyla, <code>&lt;ID_TOKEN></code> değeriniz <code>"DISNEY"</code> ve isteminiz <code>"Spiderman swinging over buildings"</code> ise, eğitimde kullanılan etkili istem <code>"DISNEY Spiderman swinging over buildings"</code> olur. Sağlanmadığında, ek bir belirteç olmadan eğitim yapabilir veya eğitime başlamadan önce belirteci istediğiniz yere uygulamak için veri setinizi genişletebilirsiniz.</p> <blockquote class="note"><p>Eğitimin bellek gereksinimlerini azaltmak için <code>--use_8bit_adam</code> parametresini iletebilirsiniz.</p></blockquote> <blockquote class="important"><p>CogVideoX LoRA eğitim desteği eklendiğinde aşağıdaki ayarlar test edilmiştir:</p> <ul><li>Testlerimizin büyük bölümü CogVideoX-2b üzerinde gerçekleştirildi. Yakında CogVideoX-5b ve CogVideoX-5b-I2V üzerinde de çalışacağız.</li> <li>70 eğitim videosundan oluşan bir veri seti kullanıldı; çözünürlükleri <code>200 x 480 x 720</code> (F x H x W) idi. Bu veri setinden, veri ön işleme sırasında kare atlama (frame skipping) yöntemiyle, daha hızlı deneyler için ve CogVideoX ekibinin önerdiği maksimum sınırın 49 kare olması nedeniyle, 49 karelik ve 16 karelik iki daha küçük veri seti oluşturduk. 70 videodan 10, 25 ve 50 videodan oluşan üç grup oluşturduk. Tüm videolar, eğitilen kavramın doğası açısından benzerdi.</li> <li>Yeni kavramlar ve stiller için eğitimde 25+ video en iyi sonucu verdi.</li> <li><code>--id_token</code> olarak belirtilebilen bir tanımlayıcı jetonu ile eğitimin daha iyi olduğunu tespit ettik. Bu, Dreambooth benzeri eğitime benzer ancak böyle bir jeton olmadan normal ince ayar da işe yarar.</li> <li>Eğitilmiş kavram, tamamen alakasız istemlerle birleştirildiğinde oldukça iyi çalıştı. CogVideoX-5B ince ayarlanırsa daha iyi sonuçlar bekliyoruz.</li> <li>Orijinal depo <code>lora_alpha</code> değerini <code>1</code> olarak kullanır. Bu değerin birçok çalışmada uygun olmadığını tespit ettik; bunun nedeni muhtemelen modelleme altyapılarındaki ve eğitim ayarlarındaki farklardır. <code>lora_alpha</code> değerini <code>rank</code> veya <code>rank // 2</code> olarak ayarlamayı öneriyoruz.</li> <li>Eğer orijinal modelle kötü sonuçlar üreten açıklamalara sahip veriler üzerinde eğitim yapıyorsanız, <code>rank</code> değerinin 64 ve üzeri olması uygundur ve CogVideoX ekibinin de önerisi budur. Üretimler eğitim açıklamalarınızda zaten orta düzeyde iyi ise, <code>rank</code> değeri 16/32 olmalıdır. Rank değerinin çok düşük ayarlanmasının, örneğin <code>4</code> olması, ideal olmadığını ve umut verici sonuçlar üretmediğini tespit ettik.</li> <li>CogVideoX yazarları, en iyi sonucu elde etmek için toplamda 4000 eğitim adımı ve 100 eğitim videosu önermektedir. Bu, en iyi sonuçları verebilirken, sınırlı deneyimlerimizde 2000 adım ve 25 videonun da yeterli olabileceğini tespit ettik.</li> <li>Eğitim için Prodigy optimizatörünü kullanırken, <a href="https://huggingface.co/blog/sdxl_lora_advanced_script" rel="nofollow">bu</a> blogdaki önerileri takip edebilirsiniz. Prodigy hızla aşırı öğrenmeye (overfit) eğilimlidir. Çok sınırlı testlerime göre, <code>0.5</code> öğrenme hızının, <code>--prodigy_use_bias_correction</code>, <code>prodigy_safeguard_warmup</code> ve <code>--prodigy_decouple</code> ile birlikte uygun olduğunu gördüm.</li> <li>CogVideoX yazarlarının önerdiği ve Adam/AdamW ile yaptığımız deneylerde 25+ videodan oluşan bir veri seti için önerilen öğrenme oranı <code>1e-3</code> ile <code>1e-4</code> arasındadır.</li></ul> <p>Keşif için sınırlı zaman nedeniyle testlerimizin kapsamlı olmadığını belirtmek isteriz. Verileriniz için en iyi ayarları bulmak amacıyla farklı ayarları denemenizi öneririz.</p></blockquote> <!--[1--><h2 class="relative group"><a id="inference" 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="#inference"><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><!---->Çıkarım<!----></span></h2><!--]--><!----> <p>Bir lora modeli eğittikten sonra, çıkarım işlemi, lora ağırlıklarını <code>CogVideoXPipeline</code> içine yükleyerek basitçe yapılabilir.</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-python "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video
pipe = CogVideoXPipeline.from_pretrained(<span class="hljs-string">&quot;THUDM/CogVideoX-2b&quot;</span>, dtype=torch.float16)
<span class="hljs-comment"># pipe.load_lora_weights(&quot;/path/to/lora/weights&quot;, adapter_name=&quot;cogvideox-lora&quot;) # Or,</span>
pipe.load_lora_weights(<span class="hljs-string">&quot;my-awesome-hf-username/my-awesome-lora-name&quot;</span>, adapter_name=<span class="hljs-string">&quot;cogvideox-lora&quot;</span>) <span class="hljs-comment"># If loading from the HF Hub</span>
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>
<span class="hljs-comment"># Assuming lora_alpha=32 and rank=64 for training. If different, set accordingly</span>
pipe.set_adapters([<span class="hljs-string">&quot;cogvideox-lora&quot;</span>], [<span class="hljs-number">32</span> / <span class="hljs-number">64</span>])
prompt = <span class="hljs-string">&quot;A vast, shimmering ocean flows gracefully under a twilight sky, its waves undulating in a mesmerizing dance of blues and greens. The surface glints with the last rays of the setting sun, casting golden highlights that ripple across the water. Seagulls soar above, their cries blending with the gentle roar of the waves. The horizon stretches infinitely, where the ocean meets the sky in a seamless blend of hues. Close-ups reveal the intricate patterns of the waves, capturing the fluidity and dynamic beauty of the sea in motion.&quot;</span>
frames = pipe(prompt, guidance_scale=<span class="hljs-number">6</span>, use_dynamic_cfg=<span class="hljs-literal">True</span>).frames[<span class="hljs-number">0</span>]
export_to_video(frames, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">8</span>)<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="reduce-memory-usage" 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="#reduce-memory-usage"><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><!---->Bellek kullanımını azaltın<!----></span></h2><!--]--><!----> <p>diffusers kütüphanesi kullanılarak yapılan testlerde, diffusers kütüphanesindeki tüm optimizasyonlar etkinleştirildi. Bu şema, <strong>NVIDIA A100 / H100</strong> mimarileri dışındaki cihazlarda gerçek bellek kullanımı açısından test edilmemiştir. Genel olarak bu şema, <strong>NVIDIA Ampere mimarisi</strong> ve üzerindeki tüm cihazlara uyarlanabilir. Optimizasyonlar devre dışı bırakılırsa bellek tüketimi katlanarak artar ve tepe bellek kullanımı, tablodaki değerin yaklaşık 3 katı olur. Ancak hız yaklaşık 3-4 kat artar. Aşağıdakiler dahil olmak üzere bazı optimizasyonları seçici olarak devre dışı bırakabilirsiniz:</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=" "><!---->pipe<span class="hljs-selector-class">.enable_sequential_cpu_offload</span>()
pipe<span class="hljs-selector-class">.vae</span><span class="hljs-selector-class">.enable_slicing</span>()
pipe<span class="hljs-selector-class">.vae</span><span class="hljs-selector-class">.enable_tiling</span>()<!----></pre></div><!----> <ul><li>Çoklu GPU çıkarımı için <code>enable_sequential_cpu_offload()</code> optimizasyonunun devre dışı bırakılması gerekir.</li> <li>INT8 modelleri kullanmak, düşük bellekli GPU'ları desteklemek ve video kalitesinde minimal kayıpla çalışmak amacıyla yapılır; ancak bu durum, çıkarım hızının önemli ölçüde düşmesine neden olur.</li> <li>CogVideoX-2B modeli <code>FP16</code> hassasiyetinde eğitildi ve tüm CogVideoX-5B modelleri <code>BF16</code> hassasiyetinde eğitildi.
Çıkarım için modelin eğitildiği hassasiyetin kullanılmasını öneririz.</li> <li><a href="https://github.com/pytorch/ao" rel="nofollow">PytorchAO</a> ve <a href="https://github.com/huggingface/optimum-quanto/" rel="nofollow">Optimum-quanto</a>, CogVideoX'in bellek gereksinimlerini azaltmak için metin kodlayıcı, dönüştürücü ve VAE modüllerini nicelleştirmek (quantize) için kullanılabilir. Bu, modelin ücretsiz T4 Colab'larında veya daha küçük belleğe sahip GPU'larda çalışmasına olanak tanır. Ayrıca, TorchAO nicelleştirmesinin <code>torch.compile</code> ile tam olarak uyumlu olduğunu ve bunun çıkarım (inference) hızını önemli ölçüde artırabileceğini belirtmek gerekir. FP8 hassasiyeti, NVIDIA H100 ve üzeri cihazlarda kullanılmalıdır; bu, <code>torch</code>, <code>torchao</code>, <code>diffusers</code> ve <code>accelerate</code> Python paketlerinin kaynak kodundan kurulmasını gerektirir. CUDA 12.4 önerilir.</li> <li>Çıkarım hızı testleri de yukarıdaki bellek optimizasyonu şemasını kullandı. Bellek optimizasyonu olmadan çıkarım hızı yaklaşık %10 artar. Sadece <code>diffusers</code> sürümü modelin kuantizasyonunu destekler.</li> <li>Model yalnızca İngilizce girdiyi destekler; diğer diller, büyük model rafinelemesi yoluyla kullanılmak üzere İngilizceye çevrilebilir.</li> <li>Model ince ayarının bellek kullanımı <code>8 * H100</code> ortamında test edilir ve program <code>Zero 2</code> optimizasyonunu otomatik olarak kullanır. Tabloda belirli bir GPU sayısı belirtilmişse, ince ayar için bu sayı veya daha fazla GPU kullanılmalıdır.</li></ul> <table><thead><tr><th><strong>Öznitelik</strong></th><th><strong>CogVideoX-2B</strong></th><th><strong>CogVideoX-5B</strong></th></tr></thead><tbody><tr><td><strong>Model Adı</strong></td><td>CogVideoX-2B</td><td>CogVideoX-5B</td></tr><tr><td><strong>Çıkarım Hassasiyeti</strong></td><td>FP16<em>(Önerilen), BF16, FP32, FP8</em>, INT8, Desteklenmeyen INT4</td><td>BF16 (Önerilen), FP16, FP32, FP8*, INT8, INT4 desteklenmiyor</td></tr><tr><td><strong>Tek GPU Çıkarım VRAM</strong></td><td>FP16: diffusers kullanımı 12.5GB<em>INT8: torchao ile diffusers kullanımı 7.8GB</em></td><td>BF16: diffusers kullanımı 20.7GB<em>INT8: torchao ile diffusers kullanımı 11.4GB</em></td></tr><tr><td><strong>Çoklu GPU Çıkarım VRAM</strong></td><td>FP16: diffusers kullanılarak 10GB*</td><td>BF16: diffusers kullanılarak 15GB*</td></tr><tr><td><strong>Çıkarım Hızı</strong></td><td>Tek A100: ~90 saniye, Tek H100: ~45 saniye</td><td>Tek A100: ~180 saniye, Tek H100: ~90 saniye</td></tr><tr><td><strong>Hassas Ayar Hassasiyeti</strong></td><td>FP16</td><td>BF16</td></tr><tr><td><strong>İnce Ayar VRAM Tüketimi</strong></td><td>47 GB (bs=1, LORA) 61 GB (bs=2, LORA) 62 GB (bs=1, SFT)</td><td>63 GB (bs=1, LORA) 80 GB (bs=2, LORA) 75 GB (bs=1, SFT)</td></tr></tbody></table> <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/training/cogvideox.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, 355],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
56 kB
·
Xet hash:
941d5aa2aa17756f549d453ad661b673ac030af12427cf5c846c1f675f73e87d

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