> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-docs-custom-nodes-sdk-v2-frontend.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ComfyUI 中的 Bria Eraser、Expand Image 和 GenFill

> 使用 ComfyUI 中的 Bria Eraser、Expand Image 和 Generative Fill 合作节点移除对象、扩展图像，并在遮罩区域内生成内容。

Bria 的图像编辑工具可作为合作节点在 ComfyUI 中使用。本页介绍三种基于遮罩的编辑工作流：**Bria Eraser**（移除物体）、**Bria Expand Image**（在原始边界之外扩展绘制）和 **Bria Generative Fill**（在遮罩区域内生成内容）。这三种工作流都能确保编辑区域以外的内容保持像素级不变。

## Bria 图像编辑擅长什么

* **对象移除**：Bria 橡皮擦可擦除被遮罩的对象或区域，并用周围环境填充，无需提示词
* **图像展开**：Bria 图像展开可在原始边界之外进行 outpainting，生成与图像光照、透视和纹理相匹配的周围环境
* **生成式填充**：Bria 生成式填充可根据提示词重新生成遮罩区域，将新内容艺术化地融入场景
* **像素级完美保留**：这三种工作流都会保持编辑区域之外的内容完全不变

## 输出示例

使用 Bria 橡皮擦移除物体，并对已擦除区域后方的背景进行 inpainting：

![Bria：橡皮擦示例输出](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_Eraser.png)

使用 Bria 图像展开，将场景延伸至原始边界之外：

![Bria：图像展开示例输出](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_Expand_Image.png)

生成式填充，根据提示词重新生成遮罩区域：

![Bria：生成式填充示例输出](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_GenFill.png)

