Buckets:

mishig's picture
download
raw
60.5 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;命令行界面&quot;,&quot;local&quot;:&quot;command-line-interface&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;可用命令&quot;,&quot;local&quot;:&quot;available-commands&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;env&quot;,&quot;local&quot;:&quot;env&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;模式&quot;,&quot;local&quot;:&quot;schema&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;运行&quot;,&quot;local&quot;:&quot;run&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;传递 pipeline 参数&quot;,&quot;local&quot;:&quot;passing-pipeline-arguments&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;加载&quot;,&quot;local&quot;:&quot;loading&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;优化&quot;,&quot;local&quot;:&quot;optimizations&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;模块化流水线&quot;,&quot;local&quot;:&quot;modular-pipelines&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;输出&quot;,&quot;local&quot;:&quot;outputs&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;远程执行(--remote)&quot;,&quot;local&quot;:&quot;remote-execution----remote-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;custom_blocks&quot;,&quot;local&quot;:&quot;customblocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;fp16_safetensors&quot;,&quot;local&quot;:&quot;fp16safetensors&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;技能&quot;,&quot;local&quot;:&quot;skills&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;: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="{&quot;title&quot;:&quot;Command line interface&quot;,&quot;local&quot;:&quot;command-line-interface&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Available commands&quot;,&quot;local&quot;:&quot;available-commands&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;env&quot;,&quot;local&quot;:&quot;env&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;schema&quot;,&quot;local&quot;:&quot;schema&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;run&quot;,&quot;local&quot;:&quot;run&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Passing pipeline arguments&quot;,&quot;local&quot;:&quot;passing-pipeline-arguments&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Loading&quot;,&quot;local&quot;:&quot;loading&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Optimizations&quot;,&quot;local&quot;:&quot;optimizations&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Modular pipelines&quot;,&quot;local&quot;:&quot;modular-pipelines&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Outputs&quot;,&quot;local&quot;:&quot;outputs&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Remote execution ( --remote )&quot;,&quot;local&quot;:&quot;remote-execution----remote-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;custom_blocks&quot;,&quot;local&quot;:&quot;customblocks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;fp16_safetensors&quot;,&quot;local&quot;:&quot;fp16safetensors&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;skills&quot;,&quot;local&quot;:&quot;skills&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/diffusers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="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><!---->命令行界面<!----></span></h1><!--]--><!----> <p><code>diffusers-cli</code> 是一个命令行客户端,用于运行、检查和打包 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><!---->可用命令<!----></span></h2><!--]--><!----> <table><thead><tr><th>命令</th><th>目的</th></tr></thead><tbody><tr><td><a href="#env"><code>env</code></a></td><td>打印环境信息以用于提交错误报告。</td></tr><tr><td><a href="#schema"><code>schema</code></a></td><td><code>__call__</code> 签名</td></tr><tr><td><a href="#run"><code>run</code></a></td><td>在本地或 Hugging Face Sandbox 中运行 pipeline。</td></tr><tr><td><a href="#customblocks"><code>custom_blocks</code></a></td><td>为 Hub 打包一个本地的 <code>ModularPipelineBlocks</code> 子类。</td></tr><tr><td><a href="#fp16safetensors"><code>fp16_safetensors</code></a></td><td>将检查点转换为 fp16 <code>.safetensors</code>。</td></tr><tr><td><a href="#skills"><code>skills</code></a></td><td>将预制的技能包安装到您的 AI 编码代理中。</td></tr></tbody></table> <blockquote class="tip"><p>此页面未列出每个子命令下的所有选项。要查看任意子命令的完整且始终最新的选项列表,请运行 <code>diffusers-cli &lt;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>打印 Python、PyTorch、Diffusers 的版本、CUDA 信息以及已安装的可选依赖项。在提交 issue 时使用它,以便维护者能够复现你的环境配置。</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 "><!---->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><!---->模式<!----></span></h2><!--]--><!----> <p>返回该 pipeline 所接受的输入,而无需下载权重。在构建 <a href="#run"><code>run</code></a> 的 <code>--pipeline-kwargs</code> 时使用它。</p> <p>仅会获取索引文件。标准流水线读取 <code>model_index.json</code>。模块化流水线读取 <code>modular_model_index.json</code>。自定义块仓库读取 <code>modular_config.json</code>,并且需要 <code>--trust-remote-code</code>,因为加载它们会执行 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 "><!---->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><!---->运行<!----></span></h2><!--]--><!----> <p>端到端运行流水线。CLI 会自动检测标准仓库与模块化仓库。它会自动从 URL 或本地路径加载媒体输入,根据流水线的返回类型保存输出,并可通过 <code>--remote</code> 在 Hugging Face Sandbox 上远程运行。</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 "><!---->diffusers-cli run \
--model black-forest-labs/FLUX.1-dev \
--dtype bf16 \
--pipeline-kwargs <span class="hljs-string">&#x27;{&quot;prompt&quot;: &quot;an astronaut riding a horse&quot;}&#x27;</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><!---->传递 pipeline 参数<!----></span></h3><!--]--><!----> <p><code>--pipeline-kwargs</code> 接受一个 JSON 对象,并将其转发给 <code>pipeline(**kwargs)</code>。位于已知媒体输入键处的字符串值会自动加载:</p> <ul><li>图像(<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>load_image</code> 转换为 <code>PIL.Image</code>。</li> <li>视频(<code>video</code>、<code>control_video</code>)→ 通过 <code>load_video</code> 转换为 <code>list[PIL.Image]</code>。</li> <li>音频(<code>initial_audio_waveforms</code>、<code>reference_audio</code>、<code>src_audio</code>)→ 通过 <code>torchaudio.load</code> 转换为 <code>torch.Tensor</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 "><!---->diffusers-cli run \
--model black-forest-labs/FLUX.2-klein-9B --dtype bf16 \
--pipeline-kwargs <span class="hljs-string">&#x27;{&quot;prompt&quot;: &quot;make the fur grey&quot;, &quot;image&quot;: &quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png&quot;, &quot;strength&quot;: 0.6}&#x27;</span><!----></pre></div><!----> <p>媒体键和文本键均接受 JSON 数组,以便通过单次 pipeline 调用执行批量处理。媒体列表中的每个条目都会单独加载(URL、本地路径或 bucket 挂载路径),Diffusers 会在 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> 已复制</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">&#x27;{
&quot;prompt&quot;: [&quot;make it grey&quot;, &quot;make it pink&quot;, &quot;make it blue&quot;],
&quot;image&quot;: [
&quot;https://.../cat1.png&quot;,
&quot;https://.../cat2.png&quot;,
&quot;https://.../cat3.png&quot;
]
}&#x27;</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><!---->加载<!----></span></h3><!--]--><!----> <p>配置 CLI 如何加载模型权重和自定义流水线代码。</p> <ul><li><p><code>--dtype {auto, bfloat16, bf16, float16, fp16, float32, fp32}</code> — 权重数据类型。</p></li> <li><p><code>--device-map &lt;value></code> — 组件放置。接受 torch 设备字符串(<code>cuda</code>、<code>cuda:0</code>、<code>cpu</code>、<code>mps</code>)、<code>balanced</code>(自动将组件拆分到可见的 GPU 上),或用于显式指定每个组件放置位置的 JSON 字典。
如果省略,则自动检测。有关更多详细信息,请参阅 <a href="../optimization/device_map">device_map</a>。</p></li> <li><p><code>--variant fp16</code> — 选择权重变体。</p></li> <li><p><code>--revision &lt;sha></code> — 固定特定的模型版本。</p></li> <li><p><code>--trust-remote-code</code> — 允许使用来自 Hub 的自定义代码(对于包含自定义 pipeline 类或模块化模块的仓库是必需的)。有关标准自定义 pipeline,请参阅 <a href="../using-diffusers/custom_pipeline_overview">Community pipelines</a>;有关模块化 Diffusers,请参阅 <a href="../modular_diffusers/overview">Modular Diffusers</a>。</p></li> <li><p><code>--lora &lt;spec></code> — 在加载后附加一个 LoRA 适配器。每个值都是一个 JSON 字典。重复该标志以堆叠多个适配器。每个条目中 <code>lora_id</code> 为必填项,<code>lora_scale</code> 默认为 <code>1.0</code>,<code>adapter_name</code> 为可选项(堆叠时会自动生成为 <code>lora_&lt;i></code>)。</p> <ul><li>单个:<code>--lora '{"lora_id": "alvdansen/flux-koda", "lora_scale": 0.8}'</code></li> <li>多个:<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>所有规格均由 <code>pipeline.load_lora_weights(...)</code> 加载,然后通过一次 <code>pipeline.set_adapters(names, adapter_weights=scales)</code> 调用同时激活。有关适配器堆叠、缩放调度以及热切换的详细说明,请参阅 <a href="../tutorials/using_peft_for_inference">LoRA</a>。</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><!---->优化<!----></span></h3><!--]--><!----> <ul><li><code>--cpu-offload {model, group, auto}</code> — offload 目标来自 <code>--device-map</code> (offload 所需的纯设备字符串)。 <ul><li><code>model</code> — 用于标准流水线,<code>enable_model_cpu_offload</code>。参见 <a href="../optimization/memory#model-offloading">模型卸载</a>。</li> <li><code>group</code> — 用于标准流水线,调用 <code>enable_group_offload(offload_type="leaf_level", use_stream=True)</code>。请参阅 <a href="../optimization/memory#group-offloading">组卸载</a>。</li> <li><code>auto</code> — 仅在 <a href="../modular_diffusers/components_manager"><code>ComponentsManager</code></a> 中支持模块化。标准模式在模块化管道中会抛出异常。<code>auto</code> 在标准管道中会抛出异常。</li></ul></li> <li><code>--offload-margin &lt;size></code> — 在 <code>--cpu-offload auto</code> 下,为激活值保留的设备内存大小,作为 <code>memory_reserve_margin</code> 参数传递给 <code>enable_auto_cpu_offload</code>(默认值为 <code>3GB</code>)。如果大画布在前向传播过程中出现内存不足,请调高此值。由于 offloader 会在组件能够容纳时保持其驻留,因此在高显存显卡上,默认的 margin 可能无法为长视频的激活值留出足够的空间。</li> <li><code>--attention-backend</code> — 托管在 Hub 上的注意力内核,首次使用时会自动下载。可选值为 <code>default</code> 以及 Diffusers 中注册的 Hub 后端(例如 <code>flash_hub</code>、<code>flash_varlen_hub</code>、<code>flash_4_hub</code>、<code>sage_hub</code>、<code>sage_blackwell_hub</code>)。运行 <code>diffusers-cli run --help</code> 可查看当前列表。它仅支持基于 Transformer 的流水线,在旧版 UNet 流水线中会被忽略并给出警告。参见 <a href="../optimization/attention_backends">注意力后端</a>。</li> <li><code>--vae-tiling</code> / <code>--vae-slicing</code> — 降低 VAE 解码的显存占用。参见 <a href="../optimization/memory#vae-tiling">VAE 分块</a> 和 <a href="../optimization/memory#vae-slicing">VAE 切片</a>。</li> <li><code>--compile [JSON]</code> — 使用 <a href="../optimization/fp16#torchcompile">torch.compile</a> 编译 denoiser 模块。对于包含重复块的模块,CLI 优先采用 <a href="../optimization/fp16#regional-compilation">regional compilation</a>。仅使用 <code>--compile</code> 时,默认使用 <code>fullgraph=true</code>。JSON 对象会直接传递给 <code>torch.compile</code>。不支持与 <code>--context-parallel</code> 一起使用。</li> <li><code>--context-parallel</code> — 基于 DiT 的流水线上的 Ulysses 风格上下文并行。本地需要 torchrun,但在 <code>--remote</code> 下,CLI 会为您封装 <code>torchrun --nproc-per-node=gpu</code>。参见 <a href="../optimization/context_parallelism">上下文并行</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><!---->模块化流水线<!----></span></h3><!--]--><!----> <p><code>run</code> 会自动检测 <a href="../modular_diffusers/overview">模块化仓库</a>——无论是因为它附带了 <code>modular_model_index.json</code>,还是因为其 <code>model_index.json</code> 中指定了 <code>ModularPipeline</code> 的子类——因此无需使用任何标志即可启用。</p> <p>一些模块化仓库定义了多个 <em>工作流</em>,它们类似于命名任务,共享相同的组件,但运行的模块和接受的输入有所不同。例如,<a href="../api/pipelines/minimax_h3">MiniMax-H3</a> 提供了 <code>t2va</code>(文本转视频和音频)、<code>fl2va</code>(首帧和/或尾帧)以及 <code>ref2va</code>(图像、视频和音频参考的有序混合)。传入 <code>--workflow</code> 以选择其中一个:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli run \
--model MiniMaxAI/MiniMax-H3 --workflow fl2va \
--pipeline-kwargs <span class="hljs-string">&#x27;{
&quot;prompt&quot;: &quot;the camera pushes in slowly as rain falls&quot;,
&quot;image&quot;: &quot;opening-frame.png&quot;,
&quot;last_image&quot;: &quot;closing-frame.png&quot;,
&quot;num_frames&quot;: 124
}&#x27;</span> \
--output-key videos --output-key audio \
--fps 24 --sampling-rate 32000 \
--cpu-offload auto --dtype bf16<!----></pre></div><!----> <p>选择某个工作流后,仅保留该任务对应的模块,因此流水线只声明所需的组件,<code>load_components</code> 也只获取相应的子文件夹。省略 <code>--workflow</code> 参数可保留所有可用工作流,让流水线根据每次调用时传入的输入自行选择。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->diffusers-cli --format json schema --model MiniMaxAI/MiniMax-H3 --trust-remote-code<!----></pre></div><!----> <p><code>--workflow</code> 仅适用于模块化流水线。在标准流水线中,该参数会被忽略并触发警告。</p> <p>模块化流水线返回的是 <a href="../modular_diffusers/modular_pipeline"><code>PipelineState</code></a>,而非单个输出对象,因此 <code>--output-key</code> 用于指定要保存的中间结果。</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><!---->输出<!----></span></h3><!--]--><!----> <p><code>run</code> 会检测流水线输出类型:</p> <ul><li><code>PIL.Image</code>/list → <code>&lt;NNNN>.png</code>(零填充索引,例如 <code>0000.png</code>)</li> <li>图像序列 → <code>0000.mp4</code>(<code>--fps</code> 控制帧率,默认值为 8)</li> <li>音频数组 → <code>0000.wav</code>(<code>--sampling-rate</code> 控制采样率)</li> <li>其他任何内容 → JSON 转储</li></ul> <p>默认输出目录格式为 <code>~/.diffusers/cli/run/outputs/diffusers-run-&lt;YYYYMMDDTHHMMSS>-&lt;uuid>/</code>。每次运行都会生成一个独立的子目录,因此连续调用不会相互覆盖。</p> <p>使用 <code>--output &lt;path></code> 进行覆盖。路径的展开方式取决于其形式和批处理大小:</p> <table><thead><tr><th><code>--output</code></th><th>1 个输出</th><th>N 个输出</th></tr></thead><tbody><tr><td><em>已省略</em></td><td>默认目录 → <code>0000.png</code></td><td>默认目录 → <code>0000.png</code>、<code>0001.png</code>、<code>0002.png</code>、……</td></tr><tr><td><code>./results/</code>(末尾的 <code>/</code> 或一个已存在的目录)</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>(文件路径)</td><td><code>my-cat.png</code>(原样使用)</td><td><code>my-cat-0000.png</code>, <code>my-cat-0001.png</code>, …</td></tr></tbody></table> <p>目录输出始终使用纯填充名称(<code>0000</code>、<code>0001</code>、……)。显式文件路径会保留您选择的词干,并在批次产生多个输出时附加填充索引。</p> <p>使用 <code>--push-to</code> 将输出上传到 <a href="https://huggingface.co/docs/hub/en/storage-buckets" rel="nofollow">Hugging Face 存储桶</a>。它接受一个:</p> <ul><li>HF 存储桶 ID(<code>&lt;namespace>/&lt;name></code>)</li> <li><code>hf://buckets/&lt;namespace>/&lt;name>[/&lt;subpath>]</code> <a href="https://huggingface.co/docs/huggingface_hub/main/en/package_reference/hf_uris" rel="nofollow">HF URI</a></li> <li>浏览器 URL</li></ul> <p>子路径用作文件夹前缀。如果存储桶不存在,则会自动创建,对象将放置在 <code>[&lt;subpath>/]&lt;run_id>/&lt;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> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># HF bucket id — files at hf://buckets/alice/edit-outputs/&lt;run_id&gt;/&lt;file&gt;</span>
--push-to alice/edit-outputs
<span class="hljs-comment"># URI with subpath — files at hf://buckets/alice/edit-outputs/greyscale/2026-07/&lt;run_id&gt;/&lt;file&gt;</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>下表描述了远程运行。对于本地运行,<code>--push-to</code> 会上传本地保存的输出。它不会抑制本地文件的创建。</p> <table><thead><tr><th><code>--push-to</code> 是否已设置?</th><th><code>--output</code> 是否已设置?</th><th>结果</th></tr></thead><tbody><tr><td>no</td><td>no</td><td>下载至默认本地目录</td></tr><tr><td>no</td><td>是的</td><td>下载至 <code>--output</code></td></tr><tr><td>是的</td><td>no</td><td>仅 bucket,不进行本地下载</td></tr><tr><td>是的</td><td>是的</td><td>bucket 和 <code>--output</code></td></tr></tbody></table> <p><code>--format</code> 用于控制标准输出中的元数据(路径、耗时、沙箱信息)。它不会更改媒体文件本身的格式。生成的图像始终为 PNG,视频为 MP4,音频为 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><!---->远程执行(--remote)<!----></span></h3><!--]--><!----> <p>在 <a href="https://huggingface.co/docs/huggingface_hub/en/guides/sandbox" rel="nofollow">Hugging Face Sandbox</a> 中运行相同的调用——这是一个由 CLI 通过 HTTP 驱动的隔离云虚拟机:它会上传输入、运行流水线、下载输出,然后终止沙箱。需要 <code>huggingface_hub>=1.23</code>。</p> <p>沙箱从 <a href="https://hub.docker.com/r/diffusers/diffusers-cli-cuda" rel="nofollow"><code>diffusers/diffusers-cli-cuda</code></a> 启动,这是一个预构建的镜像,已内置 torch、CUDA 以及 CLI 的依赖项,因此冷启动时可直接开始生成,而无需先进行安装。</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 "><!---->diffusers-cli run \
--model black-forest-labs/FLUX.1-dev --dtype bf16 \
--pipeline-kwargs <span class="hljs-string">&#x27;{&quot;prompt&quot;: &quot;an astronaut riding a horse&quot;}&#x27;</span> \
--remote --flavor a100-large<!----></pre></div><!----> <p>远程标志:</p> <ul><li><code>--flavor &lt;name></code> — 沙箱硬件(例如,<code>a10g-small</code>、<code>h200</code>、<code>rtx-pro-6000</code>)。</li> <li><code>--timeout &lt;duration></code> — 沙箱内运行命令的最大实际耗时(默认值为 <code>10m</code>)。</li> <li><code>--dependencies &lt;pkg></code> — 额外的 pip 依赖项(可重复使用),将安装在镜像之上。适用于固定 diffusers 分支的 tarball 或添加特定于流水线的额外依赖项。</li> <li><code>--namespace &lt;name></code> — 在不同的 HF 组织/账户下创建沙箱。</li> <li><code>--image &lt;ref></code> — 覆盖沙箱镜像。该镜像必须包含与 <code>--flavor</code> 的驱动程序兼容的 torch + CUDA。随后,CLI 会在每个冷启动的沙箱上安装其自身的依赖项,而默认镜像则避免了这一点。</li> <li><code>--volume &lt;bucket-id>[:&lt;mount-path>]</code> — 将一个 <a href="https://huggingface.co/docs/hub/en/storage-buckets" rel="nofollow">HF 存储桶</a> 以可读写目录的形式挂载到沙箱中(可重复使用)。默认挂载路径为 <code>/mnt/buckets/&lt;bucket-id></code>。在 <code>--pipeline-kwargs</code> 中引用已挂载的文件时,可将其视为任意其他本地路径。
仅在创建新沙箱时生效,通过 <code>--sandbox-id</code> 重新连接时会被忽略。</li></ul> <p>默认情况下,每次 <code>--remote</code> 运行都是临时的(创建 → 运行 → 下载 → 终止)。若要在多次运行之间复用已就绪的沙箱——保留其磁盘上的依赖项、模型权重缓存以及 <code>torch.compile</code> 缓存——请保持沙箱存活并重新连接:</p> <ul><li><code>--keep-alive</code> — 运行结束后不终止沙箱。其 id 会被打印出来。</li> <li><code>--sandbox-id &lt;id></code> — 重新连接到保持活动的沙箱,而不是创建一个新的沙箱。</li> <li><code>--idle-timeout &lt;duration></code> — 在此时长无活动后自动关闭(默认 <code>10m</code>)。仅在创建新沙箱时生效,通过 <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> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># First run keeps the sandbox alive and prints sandbox_id=&lt;id&gt;.</span>
diffusers-cli run -m black-forest-labs/FLUX.1-dev --dtype bf16 \
--pipeline-kwargs <span class="hljs-string">&#x27;{&quot;prompt&quot;: &quot;a cat&quot;}&#x27;</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">&#x27;{&quot;prompt&quot;: &quot;a dog&quot;}&#x27;</span> --remote --flavor a100-large --sandbox-id &lt;<span class="hljs-built_in">id</span>&gt;
<span class="hljs-comment"># Stop it when done (or let it timeout).</span>
hf sandbox <span class="hljs-built_in">kill</span> &lt;<span class="hljs-built_in">id</span>&gt;<!----></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>将本地 <code>ModularPipelineBlocks</code> 子类打包以便上传至 Hub。读取 Python 文件,通过 AST 扫描其中继承自 <code>ModularPipelineBlocks</code> 或其某个复合子类(<code>SequentialPipelineBlocks</code>、<code>AutoPipelineBlocks</code>、<code>ConditionalPipelineBlocks</code>、<code>LoopSequentialPipelineBlocks</code>)的类,实例化所选的类,并在当前工作目录中调用 <code>save_pretrained</code>。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-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>块类必须能够以零个构造参数实例化,并在 <code>__init__</code> 中硬编码默认值,或在调用时从 pipeline 的 <code>state</code> 中读取配置。</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>此命令现已弃用,并将在未来版本中移除。</p></blockquote> <p>将 Hub 上的检查点转换为 fp16 <code>.safetensors</code> 并推送结果。这有助于缩小仓库的权重体积,从而加快加载速度。有关确切参数,请参阅 <code>diffusers-cli fp16_safetensors --help</code>。</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><!---->技能<!----></span></h2><!--]--><!----> <p>从 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> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># Install a single skill</span>
diffusers-cli skills add <span class="hljs-string">&quot;&lt;skill name&gt;&quot;</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&#x27;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>若未指定目标标志,CLI 将为启动它的 agent 进行安装;若无法确定,则将为所有 agent 安装。Claude Code 会在 <code>.claude/skills/diffusers/</code> 下安装一个插件包(命名空间为 <code>/diffusers:&lt;skill name></code>)。Codex 和 Cursor 则会安装到 <code>.agents/skills/&lt;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:
60.5 kB
·
Xet hash:
4d856b3798ed29aaf44809a42f1fde18b6b6e780009e1e510da83d8649bb0610

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