Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Giao diện dòng lệnh","local":"command-line-interface","sections":[{"title":"Các lệnh khả dụng","local":"available-commands","sections":[],"depth":2},{"title":"env","local":"env","sections":[],"depth":2},{"title":"schema","local":"schema","sections":[],"depth":2},{"title":"chạy","local":"run","sections":[{"title":"Truyền các đối số pipeline","local":"passing-pipeline-arguments","sections":[],"depth":3},{"title":"Đang tải","local":"loading","sections":[],"depth":3},{"title":"Tối ưu hóa","local":"optimizations","sections":[],"depth":3},{"title":"Đường ống xử lý dạng module","local":"modular-pipelines","sections":[],"depth":3},{"title":"Đầu ra","local":"outputs","sections":[],"depth":3},{"title":"Thực thi từ xa ( --remote )","local":"remote-execution----remote-","sections":[],"depth":3}],"depth":2},{"title":"custom_blocks","local":"customblocks","sections":[],"depth":2},{"title":"fp16_safetensors","local":"fp16safetensors","sections":[],"depth":2},{"title":"kỹ năng","local":"skills","sections":[],"depth":2}],"depth":1}"/> | |
| <link href="/docs/diffusers/main/en/_app/immutable/entry/start.0S0_iEoG.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/main/en/_app/immutable/chunks/I9eooN77.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.CPdOxCbw.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.DteTvmQZ.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/388.Cww0re_K.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/main/en/_app/immutable/chunks/DSPDl1gz.js" rel="modulepreload"> | |
| <!--1wkohmy--><meta name="hf:doc:metadata" content="{"title":"Command line interface","local":"command-line-interface","sections":[{"title":"Available commands","local":"available-commands","sections":[],"depth":2},{"title":"env","local":"env","sections":[],"depth":2},{"title":"schema","local":"schema","sections":[],"depth":2},{"title":"run","local":"run","sections":[{"title":"Passing pipeline arguments","local":"passing-pipeline-arguments","sections":[],"depth":3},{"title":"Loading","local":"loading","sections":[],"depth":3},{"title":"Optimizations","local":"optimizations","sections":[],"depth":3},{"title":"Modular pipelines","local":"modular-pipelines","sections":[],"depth":3},{"title":"Outputs","local":"outputs","sections":[],"depth":3},{"title":"Remote execution ( --remote )","local":"remote-execution----remote-","sections":[],"depth":3}],"depth":2},{"title":"custom_blocks","local":"customblocks","sections":[],"depth":2},{"title":"fp16_safetensors","local":"fp16safetensors","sections":[],"depth":2},{"title":"skills","local":"skills","sections":[],"depth":2}],"depth":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="command-line-interface" 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="#command-line-interface"><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><!---->Giao diện dòng lệnh<!----></span></h1><!--]--><!----> <p><code>diffusers-cli</code> là một client dòng lệnh để chạy, kiểm tra và đóng gói các pipeline của Diffusers.</p> <!--[1--><h2 class="relative group"><a id="available-commands" 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="#available-commands"><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><!---->Các lệnh khả dụng<!----></span></h2><!--]--><!----> <table><thead><tr><th>Lệnh</th><th>Mục đích</th></tr></thead><tbody><tr><td><a href="#env"><code>env</code></a></td><td>In thông tin môi trường cho các báo cáo lỗi.</td></tr><tr><td><a href="#schema"><code>schema</code></a></td><td>Kiểm tra chữ ký <code>__call__</code> của một pipeline mà không cần tải trọng số.</td></tr><tr><td><a href="#run"><code>run</code></a></td><td>Chạy một pipeline cục bộ hoặc trong Hugging Face Sandbox.</td></tr><tr><td><a href="#customblocks"><code>custom_blocks</code></a></td><td>Đóng gói một lớp con <code>ModularPipelineBlocks</code> cục bộ cho Hub.</td></tr><tr><td><a href="#fp16safetensors"><code>fp16_safetensors</code></a></td><td>Chuyển đổi checkpoint sang fp16 <code>.safetensors</code>.</td></tr><tr><td><a href="#skills"><code>skills</code></a></td><td>Cài đặt các gói kỹ năng có sẵn vào tác nhân lập trình AI của bạn.</td></tr></tbody></table> <blockquote class="tip"><p>Trang này không cung cấp chi tiết cho tất cả các tùy chọn dưới mỗi lệnh con. Để xem danh sách đầy đủ và luôn cập nhật các tùy chọn cho bất kỳ lệnh con nào, hãy chạy <code>diffusers-cli <command> --help</code> (<code>diffusers-cli run --help</code>).</p></blockquote> <!--[1--><h2 class="relative group"><a id="env" 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="#env"><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><!---->env<!----></span></h2><!--]--><!----> <p>In ra phiên bản của Python, PyTorch, Diffusers, thông tin CUDA và các thư viện tùy chọn đã cài đặt. Hãy sử dụng lệnh này khi mở một issue để các nhà phát triển có thể tái tạo lại môi trường của bạ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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli <span class="hljs-built_in">env</span><!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="schema" 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="#schema"><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><!---->schema<!----></span></h2><!--]--><!----> <p>Trả về các đầu vào được chấp nhận của pipeline mà không tải trọng số. Sử dụng khi xây dựng <code>--pipeline-kwargs</code> cho <a href="#run"><code>run</code></a>.</p> <p>Chỉ tệp chỉ mục được tải về. Các pipeline chuẩn đọc <code>model_index.json</code>. Các pipeline modular đọc <code>modular_model_index.json</code>. Các kho chứa khối tùy chỉnh đọc <code>modular_config.json</code> và cần <code>--trust-remote-code</code>, vì việc tải chúng sẽ thực thi mã từ 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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli --format json schema --model black-forest-labs/FLUX.1-dev | |
| diffusers-cli schema --model my-org/my-custom-blocks --trust-remote-code<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="run" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#run"><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><!---->chạy<!----></span></h2><!--]--><!----> <p>Chạy pipeline từ đầu đến cuối. CLI tự động phát hiện kho chuẩn hay kho modular. Nó tự động nạp các đầu vào media từ URL hoặc đường dẫn cục bộ, lưu các đầu ra dựa trên kiểu trả về của pipeline, và có thể chạy từ xa trên Hugging Face Sandbox thông qua <code>--remote</code>.</p> <p>Ví dụ tối giả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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \ | |
| --model black-forest-labs/FLUX.1-dev \ | |
| --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{"prompt": "an astronaut riding a horse"}'</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="passing-pipeline-arguments" 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="#passing-pipeline-arguments"><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><!---->Truyền các đối số pipeline<!----></span></h3><!--]--><!----> <p><code>--pipeline-kwargs</code> nhận một đối tượng JSON được chuyển tiếp đến <code>pipeline(**kwargs)</code>. Các giá trị chuỗi tại các khóa đầu vào phương tiện đã biết sẽ được tự động tải:</p> <ul><li>Hình ảnh (<code>image</code>, <code>last_image</code>, <code>mask_image</code>, <code>control_image</code>, <code>ip_adapter_image</code>, <code>image_2</code>) → <code>PIL.Image</code> thông qua <code>load_image</code>.</li> <li>Video (<code>video</code>, <code>control_video</code>) → <code>list[PIL.Image]</code> thông qua <code>load_video</code>.</li> <li>Âm thanh (<code>initial_audio_waveforms</code>, <code>reference_audio</code>, <code>src_audio</code>) → <code>torch.Tensor</code> thông qua <code>torchaudio.load</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \ | |
| --model black-forest-labs/FLUX.2-klein-9B --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{"prompt": "make the fur grey", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png", "strength": 0.6}'</span><!----></pre></div><!----> <p>Cả media keys và text keys đều nhận một mảng JSON để chạy một lô (batch) qua một lần gọi pipeline duy nhất. Mỗi mục trong danh sách media được tải riêng lẻ (URL, đường dẫn cục bộ, hoặc đường dẫn bucket-mount), và Diffusers xử lý toàn bộ danh sách trong một lần forward pass trên GPU:</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \ | |
| --model black-forest-labs/FLUX.1-Kontext-dev --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{ | |
| "prompt": ["make it grey", "make it pink", "make it blue"], | |
| "image": [ | |
| "https://.../cat1.png", | |
| "https://.../cat2.png", | |
| "https://.../cat3.png" | |
| ] | |
| }'</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="loading" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#loading"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Đang tải<!----></span></h3><!--]--><!----> <p>Cấu hình cách CLI nạp trọng số mô hình và mã pipeline tùy chỉnh.</p> <ul><li><p><code>--dtype {auto, bfloat16, bf16, float16, fp16, float32, fp32}</code> — dtype của trọng số.</p></li> <li><p><code>--device-map <value></code> — vị trí đặt các thành phần. Chấp nhận chuỗi thiết bị torch (<code>cuda</code>, <code>cuda:0</code>, <code>cpu</code>, <code>mps</code>), <code>balanced</code> (tự động chia các thành phần trên các GPU hiển thị), hoặc một dict JSON để đặt vị trí rõ ràng cho từng thành phần. | |
| Nếu bị bỏ qua, hệ thống sẽ tự động phát hiện. Xem <a href="../optimization/device_map">device_map</a> để biết thêm chi tiết.</p></li> <li><p><code>--variant fp16</code> — chọn một biến thể trọng số.</p></li> <li><p><code>--revision <sha></code> — cố định một phiên bản mô hình cụ thể.</p></li> <li><p><code>--trust-remote-code</code> — cho phép mã tùy chỉnh từ Hub (bắt buộc đối với các kho chứa các lớp pipeline tùy chỉnh hoặc các khối modular). Xem <a href="../using-diffusers/custom_pipeline_overview">Các pipeline của cộng đồng</a> để biết về các pipeline tùy chỉnh tiêu chuẩn và <a href="../modular_diffusers/overview">Modular Diffusers</a>.</p></li> <li><p><code>--lora <spec></code> — gắn một bộ thích ứng LoRA sau khi tải. Mỗi giá trị là một từ điển JSON. Lặp lại cờ này để xếp chồng nhiều bộ thích ứng. <code>lora_id</code> là bắt buộc cho mỗi mục, <code>lora_scale</code> mặc định là <code>1.0</code>, và <code>adapter_name</code> là tùy chọn (tự động tạo thành <code>lora_<i></code> khi xếp chồng).</p> <ul><li>Đơn: <code>--lora '{"lora_id": "alvdansen/flux-koda", "lora_scale": 0.8}'</code></li> <li>Nhiều: <code>--lora '{"lora_id": "alvdansen/flux-koda", "lora_scale": 0.6, "adapter_name": "koda"}' --lora '{"lora_id": "Shakker-Labs/FLUX.1-dev-LoRA-AntiBlur", "lora_scale": 0.4}'</code></li></ul> <p>Tất cả các thông số kỹ thuật được nạp bởi <code>pipeline.load_lora_weights(...)</code>, sau đó được kích hoạt cùng nhau bằng một lần gọi duy nhất <code>pipeline.set_adapters(names, adapter_weights=scales)</code>. Xem <a href="../tutorials/using_peft_for_inference">LoRA</a> để có hướng dẫn chi tiết hơn về việc xếp chồng adapter, lập lịch tỷ lệ và thay đổi nóng.</p></li></ul> <!--[2--><h3 class="relative group"><a id="optimizations" 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="#optimizations"><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><!---->Tối ưu hóa<!----></span></h3><!--]--><!----> <ul><li><code>--cpu-offload {model, group, auto}</code> — mục tiêu onload được lấy từ <code>--device-map</code> (chuỗi thiết bị đơn giản bắt buộc cho offload). model — enable_model_cpu_offload cho các pipeline tiêu chuẩn. Xem Model offloading. group — enable_group_offload(offload_type="leaf_level", use_stream=True) cho các pipeline tiêu chuẩn. Xem Group offloading. auto — chỉ dành cho modular với ComponentsManager. Các chế độ tiêu chuẩn sẽ gây lỗi trên các pipeline modular. auto sẽ gây lỗi trên các pipeline tiêu chuẩn. <ul><li><code>model</code> — <code>enable_model_cpu_offload</code> cho các pipeline tiêu chuẩn. Xem <a href="../optimization/memory#model-offloading">Offloading mô hình</a>.</li> <li><code>group</code> — <code>enable_group_offload(offload_type="leaf_level", use_stream=True)</code> cho các pipeline tiêu chuẩn. Xem <a href="../optimization/memory#group-offloading">Group offloading</a>.</li> <li><code>auto</code> — chỉ dùng cho modular với <a href="../modular_diffusers/components_manager"><code>ComponentsManager</code></a>. Các chế độ chuẩn sẽ gây lỗi với pipeline modular. <code>auto</code> sẽ gây lỗi với pipeline chuẩn.</li></ul></li> <li><code>--offload-margin <size></code> — bộ nhớ thiết bị được giữ trống cho các activation dưới <code>--cpu-offload auto</code>, được truyền vào <code>enable_auto_cpu_offload</code> dưới dạng <code>memory_reserve_margin</code> (mặc định là <code>3GB</code>). Hãy tăng giá trị này khi một canvas lớn bị hết bộ nhớ giữa chừng quá trình forward. Bộ offloader sẽ giữ các thành phần ở trạng thái resident chừng nào chúng còn vừa, do đó trên card VRAM cao, margin mặc định có thể không chừa đủ chỗ cho các activation của một video dài.</li> <li><code>--attention-backend</code> — Các kernel attention được lưu trữ trên Hub, tự động tải xuống khi sử dụng lần đầu. Các lựa chọn bao gồm <code>default</code> cùng các backend Hub đã đăng ký trong Diffusers (ví dụ <code>flash_hub</code>, <code>flash_varlen_hub</code>, <code>flash_4_hub</code>, <code>sage_hub</code>, <code>sage_blackwell_hub</code>). Chạy <code>diffusers-cli run --help</code> để xem danh sách hiện tại. Tính năng này chỉ hỗ trợ các pipeline dựa trên Transformer và sẽ bị bỏ qua kèm theo cảnh báo trên các pipeline UNet cũ. Xem <a href="../optimization/attention_backends">Các backend Attention</a>.</li> <li><code>--vae-tiling</code> / <code>--vae-slicing</code> — giảm VRAM khi giải mã VAE. Xem <a href="../optimization/memory#vae-tiling">VAE tiling</a> và <a href="../optimization/memory#vae-slicing">VAE slicing</a>.</li> <li><code>--compile [JSON]</code> — biên dịch các module denoiser bằng <a href="../optimization/fp16#torchcompile">torch.compile</a>. CLI ưu tiên <a href="../optimization/fp16#regional-compilation">biên dịch theo vùng</a> cho các module có các khối lặp lại. <code>--compile</code> đơn thuần sử dụng <code>fullgraph=true</code>. Một đối tượng JSON sẽ được chuyển tiếp đến <code>torch.compile</code>. Không được hỗ trợ cùng với <code>--context-parallel</code>.</li> <li><code>--context-parallel</code> — song song ngữ cảnh theo phong cách Ulysses trên pipeline dựa trên DiT. Cần torchrun cục bộ, nhưng | |
| khi dùng <code>--remote</code>, CLI sẽ tự bọc <code>torchrun --nproc-per-node=gpu</code> cho bạn. Xem <a href="../optimization/context_parallelism">Song song ngữ cảnh</a>.</li></ul> <!--[2--><h3 class="relative group"><a id="modular-pipelines" 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="#modular-pipelines"><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><!---->Đường ống xử lý dạng module<!----></span></h3><!--]--><!----> <p><code>run</code> tự động phát hiện <a href="../modular_diffusers/overview">modular repo</a> — hoặc vì nó có kèm <code>modular_model_index.json</code>, hoặc vì <code>model_index.json</code> của nó chỉ định một lớp con của <code>ModularPipeline</code> — nên không cần cờ nào để bật tính năng này.</p> <p>Một số kho mã module định nghĩa nhiều <em>workflows</em> giống như các tác vụ có tên, chia sẻ các thành phần nhưng khác nhau ở các khối được thực thi và các đầu vào mà chúng nhận. Ví dụ, <a href="../api/pipelines/minimax_h3">MiniMax-H3</a> cung cấp <code>t2va</code> (chuyển văn bản thành video và âm thanh), <code>fl2va</code> (khung hình chính đầu tiên và/hoặc cuối cùng) và <code>ref2va</code> (một hỗn hợp có thứ tự của các tham chiếu hình ảnh, video và âm thanh). Truyền <code>--workflow</code> để chọn một workflow:</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \ | |
| --model MiniMaxAI/MiniMax-H3 --workflow fl2va \ | |
| --pipeline-kwargs <span class="hljs-string">'{ | |
| "prompt": "the camera pushes in slowly as rain falls", | |
| "image": "opening-frame.png", | |
| "last_image": "closing-frame.png", | |
| "num_frames": 124 | |
| }'</span> \ | |
| --output-key videos --output-key audio \ | |
| --fps 24 --sampling-rate 32000 \ | |
| --cpu-offload auto --dtype bf16<!----></pre></div><!----> <p>Việc chọn một workflow chỉ giữ lại các khối của tác vụ đó, do đó pipeline chỉ khai báo các thành phần cần thiết và <code>load_components</code> chỉ lấy các thư mục con tương ứng. Bỏ qua <code>--workflow</code> để giữ lại mọi workflow khả dụng và để pipeline tự chọn theo từng lần gọi dựa trên các đầu vào được cung cấ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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli --format json schema --model MiniMaxAI/MiniMax-H3 --trust-remote-code<!----></pre></div><!----> <p><code>--workflow</code> chỉ áp dụng cho các pipeline dạng modular. Nó sẽ bị bỏ qua kèm theo cảnh báo trên các pipeline tiêu chuẩn.</p> <p>Một pipeline dạng module trả về một <a href="../modular_diffusers/modular_pipeline"><code>PipelineState</code></a> thay vì một đối tượng đầu ra duy nhất, do đó <code>--output-key</code> đặt tên cho giá trị trung gian cần lưu.</p> <!--[2--><h3 class="relative group"><a id="outputs" 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="#outputs"><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><!---->Đầu ra<!----></span></h3><!--]--><!----> <p><code>run</code> phát hiện kiểu đầu ra của pipeline:</p> <ul><li><code>PIL.Image</code>/list → <code><NNNN>.png</code> (chỉ số bù số 0, ví dụ <code>0000.png</code>)</li> <li>Chuỗi hình ảnh → <code>0000.mp4</code> (<code>--fps</code> kiểm soát tốc độ khung hình, mặc định là 8)</li> <li>Mảng âm thanh → <code>0000.wav</code> (<code>--sampling-rate</code> kiểm soát tốc độ)</li> <li>Bất kỳ thứ gì khác → JSON dump</li></ul> <p>Định dạng thư mục đầu ra mặc định là <code>~/.diffusers/cli/run/outputs/diffusers-run-<YYYYMMDDTHHMMSS>-<uuid>/</code>. Mỗi lần chạy sẽ có một thư mục con riêng để các lần gọi liên tiếp không ghi đè lên nhau.</p> <p>Ghi đè bằng <code>--output <path></code>. Cách đường dẫn được mở rộng phụ thuộc vào dạng của nó và kích thước lô:</p> <table><thead><tr><th><code>--output</code></th><th>1 đầu ra</th><th>N đầu ra</th></tr></thead><tbody><tr><td><em>bị bỏ qua</em></td><td>mặc định dir → <code>0000.png</code></td><td>mặc định dir → <code>0000.png</code>, <code>0001.png</code>, <code>0002.png</code>, …</td></tr><tr><td><code>./results/</code> (kèm <code>/</code> ở cuối hoặc một thư mục hiện có)</td><td><code>./results/0000.png</code></td><td><code>./results/0000.png</code>, <code>./results/0001.png</code>, …</td></tr><tr><td><code>my-cat.png</code> (đường dẫn tệp)</td><td><code>my-cat.png</code> (được sử dụng nguyên văn)</td><td><code>my-cat-0000.png</code>, <code>my-cat-0001.png</code>, …</td></tr></tbody></table> <p>Đầu ra dạng thư mục luôn sử dụng tên đệm bằng số (<code>0000</code>, <code>0001</code>, …). Đường dẫn tệp rõ ràng sẽ giữ nguyên phần tên gốc bạn chọn và được thêm chỉ số đệm khi lô tạo ra nhiều đầu ra.</p> <p>Sử dụng <code>--push-to</code> để tải các kết quả lên <a href="https://huggingface.co/docs/hub/en/storage-buckets" rel="nofollow">thùng chứa lưu trữ Hugging Face</a>. Tham số này chấp nhận một</p> <ul><li>ID bucket HF (<code><namespace>/<name></code>)</li> <li><code>hf://buckets/<namespace>/<name>[/<subpath>]</code> <a href="https://huggingface.co/docs/huggingface_hub/main/en/package_reference/hf_uris" rel="nofollow">URI HF</a></li> <li>URL trình duyệt</li></ul> <p>Subpath được dùng làm tiền tố thư mục. Bucket sẽ được tạo nếu chưa tồn tại, và các đối tượng sẽ nằm dưới <code>[<subpath>/]<run_id>/<filename></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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># HF bucket id — files at hf://buckets/alice/edit-outputs/<run_id>/<file></span> | |
| --push-to alice/edit-outputs | |
| <span class="hljs-comment"># URI with subpath — files at hf://buckets/alice/edit-outputs/greyscale/2026-07/<run_id>/<file></span> | |
| --push-to hf://buckets/alice/edit-outputs/greyscale/2026-07 | |
| <span class="hljs-comment"># Browser URL copy-paste from the Hub also works.</span> | |
| --push-to https://huggingface.co/buckets/alice/edit-outputs/tree/greyscale/2026-07<!----></pre></div><!----> <p>Bảng dưới đây mô tả các lần chạy từ xa. Đối với các lần chạy cục bộ, <code>--push-to</code> sẽ tải lên kết quả đã được lưu cục bộ. Nó không ngăn việc tạo tệp cục bộ.</p> <table><thead><tr><th><code>--push-to</code> được đặt?</th><th><code>--output</code> đã được đặt?</th><th>Kết quả</th></tr></thead><tbody><tr><td>không</td><td>không</td><td>tải xuống thư mục cục bộ mặc định</td></tr><tr><td>không</td><td>yes</td><td>tải xuống <code>--output</code></td></tr><tr><td>yes</td><td>không</td><td>chỉ bucket, không tải xuống cục bộ</td></tr><tr><td>yes</td><td>yes</td><td>bucket VÀ <code>--output</code></td></tr></tbody></table> <p><code>--format</code> định dạng metadata trên stdout (đường dẫn, thời gian, thông tin sandbox). Nó không thay đổi định dạng tệp của | |
| chính phương tiện. Ảnh được ghi luôn là PNG, video là MP4, âm thanh là WAV.</p> <!--[2--><h3 class="relative group"><a id="remote-execution----remote-" 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="#remote-execution----remote-"><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><!---->Thực thi từ xa ( --remote )<!----></span></h3><!--]--><!----> <p>Chạy cùng một lệnh bên trong <a href="https://huggingface.co/docs/huggingface_hub/en/guides/sandbox" rel="nofollow">Hugging Face Sandbox</a> — một VM cloud được cách ly, do CLI điều khiển qua HTTP: nó tải lên các đầu vào, chạy pipeline, tải xuống các đầu ra, sau đó kết thúc sandbox. Yêu cầu <code>huggingface_hub>=1.23</code>.</p> <p>Sandbox khởi động từ <a href="https://hub.docker.com/r/diffusers/diffusers-cli-cuda" rel="nofollow"><code>diffusers/diffusers-cli-cuda</code></a>, một | |
| ảnh đã được xây dựng sẵn, bao gồm sẵn torch, CUDA và các phụ thuộc của CLI, do đó một lần chạy lạnh sẽ bắt đầu tạo nội dung ngay | |
| thay vì phải cài đặt trước.</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \ | |
| --model black-forest-labs/FLUX.1-dev --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{"prompt": "an astronaut riding a horse"}'</span> \ | |
| --remote --flavor a100-large<!----></pre></div><!----> <p>Các cờ từ xa:</p> <ul><li><code>--flavor <name></code> — phần cứng sandbox (ví dụ: <code>a10g-small</code>, <code>h200</code>, <code>rtx-pro-6000</code>).</li> <li><code>--timeout <duration></code> — thời gian thực tối đa cho lệnh chạy bên trong sandbox (mặc định là <code>10m</code>).</li> <li><code>--dependencies <pkg></code> — các phụ thuộc pip bổ sung (có thể lặp lại), được cài đặt lên trên image. Hữu ích để cố định (pin) một tarball của nhánh diffusers hoặc thêm các phụ kiện (extras) dành riêng cho pipeline.</li> <li><code>--namespace <name></code> — tạo sandbox dưới một tổ chức/tài khoản HF khác.</li> <li><code>--image <ref></code> — ghi đè ảnh sandbox. Ảnh này phải có sẵn torch + CUDA tương thích với driver của <code>--flavor</code> của bạn. Khi đó, CLI sẽ tự cài đặt các phụ thuộc của nó lên trên mỗi sandbox lạnh, điều mà ảnh mặc định giúp tránh được.</li> <li><code>--volume <bucket-id>[:<mount-path>]</code> — gắn một <a href="https://huggingface.co/docs/hub/en/storage-buckets" rel="nofollow">HF storage bucket</a> vào sandbox dưới dạng thư mục đọc-ghi (có thể lặp lại). Đường dẫn gắn mặc định là <code>/mnt/buckets/<bucket-id></code>. Tham chiếu các tệp đã gắn từ <code>--pipeline-kwargs</code> như bất kỳ đường dẫn cục bộ nào khác. | |
| Chỉ được áp dụng khi tạo sandbox mới và bị bỏ qua khi kết nối lại qua <code>--sandbox-id</code>.</li></ul> <p>Mặc định, mỗi lần chạy <code>--remote</code> là tạm thời (tạo → chạy → tải xuống → hủy bỏ). Để tái sử dụng một sandbox đang chạy giữa các lần chạy — giữ các phụ thuộc, bộ nhớ đệm trọng số mô hình và bộ nhớ đệm <code>torch.compile</code> trên đĩa của nó — hãy giữ nó hoạt động và kết nối lại:</p> <ul><li><code>--keep-alive</code> — không kết thúc sandbox sau khi chạy. id của nó sẽ được in ra.</li> <li><code>--sandbox-id <id></code> — kết nối lại với một sandbox đang được giữ hoạt động thay vì tạo một sandbox mới.</li> <li><code>--idle-timeout <duration></code> — tự động tắt sau khoảng thời gian không hoạt động này (mặc định <code>10m</code>). Chỉ được áp dụng khi tạo sandbox mới và bị bỏ qua khi kết nối lại qua <code>--sandbox-id</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># First run keeps the sandbox alive and prints sandbox_id=<id>.</span> | |
| diffusers-cli run -m black-forest-labs/FLUX.1-dev --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{"prompt": "a cat"}'</span> --remote --flavor a100-large --keep-alive | |
| <span class="hljs-comment"># Reconnect for the next run — the model is already cached, so only inference runs.</span> | |
| diffusers-cli run -m black-forest-labs/FLUX.1-dev --dtype bf16 \ | |
| --pipeline-kwargs <span class="hljs-string">'{"prompt": "a dog"}'</span> --remote --flavor a100-large --sandbox-id <<span class="hljs-built_in">id</span>> | |
| <span class="hljs-comment"># Stop it when done (or let it timeout).</span> | |
| hf sandbox <span class="hljs-built_in">kill</span> <<span class="hljs-built_in">id</span>><!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="customblocks" 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="#customblocks"><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><!---->custom_blocks<!----></span></h2><!--]--><!----> <p>Đóng gói một lớp con <code>ModularPipelineBlocks</code> cục bộ để tải lên Hub. Đọc một tệp Python, quét AST để tìm các lớp kế thừa từ <code>ModularPipelineBlocks</code> hoặc một trong các lớp con tổng hợp của nó (<code>SequentialPipelineBlocks</code>, <code>AutoPipelineBlocks</code>, <code>ConditionalPipelineBlocks</code>, <code>LoopSequentialPipelineBlocks</code>), khởi tạo lớp được chọn và gọi <code>save_pretrained</code> trong thư mục làm việc hiện tại.</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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># Package the first block found in ./block.py</span> | |
| diffusers-cli custom_blocks | |
| <span class="hljs-comment"># Point at a different file / pick a specific class</span> | |
| diffusers-cli custom_blocks --block_module_name my_block.py --block_class_name MyDenoiseBlock<!----></pre></div><!----> <p>Lớp block phải có thể khởi tạo với số lượng đối số constructor bằng 0 và hardcode các giá trị mặc định trong <code>__init__</code> hoặc đọc config từ <code>state</code> của pipeline tại thời điểm gọi.</p> <!--[1--><h2 class="relative group"><a id="fp16safetensors" 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="#fp16safetensors"><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><!---->fp16_safetensors<!----></span></h2><!--]--><!----> <blockquote class="caution"><p>Lệnh này hiện đã bị ngừng hỗ trợ và sẽ bị loại bỏ trong một phiên bản tương lai.</p></blockquote> <p>Chuyển đổi checkpoint trên Hub sang <code>.safetensors</code> fp16 và đẩy kết quả. Hữu ích để giảm kích thước trọng số của repo, giúp tải nhanh hơn. Xem <code>diffusers-cli fp16_safetensors --help</code> để biết chính xác các tham số.</p> <!--[1--><h2 class="relative group"><a id="skills" 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="#skills"><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ỹ năng<!----></span></h2><!--]--><!----> <p>Cài đặt các kỹ năng từ kho diffusers (<a href="https://github.com/huggingface/diffusers/tree/main/.ai/skills" rel="nofollow"><code>.ai/skills/</code></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> Đã sao chép</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># Install a single skill</span> | |
| diffusers-cli skills add <span class="hljs-string">"<skill name>"</span> | |
| <span class="hljs-comment"># Install every skill in the registry</span> | |
| diffusers-cli skills add --all | |
| <span class="hljs-comment"># List available skills with a one-line summary of each</span> | |
| diffusers-cli skills list | |
| <span class="hljs-comment"># Preview a skill's SKILL.md without installing</span> | |
| diffusers-cli skills preview diffusers-cli | |
| <span class="hljs-comment"># Refetch and reinstall every managed skill</span> | |
| diffusers-cli skills update | |
| <span class="hljs-comment"># Install to the user-level directory instead of the current project</span> | |
| diffusers-cli skills add diffusers-cli --global | |
| <span class="hljs-comment"># Install for one agent instead of detecting it from the environment</span> | |
| diffusers-cli skills add --all --claude <span class="hljs-comment"># or --codex / --cursor</span><!----></pre></div><!----> <p>Nếu không có cờ đích, CLI sẽ cài đặt cho tác nhân đã khởi chạy nó, hoặc cho mọi tác nhân khi không thể xác định. Claude Code nhận một gói plugin dưới <code>.claude/skills/diffusers/</code> (được đặt trong không gian tên <code>/diffusers:<skill name></code>). Codex và Cursor nhận <code>.agents/skills/<skill name>/</code>.</p> <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/using-diffusers/cli.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_1qsdbwf = { | |
| 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.0S0_iEoG.js"), | |
| import("/docs/diffusers/main/en/_app/immutable/entry/app.CPdOxCbw.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 388], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 64.3 kB
- Xet hash:
- 3a164ff16e7032ca363585f230eab54d2c8482ca3df3bff567d1e28e45021d16
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.