图像分区 · 可选离线英译
A translation node for prompts that are allowed to be empty — no API key, no network
- sam_english_prompt
- has_text
If you've ever built a workflow where the SAM prompt is allowed to be blank - the "only protect something if the user actually names it" branch - you've hit the classic problem: an empty string isn't a valid SAM prompt, and a translation step that runs on nothing will error or do something dumb. RegionEditOptionalOfflineEnglish is the polite version of the toolkit's SAM translation node: it translates Chinese to English offline when there's text, and when there isn't, it just tells you so instead of exploding.
The mechanism is the same verified-offline path as its required sibling, but with an escape hatch. The single input is text (multiline, and this one's blank by default). The node strips it; if it comes back empty it returns an empty sam_english_prompt plus has_text = false, which is the signal your graph uses to skip the protection-SAM branch entirely. If it's non-empty Chinese, it runs through the installed Argos Translate zh → en model and returns the translation with has_text = true. English text passes through untouched. Nothing here ever touches the network - no API key, no service call, just the local model.
Why Argos? Because the pack targets Chinese-speaking users doing local edits, and it refuses to phone home to do it. That's also where the setup gotcha lives: requirements.txt installs argostranslate itself, but the actual Chinese→English model is a separate download. You check and install it with the pack's script, using the Python that ComfyUI actually runs:
& "<ComfyUI Python>" scripts\install_argos_zh_en.py --check
& "<ComfyUI Python>" scripts\install_argos_zh_en.py
then restart ComfyUI. If you never use the translation nodes, you don't need the model at all - the README says so explicitly. The one thing to know: if the model is missing and you feed it Chinese, this node (like its required sibling) will raise a clear error rather than silently passing broken text through. That's a feature. A SAM prompt that's still half-Chinese will make the model do unpredictable things; a loud failure won't.
The has_text boolean is the part that makes this node composable. Wire it into a route selector or an enable switch and you get a protection branch that activates itself only when the user bothered to type something. That's the whole point of "optional" in the name.
Install is pack-standard: ComfyUI Manager → search Region Edit Toolkit (registry ID native-region-tile-planner-merge), or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip-install requirements.txt into ComfyUI's actual Python, restart. Remember the separate Argos model step above only if you're actually going to translate.
Fair warning, and this applies to the whole pack: it's young and quiet, so don't expect community threads when something's off. But this particular node's failure modes are blunt and self-explanatory - an empty prompt behaves, a missing model errors loudly, and everything else passes through unchanged.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | 可留空;留空时不执行保护对象 SAM。中文使用已安装的 Argos 模型离线翻译,英文原样通过。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| sam_english_prompt | STRING | — |
| has_text | BOOLEAN | — |