ComfyUI Node
TranslateGemma
A ComfyUI node in text/translation with 21 inputs and 1 output.
TranslateGemma
- image
- translated_text
◄text►
◄target_languageEnglish►
◄model_size4B►
◄devicedefault►
◄image_enhancefalse►
◄image_resize_modeletterbox►
◄image_two_passtrue►
◄source_languageAuto Detect►
◄external_text—►
◄prompt_modeauto►
◄max_new_tokens512►
◄max_input_tokens2048►
◄truncate_inputtrue►
◄strict_context_limittrue►
◄keep_model_loadedtrue►
◄debugfalse►
◄chinese_conversion_onlyfalse►
◄chinese_conversion_directionauto_flip►
◄long_text_strategydisable►
◄quantizationnone►
Categorytext/translation
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Built-in text input. Ignored when `external_text` is connected. Empty/whitespace returns empty output. | |
| target_language | COMBO | English | Translation target language. Does not affect `chinese_conversion_only=true` (direction is controlled by `chinese_conversion_direction`). |
| model_size | COMBO | 4B | Model size: 4B (fastest) / 12B / 27B trade-off (speed vs quality vs VRAM). Gated HF repos require accepting Gemma terms + authentication (`hf auth login` or HF token env var). |
| device | COMBO | default | Device override (TG-015). default: use ComfyUI's active device. cpu: force CPU. gpu:N: use the Nth host GPU option when available. Invalid saved values fall back to default. |
| imageopt | IMAGE | If connected, uses multimodal path to translate text from the image. Requires explicit `source_language` (Auto Detect is not supported for images). | |
| image_enhanceopt | BOOLEAN | false | Mild contrast/sharpening to help small text visibility; may introduce artifacts on some images. |
| image_resize_modeopt | COMBO | letterbox | letterbox: preserve aspect ratio (pad to 896×896, recommended). processor: official resize (may stretch). stretch: force 896×896 (may distort). |
| image_two_passopt | BOOLEAN | true | Extract text from image first (source→source), then translate extracted text (more accurate, slower). |
| source_languageopt | COMBO | Auto Detect | Auto Detect is supported for text only. Images require explicit source language. If you get wrong-language behavior, set this explicitly. |
| external_textopt | STRING | When connected, overrides `text` even if empty. Intended for chaining from other nodes. | |
| prompt_modeopt | COMBO | auto | auto: structured first, fallback to plain. structured: fail loudly if chat template unavailable. plain: instruction-only (no chat template). |
| max_new_tokensopt | INT | 5120–8192 | 0 = Auto. Maximum output tokens. Higher values allow longer outputs but increase latency; output is also clamped by the model context window. |
| max_input_tokensopt | INT | 20480–8192 | 0 = Auto. Input truncation limit (reserves room for output). Too low can break multimodal inputs/templates. Recommended 2048+ for long documents. |
| truncate_inputopt | BOOLEAN | true | Truncate input if it exceeds max_input_tokens. Disable may cause OOM on long texts. |
| strict_context_limitopt | BOOLEAN | true | Clamp output so input+output stays within model context window. |
| keep_model_loadedopt | BOOLEAN | true | Keep model in memory between runs for faster repeated use; may keep VRAM allocated. |
| debugopt | BOOLEAN | false | Enable debug logging. Sensitive data is redacted by default; set TRANSLATEGEMMA_VERBOSE_DEBUG=1 for full details. |
| chinese_conversion_onlyopt | BOOLEAN | false | OpenCC conversion only (Simplified↔Traditional) without loading the model. Text-only; image not supported. |
| chinese_conversion_directionopt | COMBO | auto_flip | auto_flip: detect input variant and convert to opposite. to_traditional: force Simplified→Traditional. to_simplified: force Traditional→Simplified. Returns error if input is ambiguous with auto_flip. |
| long_text_strategyopt | COMBO | disable | disable: default single-call behavior. auto-continue: if the model stops early (<end_of_turn>) on long input, retry up to 2 rounds to continue the translation and merge outputs (best-effort; slower). segmented: split by blank lines and translate paragraph-by-paragraph, preserving paragraph separators (most robust for very long documents; slowest). |
| quantizationopt | COMBO | none | Best-effort VRAM reduction using bitsandbytes (TG-014). none: No quantization (default, full precision). bnb-8bit: 8-bit quantization (~50% VRAM reduction). bnb-4bit: 4-bit quantization (~75% VRAM reduction, NF4). Requires: CUDA GPU + bitsandbytes installed. Falls back to error with guidance if unavailable. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| translated_text | STRING | — |