Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"CogVideoX","local":"cogvideox","sections":[{"title":"๋ฐ์ดํฐ ์ค๋น","local":"data-preparation","sections":[{"title":"์ํ ํ์","local":"small-format","sections":[],"depth":3},{"title":"์คํธ๋ฆผ ํ์","local":"stream-format","sections":[],"depth":3}],"depth":2},{"title":"ํ์ต","local":"training","sections":[],"depth":2},{"title":"์ถ๋ก ","local":"inference","sections":[],"depth":2},{"title":"๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ ์ค์ด๊ธฐ","local":"reduce-memory-usage","sections":[],"depth":2}],"depth":1}"/> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/entry/start.1gaXe03k.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/BObs6oQO.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DPnyVmXs.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/entry/app.BwdYRbCn.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DSGUT_OW.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/C045MWWx.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/6tuJ3nyi.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/nodes/0.CornNeQR.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/IaDvMxLQ.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/nodes/313.Bvta39Wd.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/bKdwVYpU.js" rel="modulepreload"> | |
| <!--26s02k--><meta name="hf:doc:metadata" content="{"title":"CogVideoX","local":"cogvideox","sections":[{"title":"Data Preparation","local":"data-preparation","sections":[{"title":"Small format","local":"small-format","sections":[],"depth":3},{"title":"Stream format","local":"stream-format","sections":[],"depth":3}],"depth":2},{"title":"Training","local":"training","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2},{"title":"Reduce memory usage","local":"reduce-memory-usage","sections":[],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/diffusers/v0.43.0/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๋ ํ๋กฌํํธ์ ๋ ์ ์ ๋ ฌ๋ ์ผ๊ด์ฑ ์๋ ๋น๋์ค๋ฅผ ์์ฑํ๋ ๋ฐ ์ด์ ์ ๋ง์ถ ํ ์คํธ-๋น๋์ค ์์ฑ ๋ชจ๋ธ์ ๋๋ค. ์ด๋ฅผ ์ํด ์ฌ๋ฌ ๋ฐฉ๋ฒ์ ์ฌ์ฉํฉ๋๋ค.</p> <ul><li><p>์์ญ์ ๋ฐ ์๊ฐ์ ์ผ๋ก ๋น๋์ค๋ฅผ ์์ถํ์ฌ ์์ถ๋ฅ ๊ณผ ๋น๋์ค ์ ํ๋๋ฅผ ํฅ์์ํค๋ 3D ๋ณ๋ถ ์คํ ์ธ์ฝ๋</p></li> <li><p>ํ ์คํธ์ ๋น๋์ค๋ฅผ ์ ๋ ฌํ๋ ๋ฐ ๋์์ ์ฃผ๋ ์ ๋ฌธ๊ฐ transformer ๋ธ๋ก๊ณผ ๊ณต๊ฐ์ ๋ฐ ์๊ฐ์ ์ผ๋ก ์ ํํ ๋น๋์ค๋ฅผ ํฌ์ฐฉํ๊ณ ์์ฑํ๊ธฐ ์ํ 3D full attention ๋ชจ๋</p></li></ul> <p>๋น๋์ค ์ง์ ์ฐจ์์ ๋ํ ์ค์ ํ ์คํธ ๊ฒฐ๊ณผ, CogVideoX๋ ์ผ๊ด๋ ์ฃผ์ , ๋์ ์ ๋ณด, ์ผ๊ด๋ ๋ฐฐ๊ฒฝ, ๊ฐ์ฒด ์ ๋ณด, ๋ถ๋๋ฌ์ด ์์ง์, ์์, ์ฅ๋ฉด, ์ธํ ์คํ์ผ, ์๊ฐ์ ์คํ์ผ์์ ์ข์ ํจ๊ณผ๋ฅผ ๋ณด์์ง๋ง, ์ธ๊ฐ ๋์, ๊ณต๊ฐ ๊ด๊ณ, ๋ค์ค ๊ฐ์ฒด์์๋ ์ข์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ง ๋ชปํ์ต๋๋ค.</p> <p>Diffusers๋ฅผ ์ฌ์ฉํ Fine-tuning์ ์ด๋ฌํ ์ ์กฐํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ํ๋ ๋ฐ ๋์์ด ๋ ์ ์์ต๋๋ค.</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><!---->๋ฐ์ดํฐ ์ค๋น<!----></span></h2><!--]--><!----> <p>training scripts๋ ๋ ๊ฐ์ง ํ์์ ๋ฐ์ดํฐ๋ฅผ ์ง์ํฉ๋๋ค.</p> <p>์ฒซ ๋ฒ์งธ ํ์์ ์๊ท๋ชจ ํ์ต์ ์ ํฉํ๋ฉฐ, ๋ ๋ฒ์งธ ํ์์ CSV ํ์์ ์ฌ์ฉํ์ฌ ๋๊ท๋ชจ ํ์ต์ ์ํ ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ์ ๋ ์ ํฉํฉ๋๋ค. ํฅํ Diffusers๋ <code><Video></code> ํ๊ทธ๋ฅผ ์ง์ํ ์์ ์ ๋๋ค.</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><!---->์ํ ํ์<!----></span></h3><!--]--><!----> <p><code>--instance_data_root</code>์ ์ง์ ํ ๋ ์ ๋ฌํ๋ ๊ฒฝ๋ก ๊ธฐ์ค์ผ๋ก ์๋ ๊ฒฝ๋ก์ฌ์ผ ํ๋ ๋น๋์ค ํ์ผ ๊ฒฝ๋ก๋ฅผ ์ค๋ฐ๊ฟ์ผ๋ก ๊ตฌ๋ถํ์ฌ ํฌํจํ๋ ํ์ผ๊ณผ, ์ค๋ฐ๊ฟ์ผ๋ก ๊ตฌ๋ถ๋ ํ๋กฌํํธ๋ฅผ ํฌํจํ๋ ํ์ผ ๋ ๊ฐ์ ๋๋ค. ์ด๋ฅผ ๋ ์ ์ดํดํ๊ธฐ ์ํด ์์๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค!</p> <p><code>--instance_data_root</code>์ <code>/dataset</code>์ผ๋ก ์ง์ ํ๋ค๊ณ ๊ฐ์ ํ๊ณ , ์ด ๋๋ ํ ๋ฆฌ์ <code>prompts.txt</code>์ <code>videos.txt</code> ํ์ผ์ด ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.</p> <p><code>prompts.txt</code> ํ์ผ์๋ ์ค๋ฐ๊ฟ์ผ๋ก ๊ตฌ๋ถ๋ ํ๋กฌํํธ๊ฐ ํฌํจ๋์ด์ผ ํฉ๋๋ค:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class=" "><!---->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'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'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">'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> ํ์ผ์๋ ๋น๋์ค ํ์ผ์ ๊ฒฝ๋ก๋ฅผ ์ค๋ฐ๊ฟ์ผ๋ก ๊ตฌ๋ถํ์ฌ ํฌํจํด์ผ ํฉ๋๋ค. ๊ฒฝ๋ก๋ <code>--instance_data_root</code> ๋๋ ํ ๋ฆฌ์ ๋ํ <em>์๋ ๊ฒฝ๋ก</em>์ฌ์ผ ํฉ๋๋ค.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class=" "><!---->videos<span class="hljs-symbol">/00000.mp4</span> | |
| videos<span class="hljs-symbol">/00001.mp4</span> | |
| ...<!----></pre></div><!----> <p>์ ์ฒด์ ์ผ๋ก, ๋ฐ์ดํฐ์ ๋ฃจํธ ๋๋ ํฐ๋ฆฌ์์ <code>tree</code> ๋ช ๋ น์ ์คํํ๋ฉด ๋ฐ์ดํฐ์ ์ ๋ค์๊ณผ ๊ฐ์ด ํ์๋ฉ๋๋ค:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class=" "><!---->/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>์ด ํ์์ ์ฌ์ฉํ ๋ <code>--caption_column</code>์ <code>prompts.txt</code>์ด๊ณ <code>--video_column</code>์ <code>videos.txt</code>์ฌ์ผ ํฉ๋๋ค.</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><!---->์คํธ๋ฆผ ํ์<!----></span></h3><!--]--><!----> <p>๋จ์ผ CSV ํ์ผ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด ์์๋ฅผ ์ํด <code>metadata.csv</code> ํ์ผ์ด ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ์์๋๋ ํ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class=" "><!----><CAPTION_COLUMN>,<PATH_TO_VIDEO_COLUMN> | |
| <span class="hljs-string">"""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."""</span>,<span class="hljs-string">"""00000.mp4"""</span> | |
| <span class="hljs-string">"""A black and white animated sequence on a ship'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's interior remains static in the background, with minimalistic details such as a bell and open door. The character's dynamic movements and changing expressions drive the narrative, with no camera movement to distract from its evolving reactions and physical gestures."""</span>,<span class="hljs-string">"""00001.mp4"""</span> | |
| ...<!----></pre></div><!----> <p>์ด ๊ฒฝ์ฐ <code>--instance_data_root</code>์ ๋น๋์ค๊ฐ ์ ์ฅ๋ ์์น์ฌ์ผ ํ๋ฉฐ, <code>--dataset_name</code>์ ๋ก์ปฌ ํด๋์ ๊ฒฝ๋ก ๋๋ Hub์ ํธ์คํ ๋ <a href="https://huggingface.co/docs/datasets/v5.2.0/en/package_reference/loading_methods#datasets.load_dataset" rel="nofollow">load_dataset</a> ํธํ ๋ฐ์ดํฐ์ ์ด์ด์ผ ํฉ๋๋ค. <code>https://huggingface.co/datasets/my-awesome-username/minecraft-videos</code>์ Minecraft ๊ฒ์ ํ๋ ์ด ๋น๋์ค๊ฐ ์๋ค๊ณ ๊ฐ์ ํ๋ฉด, <code>my-awesome-username/minecraft-videos</code>๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค.</p> <p>์ด ํ์์ ์ฌ์ฉํ ๋ <code>--caption_column</code>์ <code><CAPTION_COLUMN></code>์ด๊ณ <code>--video_column</code>์ <code><PATH_TO_VIDEO_COLUMN></code>์ด์ด์ผ ํฉ๋๋ค.</p> <p>CSV ํ์์ผ๋ก๋ง ์ ํ๋๋ ๊ฒ์ ์๋๋๋ค. <code>load_dataset</code> ๋ฉ์๋๊ฐ <code><PATH_TO_VIDEO_COLUMN></code>๊ณผ <code><CAPTION_COLUMN></code>์ ๋ก๋ํ ์ ์๋ ํ์ผ ํ์์ ์ง์ํ๋ค๋ฉด ์ด๋ค ํ์์ด๋ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋น๋์ค ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๊ธฐ ์ํด ์ด๋ฌํ ๋ฐ์ดํฐ์ ๊ตฌ์ฑ ์์ ์ ๊ฑฐ์น๋ ์ด์ ๋ <code>load_dataset</code>๊ฐ ๋ชจ๋ ์ข ๋ฅ์ ๋น๋์ค ํ์์ ์์ ํ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค.</p> <blockquote class="note"><p>CogVideoX๋ ๋น๋์ค ์์ฑ์ ์ํด ๊ธธ๊ณ ์ค๋ช ์ ์ธ LLM ์ฆ๊ฐ ํ๋กฌํํธ์ ํจ๊ป ๊ฐ์ฅ ์ ์๋ํฉ๋๋ค. VLM์ ์ฌ์ฉํ์ฌ ์์ฝ์ ์์ฑํ ํ LLM์ผ๋ก ํ๋กฌํํธ๋ฅผ ์ฆ๊ฐํ๋ ๋ฐฉ์์ผ๋ก ๋น๋์ค๋ฅผ ์ ์ฒ๋ฆฌํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค. ์์ ์บก์ ์ ์์ฑํ๊ธฐ ์ํด <a href="https://huggingface.co/openbmb/MiniCPM-V-2_6" rel="nofollow">MiniCPM-V-26</a>๊ณผ <a href="https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct" rel="nofollow">Llama-3.1-8B-Instruct</a>๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ์ด ๊ณผ์ ์ ๋ํ ๋งค์ฐ ๋จ์ํ๊ณ ๊ฐ๊ฒฐํ ์์ ๋ <a href="https://gist.github.com/a-r-r-o-w/4dee20250e82f4e44690a02351324a4a" rel="nofollow">์ฌ๊ธฐ</a>์์ ํ์ธํ ์ ์์ต๋๋ค. ๊ณต์์ ์ผ๋ก ๊ถ์ฅ๋๋ ํ๋กฌํํธ ์ฆ๊ฐ ๋ชจ๋ธ์ <a href="https://huggingface.co/THUDM?search_models=chatglm" rel="nofollow">ChatGLM</a>์ด๋ฉฐ, 50~100๋จ์ด ๊ธธ์ด๊ฐ ์ ์ ํ๋ค๊ณ ํ๊ฐ๋ฉ๋๋ค.</p></blockquote> <blockquote><p>![NOTE] | |
| ๋ฐ์ดํฐ์ ์ด ์ด๋ฏธ ์ ์ฒ๋ฆฌ๋์ด ์์ด์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ, ๋ค์ ๋งค๊ฐ๋ณ์๋ฅผ ์กฐ์ ํ์ฌ ๊ธฐ๋ณธ์ ์ธ ์ ์ฒ๋ฆฌ๋ฅผ ์ํํ ์ ์์ต๋๋ค: <code>--height</code>, <code>--width</code>, <code>--fps</code>, <code>--max_num_frames</code>, <code>--skip_frames_start</code> ๋ฐ <code>--skip_frames_end</code>. | |
| ํ์ฌ ํ์ต ๋ฐฐ์น ํฌ๊ธฐ๊ฐ 1๋ณด๋ค ํฐ ๊ฒฝ์ฐ, ๋ฐ์ดํฐ์ ์ ๋ชจ๋ ๋น๋์ค๋ ๋์ผํ ์์ ๋น๋์ค ํ๋ ์์ ํฌํจํด์ผ ํฉ๋๋ค.</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><!---->ํ์ต<!----></span></h2><!--]--><!----> <p>ํ์ํ ์๊ตฌ ์ฌํญ์ ์ค์นํ์ฌ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ค์ ํด์ผ ํฉ๋๋ค. ๋ค์ ํจํค์ง๊ฐ ํ์ํฉ๋๋ค:</p> <ul><li>์ฌ์ฉ ์ค์ธ ํ์ต ๊ธฐ๋ฅ์ ๋ฐ๋ผ Torch 2.0 ์ด์ (์์ํ/deepspeed ํ์ต์ ๊ฒฝ์ฐ ์ต์ ๋ฒ์ ๋๋ nightly ๋ฒ์ ์ด ํ์ํ ์ ์์)</li> <li>๋ชจ๋ธ๋ง ๋ฐ ํ์ต ๊ด๋ จ ๋ชจ๋ ์์ ์ <code>pip install diffusers transformers accelerate peft huggingface_hub</code></li> <li><code>pip install datasets decord</code>๋ฅผ ์ฌ์ฉํ์ฌ ๋น๋์ค ํ์ต ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํฉ๋๋ค</li> <li>๋ฉ๋ชจ๋ฆฌ ์ต์ ํ ํ์ต์ ์ํด 8-bit Adam ๋๋ AdamW ์ตํฐ๋ง์ด์ ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด <code>pip install bitsandbytes</code></li> <li><code>pip install wandb</code>๋ฅผ ์ ํ์ ์ผ๋ก ์ค์นํ์ฌ ํ์ต ๋ก๊ทธ๋ฅผ ๋ชจ๋ํฐ๋งํ ์ ์์ต๋๋ค</li> <li><code>pip install deepspeed</code>๋ฅผ ์ ํ์ ์ผ๋ก ์ค์นํ์ฌ <a href="https://github.com/microsoft/DeepSpeed" rel="nofollow">DeepSpeed</a> ํ์ต์ ์ํํ ์ ์์ต๋๋ค</li> <li><code>pip install prodigyopt</code> ํ์ต์ Prodigy ์ตํฐ๋ง์ด์ ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ์ ํ์ ์ผ๋ก ์ค์นํ์ธ์</li></ul> <p>์ต์ ๋ฒ์ ์ ์์ ์คํฌ๋ฆฝํธ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์คํํ ์ ์๋๋ก <strong>์์ค์์ ์ค์น</strong>ํ๊ณ , ์์ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฃผ ์ ๋ฐ์ดํธํ๊ณ ์์ ๋ณ ํน์ ์๊ตฌ ์ฌํญ์ ์ค์นํ๊ธฐ ๋๋ฌธ์ ์ค์น๋ฅผ ์ต์ ์ํ๋ก ์ ์งํ๋ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅํฉ๋๋ค. ์ด๋ฅผ ์ํด ์๋ก์ด ๊ฐ์ ํ๊ฒฝ์์ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ์ธ์:</p> <p>โฆ</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-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>์ดํ ํ์ต ์คํฌ๋ฆฝํธ๊ฐ ํฌํจ๋ ์์ ํด๋๋ก ์ด๋ํ์ฌ ์ฌ์ฉํ๋ ์คํฌ๋ฆฝํธ์ ํ์ํ ์์กด์ฑ์ ์ค์นํฉ๋๋ค:</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> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-built_in">cd</span> examples/cogvideo | |
| pip install -r requirements.txt<!----></pre></div><!----> <p>๋ค์์ผ๋ก <a href="https://github.com/huggingface/accelerate/" rel="nofollow">๐ค Accelerate</a> ํ๊ฒฝ์ ์ด๊ธฐํํฉ๋๋ค:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-bash "><!---->accelerate config<!----></pre></div><!----> <p>accelerate ์ค์ ์ ๋ํ ํ๊ฒฝ ๊ด๋ จ ์ง๋ฌธ ์์ด ๊ธฐ๋ณธ accelerate ๊ตฌ์ฑ์ ์ฌ์ฉํ๋ ค๋ฉด</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-bash "><!---->accelerate config default<!----></pre></div><!----> <p>๋๋ ํ๊ฒฝ์ด ์ธํฐ๋ํฐ๋ธ ์ ธ์ ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ(์: ๋ ธํธ๋ถ)</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config | |
| write_basic_config()<!----></pre></div><!----> <p><code>accelerate config</code>๋ฅผ ์คํํ ๋, torch.compile์ ์ฌ์ฉํ๋ฉด ์๋นํ ์๋ ํฅ์์ ๊ธฐ๋ํ ์ ์์ต๋๋ค. PEFT ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ LoRA ํ์ต์ ๋ฐฑ์๋๋ก ์ฌ์ฉ๋๋ฏ๋ก, ํ๊ฒฝ์ <code>peft>=0.6.0</code>์ด ์ค์น๋์ด ์๋์ง ํ์ธํ์ธ์.</p> <p>๋ชจ๋ธ ํ์ต์ด ์๋ฃ๋ ํ ๊น๋ํ ๋ชจ๋ธ ์นด๋์ ํจ๊ป ๋ชจ๋ธ์ Hub์ ์ ๋ก๋ํ๋ ค๋ฉด ๋ก๊ทธ์ธ๋์ด ์๋์ง ํ์ธํ์ธ์:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-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><a href="#data-preparation">๋ฐ์ดํฐ ์ค๋น</a>์ ์ค๋ช ๋ ๋๋ก ๋ฐ์ดํฐ๊ฐ ์ค๋น๋์๋์ง ํ์ธํ์ธ์. ์ค๋น๊ฐ ์๋ฃ๋๋ฉด ํ์ต์ ์์ํ ์ ์์ต๋๋ค!</p> <p>์ ์ฌํ ๊ฐ๋ ์ 50๊ฐ ๋น๋์ค๋ก ํ์ตํ๋ค๊ณ ๊ฐ์ ํ ๋, 1500~2000 ์คํ ์ด ํจ๊ณผ์ ์์ ํ์ธํ์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ณต์ ๊ถ์ฅ ์ฌํญ์ 100๊ฐ ๋น๋์ค์ ์ด 4000 ์คํ ์ ๋๋ค. ๋จ์ผ GPU์์ <code>--train_batch_size</code>๊ฐ <code>1</code>์ธ ์ํ๋ก ํ์ตํ๋ค๊ณ ๊ฐ์ ํ๋ฉด:</p> <ul><li>50๊ฐ ๋น๋์ค์์ 1500 ์คํ ์ <code>30</code>๊ฐ์ ํ์ต ์ํฌํฌ์ ํด๋นํฉ๋๋ค</li> <li>100๊ฐ ๋น๋์ค์์ 4000 ์คํ ์ <code>40</code>๊ฐ์ ํ์ต ์ํฌํฌ์ ํด๋นํฉ๋๋ค</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> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-meta">#!/bin/bash</span> | |
| GPU_IDS=<span class="hljs-string">"0"</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 <CACHE_DIR> \ | |
| --instance_data_root <PATH_TO_WHERE_VIDEO_FILES_ARE_STORED> \ | |
| --dataset_name my-awesome-name/my-awesome-dataset \ | |
| --caption_column <CAPTION_COLUMN> \ | |
| --video_column <PATH_TO_VIDEO_COLUMN> \ | |
| --id_token <ID_TOKEN> \ | |
| --validation_prompt <span class="hljs-string">"<ID_TOKEN> 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'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'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"</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>ํ์ต ์คํ์ ๋ ์ ์ถ์ ํ๊ธฐ ์ํด, ์ ๋ช ๋ น์ด์์ ๋ค์ ํ๋๊ทธ๋ฅผ ์ฌ์ฉํฉ๋๋ค:</p> <ul><li><code>--report_to wandb</code>๋ฅผ ์ฌ์ฉํ๋ฉด ํ์ต ์คํ์ด Weights and Biases์์ ์ถ์ ๋ฉ๋๋ค. ์ด๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด <code>pip install wandb</code>๋ก <code>wandb</code>๋ฅผ ์ค์นํด์ผ ํฉ๋๋ค.</li> <li><code>validation_prompt</code>์ <code>validation_epochs</code>๋ฅผ ์ค์ ํ์ฌ ์คํฌ๋ฆฝํธ๊ฐ ๋ช ๋ฒ์ ๊ฒ์ฆ ์ถ๋ก ์ ์ํํ๋๋ก ํฉ๋๋ค. ์ด๋ฅผ ํตํด ํ์ต์ด ์์๋๋ก ์งํ๋๊ณ ์๋์ง ์ ์ฑ์ ์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.</li></ul> <p><code><ID_TOKEN></code>์ ์ค์ ํ๋ ๊ฒ์ ํ์ ์ฌํญ์ด ์๋๋๋ค. ์ ํ์ ์ธ ์คํ์ ํตํด, <a href="https://huggingface.co/docs/diffusers/en/training/dreambooth" rel="nofollow">Dreambooth</a> ํ์ต๊ณผ ์ ์ฌํ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๋ฏ๋ก <code><ID_TOKEN></code>๋ฅผ ์ ๊ณตํ์ง ์๋ ๊ฒฝ์ฐ๋ณด๋ค ์ ๊ณตํ์ ๋ ์ฑ๋ฅ์ด ๋ ์ข์์ ํ์ธํ์ต๋๋ค. <code><ID_TOKEN></code>๊ฐ ์ ๊ณต๋๋ฉด ๊ฐ ํ๋กฌํํธ์ ์์ ์ถ๊ฐ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด, <code><ID_TOKEN></code>์ด <code>"DISNEY"</code>์ด๊ณ ํ๋กฌํํธ๊ฐ <code>"Spiderman swinging over buildings"</code>์ธ ๊ฒฝ์ฐ, ํ์ต์ ์ค์ ๋ก ์ฌ์ฉ๋๋ ํ๋กฌํํธ๋ <code>"DISNEY Spiderman swinging over buildings"</code>๊ฐ ๋ฉ๋๋ค. ์ ๊ณตํ์ง ์๋ ๊ฒฝ์ฐ, ์ถ๊ฐ ํ ํฐ ์์ด ํ์ตํ๊ฑฐ๋ ํ์ต์ ์์ํ๊ธฐ ์ ์ ์ํ๋ ์์น์ ํ ํฐ์ ์ ์ฉํ๋๋ก ๋ฐ์ดํฐ์ ์ ์ฆ๊ฐํ ์ ์์ต๋๋ค.</p> <blockquote class="note"><p>๋ฉ๋ชจ๋ฆฌ ์๊ตฌ ์ฌํญ์ ์ค์ด๊ธฐ ์ํด <code>--use_8bit_adam</code>์ ์ ๋ฌํ ์ ์์ต๋๋ค.</p></blockquote> <blockquote class="important"><p>CogVideoX LoRA ํ์ต ์ง์์ด ์ถ๊ฐ๋ ์์ ์ ๋ค์ ์ค์ ์ด ํ ์คํธ๋์์ต๋๋ค:</p> <ul><li>CogVideoX-2b์์ ์ฃผ๋ก ํ ์คํธ๋ฅผ ์ํํ์ต๋๋ค. ๊ณง CogVideoX-5b์ CogVideoX-5b-I2V์ ๋ํ ์์ ์ ์งํํ ์์ ์ ๋๋ค.</li> <li>ํด์๋ <code>200 x 480 x 720</code>(F x H x W)์ธ 70๊ฐ์ ํ์ต ์์์ผ๋ก ๊ตฌ์ฑ๋ ํ๋์ ๋ฐ์ดํฐ์ ์ ์ฌ์ฉํ์ต๋๋ค. ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ ๋จ๊ณ์์ ํ๋ ์ ์คํต์ ์ ์ฉํ์ฌ, ๋ ๋น ๋ฅธ ์คํ์ ์ํด 49ํ๋ ์๊ณผ 16ํ๋ ์์ ๋ ๊ฐ์ ๋ ์์ ๋ฐ์ดํฐ์ ์ ๋ง๋ค์์ต๋๋ค. ์ด๋ CogVideoX ํ์ด ๊ถ์ฅํ๋ ์ต๋ ํ๋ ์ ์๊ฐ 49ํ๋ ์์ด๊ธฐ ๋๋ฌธ์ ๋๋ค. 70๊ฐ ์์ ์ค 10๊ฐ, 25๊ฐ, 50๊ฐ๋ก ๊ตฌ์ฑ๋ ์ธ ๊ทธ๋ฃน์ ๋ง๋ค์์ต๋๋ค. ๋ชจ๋ ์์์ ํ์ต๋๋ ๊ฐ๋ ์ ์ฑ๊ฒฉ์ด ์ ์ฌํ์ต๋๋ค.</li> <li>25๊ฐ ์ด์์ ๋น๋์ค๊ฐ ์๋ก์ด ๊ฐ๋ ๊ณผ ์คํ์ผ์ ํ์ตํ๋ ๋ฐ ๊ฐ์ฅ ํจ๊ณผ์ ์ด์์ต๋๋ค.</li> <li><code>--id_token</code>๋ก ์ง์ ํ ์ ์๋ ์๋ณ์ ํ ํฐ์ ์ฌ์ฉํ์ฌ ํ์ตํ๋ ๊ฒ์ด ๋ ๋์ ๊ฒฐ๊ณผ๋ฅผ ์ป๋๋ค๋ ๊ฒ์ ํ์ธํ์ต๋๋ค. ์ด๋ Dreambooth์ ์ ์ฌํ ํ์ต ๋ฐฉ์๊ณผ ๋น์ทํ์ง๋ง, ์ด๋ฌํ ํ ํฐ ์์ด ์ผ๋ฐ์ ์ธ fine-tuning์ ์ํํ๋ ๊ฒ๋ ๊ฐ๋ฅํฉ๋๋ค.</li> <li>ํ์ต๋ ๊ฐ๋ ์ ์์ ํ ๋ฌด๊ดํ ํ๋กฌํํธ์ ๊ฒฐํฉํ์ ๋ ์๋นํ ์ ์๋ํ๋ ๊ฒ์ผ๋ก ํ์ธ๋์์ต๋๋ค. CogVideoX-5B๋ฅผ ํ์ธํ๋ํ๋ฉด ๋ ๋์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ๊ฒ์ผ๋ก ์์๋ฉ๋๋ค.</li> <li>์๋ณธ ์ ์ฅ์๋ <code>lora_alpha</code>๋ฅผ <code>1</code>๋ก ์ค์ ํ๊ณ ์์ต๋๋ค. ๋ชจ๋ธ๋ง ๋ฐฑ์๋ ๋ฐ ํ์ต ์ค์ ์ ์ฐจ์ด๋ก ์ธํด ์ฌ๋ฌ ์คํ์์ ์ด ๊ฐ์ด ์ ํฉํ์ง ์์ ๊ฒ์ผ๋ก ํ์ธ๋์์ต๋๋ค. <code>lora_alpha</code>๋ฅผ <code>rank</code> ๋๋ <code>rank // 2</code>๋ก ์ค์ ํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.</li> <li>์๋ณธ ๋ชจ๋ธ๋ก ์บก์ ์ ์์ฑํ์ ๋ ๊ฒฐ๊ณผ๊ฐ ์ข์ง ์์ ๋ฐ์ดํฐ๋ก ํ์ตํ๋ ๊ฒฝ์ฐ, <code>rank</code>๋ฅผ 64 ์ด์์ผ๋ก ์ค์ ํ๋ ๊ฒ์ด ์ข์ผ๋ฉฐ CogVideoX ๊ฐ๋ฐํ๋ ์ด๋ฅผ ๊ถ์ฅํฉ๋๋ค. ํ์ต์ฉ ์บก์ ์ผ๋ก ์ด๋ฏธ ์ค๊ฐ ์์ค ์ด์์ ์์ฑ ๊ฒฐ๊ณผ๊ฐ ๋์ค๋ ๊ฒฝ์ฐ, <code>rank</code>๋ฅผ 16/32๋ก ์ค์ ํ๋ฉด ๋ฉ๋๋ค. rank๋ฅผ ๋๋ฌด ๋ฎ๊ฒ ์ค์ ํ๋ฉด, ์๋ฅผ ๋ค์ด <code>4</code>๋ก ์ค์ ํ๋ฉด ์ด์์ ์ด์ง ์์ผ๋ฉฐ ์ ๋งํ ๊ฒฐ๊ณผ๋ฅผ ์ป๊ธฐ ์ด๋ ต๋ค๋ ๊ฒ์ ํ์ธํ์ต๋๋ค.</li> <li>CogVideoX์ ์ ์๋ค์ ์ต์์ ๊ฒฐ๊ณผ๋ฅผ ์ป๊ธฐ ์ํด ์ด 4000๊ฐ์ ํ์ต ๋จ๊ณ์ 100๊ฐ์ ํ์ต ์์์ ๊ถ์ฅํฉ๋๋ค. ์ด๋ ์ต์์ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ ธ์ฌ ์ ์์ง๋ง, ์ ํ์ ์ธ ์คํ์ ํตํด 2000๊ฐ์ ๋จ๊ณ์ 25๊ฐ์ ์์์ผ๋ก๋ ์ถฉ๋ถํ ์ ์์์ ํ์ธํ์ต๋๋ค.</li> <li>Prodigy ์ตํฐ๋ง์ด์ ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ตํ ๋, <a href="https://huggingface.co/blog/sdxl_lora_advanced_script" rel="nofollow">์ด</a> ๋ธ๋ก๊ทธ์ ๊ถ์ฅ ์ฌํญ์ ๋ฐ๋ฅผ ์ ์์ต๋๋ค. Prodigy๋ ๋น ๋ฅด๊ฒ ๊ณผ์ ํฉ๋๋ ๊ฒฝํฅ์ด ์์ต๋๋ค. ๋งค์ฐ ์ ํ์ ์ธ ํ ์คํธ๋ฅผ ํตํด, <code>0.5</code>์ ํ์ต๋ฅ ์ด <code>--prodigy_use_bias_correction</code>, <code>prodigy_safeguard_warmup</code> ๋ฐ <code>--prodigy_decouple</code>์ ํจ๊ป ์ ํฉํ๋ค๋ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค.</li> <li>CogVideoX์ ์ ์๋ค์ด ๊ถ์ฅํ๋ ํ์ต๋ฅ ๊ณผ Adam/AdamW๋ฅผ ์ฌ์ฉํ ์ฐ๋ฆฌ์ ์คํ ๊ฒฐ๊ณผ์ ๋ฐ๋ฅด๋ฉด, 25๊ฐ ์ด์์ ๋น๋์ค๋ก ๊ตฌ์ฑ๋ ๋ฐ์ดํฐ์ ์ ๊ฒฝ์ฐ ํ์ต๋ฅ ์ <code>1e-3</code>์์ <code>1e-4</code> ์ฌ์ด๊ฐ ์ ์ ํฉ๋๋ค.</li></ul> <p>ํ์์ ํ ์ ํ ์๊ฐ์ด ์ ํ์ ์ด๋ฏ๋ก, ์ฐ๋ฆฌ์ ํ ์คํธ๋ ํฌ๊ด์ ์ด์ง ์๋ค๋ ์ ์ ์ ์ํ์ธ์. ๋ฐ์ดํฐ์ ๊ฐ์ฅ ์ ํฉํ ์ค์ ์ ์ฐพ๊ธฐ ์ํด ๋ค์ํ ํ๋ผ๋ฏธํฐ๋ฅผ ์กฐ์ ํด ๋ณด์๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.</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><!---->์ถ๋ก <!----></span></h2><!--]--><!----> <p>lora ๋ชจ๋ธ์ ํ์ตํ ํ์๋ <code>CogVideoXPipeline</code>์ lora ๊ฐ์ค์น๋ฅผ ๋ก๋ํ๋ ๊ฒ๋ง์ผ๋ก ์ถ๋ก ์ ์ํํ ์ ์์ต๋๋ค.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> 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">"THUDM/CogVideoX-2b"</span>, dtype=torch.float16) | |
| <span class="hljs-comment"># pipe.load_lora_weights("/path/to/lora/weights", adapter_name="cogvideox-lora") # Or,</span> | |
| pipe.load_lora_weights(<span class="hljs-string">"my-awesome-hf-username/my-awesome-lora-name"</span>, adapter_name=<span class="hljs-string">"cogvideox-lora"</span>) <span class="hljs-comment"># If loading from the HF Hub</span> | |
| pipe.to(<span class="hljs-string">"cuda"</span>) <span class="hljs-comment"># or "mps", "xpu", "cpu"</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">"cogvideox-lora"</span>], [<span class="hljs-number">32</span> / <span class="hljs-number">64</span>]) | |
| prompt = <span class="hljs-string">"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."</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">"output.mp4"</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><!---->๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ ์ค์ด๊ธฐ<!----></span></h2><!--]--><!----> <p>diffusers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ํ ์คํธํ๋ ๋์, diffusers ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ํฌํจ๋ ๋ชจ๋ ์ต์ ํ๊ฐ ํ์ฑํ๋์์ต๋๋ค. ์ด ๊ตฌ์ฑ์ <strong>NVIDIA A100 / H100</strong> ์ํคํ ์ฒ ์ด์ธ์ ์ฅ์น์์ ์ค์ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ ๋ํด ํ ์คํธ๋์ง ์์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ด ๊ตฌ์ฑ์ <strong>NVIDIA Ampere ์ํคํ ์ฒ</strong> ์ด์์ ๋ชจ๋ ์ฅ์น์ ์ ์ฉํ ์ ์์ต๋๋ค. ์ต์ ํ๊ฐ ๋นํ์ฑํ๋๋ฉด ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ด ์ฆ๊ฐํ๋ฉฐ, ํผํฌ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ ํ์ ์๋ ๊ฐ์ ์ฝ 3๋ฐฐ๊ฐ ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์๋๋ ์ฝ 3~4๋ฐฐ ์ฆ๊ฐํฉ๋๋ค. ๋ค์์ ํฌํจํ์ฌ ์ผ๋ถ ์ต์ ํ๋ฅผ ์ ํ์ ์ผ๋ก ๋นํ์ฑํํ ์ ์์ต๋๋ค:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> ๋ณต์ฌ๋จ</div><!----></button><!----></div> <pre class=" "><!---->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>๋ฉํฐ GPU ์ถ๋ก ์ ์ํด <code>enable_sequential_cpu_offload()</code> ์ต์ ํ๋ฅผ ๋นํ์ฑํํด์ผ ํฉ๋๋ค.</li> <li>INT8 ๋ชจ๋ธ์ ์ฌ์ฉํ๋ฉด ์ถ๋ก ์๋๊ฐ ๋๋ ค์ง๋๋ค. ์ด๋ ๋ฎ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ฐ์ง GPU๋ฅผ ์ง์ํ๋ฉด์ ์์ ํ์ง ์์ค์ ์ต์ํํ๊ธฐ ์ํ ์กฐ์น์ด์ง๋ง, ์ถ๋ก ์๋๋ ํฌ๊ฒ ๊ฐ์ํฉ๋๋ค.</li> <li>CogVideoX-2B ๋ชจ๋ธ์ <code>FP16</code> ์ ๋ฐ๋๋ก ํ์ต๋์์ผ๋ฉฐ, ๋ชจ๋ CogVideoX-5B ๋ชจ๋ธ์ <code>BF16</code> ์ ๋ฐ๋๋ก ํ์ต๋์์ต๋๋ค. | |
| ์ถ๋ก ์์๋ ๋ชจ๋ธ์ด ํ์ต๋ ์ ๋ฐ๋๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.</li> <li><a href="https://github.com/pytorch/ao" rel="nofollow">PytorchAO</a>์ <a href="https://github.com/huggingface/optimum-quanto/" rel="nofollow">Optimum-quanto</a>๋ฅผ ์ฌ์ฉํ๋ฉด ํ ์คํธ ์ธ์ฝ๋, ํธ๋์คํฌ๋จธ, VAE ๋ชจ๋์ ์์ํํ์ฌ CogVideoX์ ๋ฉ๋ชจ๋ฆฌ ์๊ตฌ๋์ ์ค์ผ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ๋ฌด๋ฃ T4 Colab ๋๋ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์์ GPU์์๋ ๋ชจ๋ธ์ ์คํํ ์ ์์ต๋๋ค. ๋ํ, TorchAO ์์ํ๋ <code>torch.compile</code>๊ณผ ์์ ํ ํธํ๋์ด ์ถ๋ก ์๋๋ฅผ ํฌ๊ฒ ํฅ์์ํฌ ์ ์์ต๋๋ค. FP8 ์ ๋ฐ๋๋ NVIDIA H100 ์ด์์ ์ฅ์น์์ ์ฌ์ฉํด์ผ ํ๋ฉฐ, <code>torch</code>, <code>torchao</code>, <code>diffusers</code>, <code>accelerate</code> Python ํจํค์ง์ ์์ค ์ค์น๊ฐ ํ์ํฉ๋๋ค. CUDA 12.4๋ฅผ ๊ถ์ฅํฉ๋๋ค.</li> <li>์ถ๋ก ์๋ ํ ์คํธ์๋ ์์ ๋ฉ๋ชจ๋ฆฌ ์ต์ ํ ๋ฐฉ์์ ์ฌ์ฉํ์ต๋๋ค. ๋ฉ๋ชจ๋ฆฌ ์ต์ ํ๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฉด ์ถ๋ก ์๋๊ฐ ์ฝ 10% ์ฆ๊ฐํฉ๋๋ค. ๋ชจ๋ธ์ <code>diffusers</code> ๋ฒ์ ๋ง ์์ํ๋ฅผ ์ง์ํฉ๋๋ค.</li> <li>๋ชจ๋ธ์ ์์ด ์ ๋ ฅ๋ง ์ง์ํฉ๋๋ค. ๋ค๋ฅธ ์ธ์ด๋ ๋๊ท๋ชจ ๋ชจ๋ธ ์ ์ ๋ฅผ ํตํด ์์ด๋ก ๋ฒ์ญํ์ฌ ์ฌ์ฉํ ์ ์์ต๋๋ค.</li> <li>๋ชจ๋ธ ํ์ธํ๋์ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ <code>8 * H100</code> ํ๊ฒฝ์์ ํ ์คํธ๋์์ผ๋ฉฐ, ํ๋ก๊ทธ๋จ์ ์๋์ผ๋ก <code>Zero 2</code> ์ต์ ํ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ํ์ ํน์ GPU ์๊ฐ ๋ช ์๋ ๊ฒฝ์ฐ, ํด๋น ์ ์ด์์ GPU๋ฅผ ์ฌ์ฉํ์ฌ ํ์ธํ๋์ ์ํํด์ผ ํฉ๋๋ค.</li></ul> <table><thead><tr><th><strong>์์ฑ</strong></th><th><strong>CogVideoX-2B</strong></th><th><strong>CogVideoX-5B</strong></th></tr></thead><tbody><tr><td><strong>๋ชจ๋ธ ์ด๋ฆ</strong></td><td>CogVideoX-2B</td><td>CogVideoX-5B</td></tr><tr><td><strong>์ถ๋ก ์ ๋ฐ๋</strong></td><td>FP16<em>(๊ถ์ฅ), BF16, FP32, FP8</em>, INT8, INT4 ๋ฏธ์ง์</td><td>BF16 (๊ถ์ฅ), FP16, FP32, FP8*, INT8, INT4 ๋ฏธ์ง์</td></tr><tr><td><strong>๋จ์ผ GPU ์ถ๋ก VRAM</strong></td><td>FP16: diffusers ์ฌ์ฉ 12.5GB<em>INT8: torchao์ ํจ๊ป diffusers ์ฌ์ฉ 7.8GB</em></td><td>BF16: diffusers ์ฌ์ฉ 20.7GB<em>INT8: torchao์ ํจ๊ป diffusers ์ฌ์ฉ 11.4GB</em></td></tr><tr><td><strong>๋ฉํฐ GPU ์ถ๋ก VRAM</strong></td><td>FP16: diffusers ์ฌ์ฉ 10GB*</td><td>BF16: diffusers ์ฌ์ฉ 15GB*</td></tr><tr><td><strong>์ถ๋ก ์๋</strong></td><td>A100 1๊ฐ: ์ฝ 90์ด, H100 1๊ฐ: ์ฝ 45์ด</td><td>A100 1๊ฐ: ์ฝ 180์ด, H100 1๊ฐ: ์ฝ 90์ด</td></tr><tr><td><strong>ํ์ธํ๋ ์ ๋ฐ๋</strong></td><td>FP16</td><td>BF16</td></tr><tr><td><strong>ํ์ธํ๋ VRAM ์ฌ์ฉ๋</strong></td><td>47 GB (bs=1, LORA) 61 GB (bs=2, LORA) 62GB (bs=1, SFT)</td><td>63 GB (bs=1, LORA) 80 GB (bs=2, LORA) 75GB (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_ywq9g6 = { | |
| base: "/docs/diffusers/v0.43.0/en", | |
| assets: "/docs/diffusers/v0.43.0/en" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/diffusers/v0.43.0/en/_app/immutable/entry/start.1gaXe03k.js"), | |
| import("/docs/diffusers/v0.43.0/en/_app/immutable/entry/app.BwdYRbCn.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 313], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 57.1 kB
- Xet hash:
- fc20d1b9c5dbe2e29662e08522f5d63158e526b96dd75e3d722b53ab384c035c
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.