每个工作流都接收一张输入图像和一个遮罩。模板中的 **Painter** 节点提供用于绘制遮罩的画笔画布，**ImageCompare** 节点并排显示之前/之后的结果。Painter 节点仅在 Nodes 2.0 下可用；如果你只看到“Painter: Node 2.0 only”，请通过 **菜单 -> Nodes2.0** 启用 Nodes 2.0，或改用[遮罩编辑器](https://docs.comfy.org/interface/maskeditor)来创建遮罩。

<Tip>
  使用 API 节点需要保证你已经正常登录，并在受许可的网络环境下使用，请参考[API 节点总览](/zh/tutorials/partner-nodes/overview)部分文档来了解使用 API 节点的具体使用要求。
</Tip>

<Tip>
  <Tabs>
    <Tab title="本地用户">
      请确保你的 ComfyUI 已经更新。

      * [ComfyUI 下载](https://www.comfy.org/download)
      * [ComfyUI 更新教程](/zh/installation/update_comfyui)

      本指南里的工作流可以在[工作流模板](/zh/interface/features/template)中找到。如果找不到，可能是 ComfyUI 没有更新。

      如果加载工作流时有节点缺失，可能原因有：

      1. 你用的不是最新版（每夜版）。
      2. 启动时有些节点导入失败。
    </Tab>

    <Tab title="云端用户">
      * [Cloud](https://cloud.comfy.org) 会在 ComfyUI 稳定版本发布后更新。

      所以，如果你发现本文档中有任何核心节点缺失，可能是因为新核心节点尚未在最新稳定版中发布。请等待下一个稳定版发布。
    </Tab>
  </Tabs>
</Tip>

<h3 id="api_bria_eraser">
  Bria：橡皮擦
</h3>

从图像中移除特定物体或区域。遮罩区域会被擦除，并以周围环境内容填充；遮罩之外的所有内容保持不变。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/api_bria_eraser-1.webp" alt="Bria：橡皮擦工作流预览" />

<CardGroup cols={2}>
  <Card title="在 Comfy Cloud 上运行" icon="cloud" href="https://cloud.comfy.org/?template=api_bria_eraser&utm_source=docs&utm_medium=referral&utm_campaign=bria-image-editing">
    在 Comfy Cloud 中打开
  </Card>

  <Card title="下载工作流" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/api_bria_eraser.json">
    下载 JSON，或在模板库中搜索“Bria Eraser”
  </Card>
</CardGroup>

**输入素材**

将此文件上传到对应的 `LoadImage` 节点：

<CardGroup cols={1}>
  <Card title="vintage_girl_yellow_apple.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/vintage_girl_yellow_apple.png">
    下载示例输入图像
  </Card>
</CardGroup>

<div style={{display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '1rem', alignItems: 'start'}}>
  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/vintage_girl_yellow_apple.png" alt="Bria：橡皮擦输入图像" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />

  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_Eraser.png" alt="Bria：橡皮擦示例输出" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />
</div>

**使用方法**

1. **加载图像**：在 `LoadImage` 中上传你的图像。Painter 画布和对比视图会自动更新。
2. **绘制遮罩**：在要移除的物体或区域上涂抹画笔。涂抹范围要稍微超出物体边缘（头发、玻璃、织物、接触点），以便模型有足够的空间进行无痕融合。
3. **运行 `BriaEraser`**：无需提示词。该节点会擦除遮罩区域，并对背景进行 inpainting。如果尚未设置，请输入你的 `api_key`。
4. **对比并保存**：`ImageCompare` 显示之前/之后的结果，`SaveImageAdvanced` 导出结果。

<Note>
  遮罩区域会完全根据周围环境重新生成，因此结果会无缝融合。遮罩是二进制的：白色（255）标记要擦除的区域，其余部分为黑色（0），并且遮罩必须与图像的宽高比相匹配。如需更精确的结果，请使用自动分割遮罩（SAM 风格，如果可用）：API 的 `mask_type` 区分 `manual`（画笔绘制）和 `automatic`（算法生成）遮罩。
</Note>

<h3 id="api_bria_expand_image">
  Bria：展开图像
</h3>

将图像展开到其原始边界之外。原始图像保持不变；系统会生成周围区域，以匹配原始图像的光照、透视和纹理。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/api_bria_expand_image-1.webp" alt="Bria：展开图像工作流预览" />

<CardGroup cols={2}>
  <Card title="在 Comfy Cloud 上运行" icon="cloud" href="https://cloud.comfy.org/?template=api_bria_expand_image&utm_source=docs&utm_medium=referral&utm_campaign=bria-image-editing">
    在 Comfy Cloud 中打开
  </Card>

  <Card title="下载工作流" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/api_bria_expand_image.json">
    下载 JSON，或在模板库中搜索 "Bria Expand Image"
  </Card>
</CardGroup>

**输入素材**

将此文件上传到对应的 `LoadImage` 节点：

<CardGroup cols={1}>
  <Card title="red_sports_car_night.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/red_sports_car_night.png">
    下载示例输入图像
  </Card>
</CardGroup>

<div style={{display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '1rem', alignItems: 'start'}}>
  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/red_sports_car_night.png" alt="Bria：展开图像输入" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />

  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_Expand_Image.png" alt="Bria：展开图像示例输出" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />
</div>

**使用方法**

1. **加载图像**：在 `LoadImage` 中上传你的图像，并将其连接到 `BriaExpandImage`。
2. **选择展开模式**：在 `expand_mode` 下拉菜单中选择：
   * **预设宽高比**：选择 `1:1`、`2:3`、`3:2`、`3:4`、`4:3`、`4:5`、`5:4`、`9:16`、`16:9` 中的任意一个。图像将居中，边缘会展开以适应该比例。
   * **自定义比例**：选择 `custom_ratio`，然后设置 `ratio_width` / `ratio_height`（例如 21:9 时设为 21 和 9）。Bria 接受的宽高比范围为 0.5 到 3.0，因此任何高于 1:2 的比例都需要使用手动模式。
   * **手动**：选择 `manual`，然后将原始图像放置在画布上，并设置 `canvas_width` / `canvas_height`（最大 5000 x 5000）、`image_width` / `image_height` 以及 `image_x` / `image_y`（图像左上角；可为负数以进行裁剪）。
3. **提示词（可选）**：留空时，Bria 会根据输入图像自动生成提示词，并展开以匹配其场景和风格。你也可以编写自己的提示词来明确引导展开方向，例如“街道继续向右延伸”“添加一盏路灯”“不要有其他车辆”。仅支持英文；不支持特殊字符。
4. **可选**：使用 `negative_prompt` 避免不想要的内容，使用 `seed` 重现结果，使用 `moderation` 启用内容审核。
5. **保存**：将图像输出连接到 `SaveImage`。

<Note>
  节点上的 `prompt` 输出会显示实际使用的提示词：即你的输入，或该字段为空时由 Bria 自动生成的提示词。如果目标宽高比与图像当前比例相同（例如将 1:1 图像设置为 `1:1`），则不会进行任何更改，图像将原样返回。画布区域限制为 5,000 x 5,000 像素。为获得最佳效果，请将主要主体保持在总画布面积的 15% 以上。
</Note>

<h3 id="api_bria_genfill">
  Bria：生成式填充
</h3>

根据提示词重新生成图像中的特定区域。遮罩区域会被完全重新生成；遮罩以外的部分保持像素级不变。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/api_bria_genfill-1.webp" alt="Bria：生成式填充工作流预览" />

<CardGroup cols={2}>
  <Card title="在 Comfy Cloud 上运行" icon="cloud" href="https://cloud.comfy.org/?template=api_bria_genfill&utm_source=docs&utm_medium=referral&utm_campaign=bria-image-editing">
    在 Comfy Cloud 中打开
  </Card>

  <Card title="下载工作流" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/api_bria_genfill.json">
    下载 JSON，或在模板库中搜索“Bria: Generative Fill”
  </Card>
</CardGroup>

**输入素材**

将该文件上传到对应的 `LoadImage` 节点：

<CardGroup cols={1}>
  <Card title="retro_girl_cinnamon_bun.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/retro_girl_cinnamon_bun.png">
    下载示例输入图像
  </Card>
</CardGroup>

<div style={{display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '1rem', alignItems: 'start'}}>
  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/retro_girl_cinnamon_bun.png" alt="Bria：生成式填充输入" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />

  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/output/Bria_GenFill.png" alt="Bria：生成式填充示例输出" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />
</div>

**使用方法**

1. **加载图像**：在 `LoadImage` 中上传您的图像。Painter 画布和对比视图会自动更新。
2. **绘制遮罩**：用画笔在要重新生成的区域上涂抹。团块状、由画笔绘制的遮罩效果最佳。涂抹范围要稍微超出物体边缘（头发、眼镜、布料、接触点），以便模型有融合的空间。
3. **编写提示词**：在 `BriaGenFill` 中描述遮罩区域内应生成的内容，就像在执导一个裁剪出的微场景：说出物体的名称、材质和尺寸，说明它如何与表面交互，并要求生成接触阴影。大约 90-110 个词效果最佳。保持 `refine_prompt` 启用。
4. **可选**：使用 `negative_prompt` 避免不需要的细节。使用固定的 `seed` 迭代调整遮罩或措辞，待结果满意后再将种子随机化。
5. **对比并保存**：`ImageCompare` 显示前后对比，`SaveImageAdvanced` 导出结果。

<Note>
  遮罩触发的是生成式替换，而非像素级润饰：遮罩区域表示“重新生成该区域”，而不是“润饰该区域”。
</Note>

## 开始使用

1. 将 ComfyUI 更新到最新版本
2. 前往模板库，搜索 `Bria Eraser`、`Bria Expand Image` 或 `Bria Generative Fill`
