ComfyUI Node

TranslateGemma

A ComfyUI node in text/translation with 21 inputs and 1 output.

By rookiestar28·Created 7 months ago·Updated 2 months ago· 29
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)

NameTypeDefaultDescription
textSTRINGBuilt-in text input. Ignored when `external_text` is connected. Empty/whitespace returns empty output.
target_languageCOMBOEnglishTranslation target language. Does not affect `chinese_conversion_only=true` (direction is controlled by `chinese_conversion_direction`).
model_sizeCOMBO4BModel 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).
deviceCOMBOdefaultDevice 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.
imageoptIMAGEIf connected, uses multimodal path to translate text from the image. Requires explicit `source_language` (Auto Detect is not supported for images).
image_enhanceoptBOOLEANfalseMild contrast/sharpening to help small text visibility; may introduce artifacts on some images.
image_resize_modeoptCOMBOletterboxletterbox: preserve aspect ratio (pad to 896×896, recommended). processor: official resize (may stretch). stretch: force 896×896 (may distort).
image_two_passoptBOOLEANtrueExtract text from image first (source→source), then translate extracted text (more accurate, slower).
source_languageoptCOMBOAuto DetectAuto Detect is supported for text only. Images require explicit source language. If you get wrong-language behavior, set this explicitly.
external_textoptSTRINGWhen connected, overrides `text` even if empty. Intended for chaining from other nodes.
prompt_modeoptCOMBOautoauto: structured first, fallback to plain. structured: fail loudly if chat template unavailable. plain: instruction-only (no chat template).
max_new_tokensoptINT5120–81920 = Auto. Maximum output tokens. Higher values allow longer outputs but increase latency; output is also clamped by the model context window.
max_input_tokensoptINT20480–81920 = Auto. Input truncation limit (reserves room for output). Too low can break multimodal inputs/templates. Recommended 2048+ for long documents.
truncate_inputoptBOOLEANtrueTruncate input if it exceeds max_input_tokens. Disable may cause OOM on long texts.
strict_context_limitoptBOOLEANtrueClamp output so input+output stays within model context window.
keep_model_loadedoptBOOLEANtrueKeep model in memory between runs for faster repeated use; may keep VRAM allocated.
debugoptBOOLEANfalseEnable debug logging. Sensitive data is redacted by default; set TRANSLATEGEMMA_VERBOSE_DEBUG=1 for full details.
chinese_conversion_onlyoptBOOLEANfalseOpenCC conversion only (Simplified↔Traditional) without loading the model. Text-only; image not supported.
chinese_conversion_directionoptCOMBOauto_flipauto_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_strategyoptCOMBOdisabledisable: 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).
quantizationoptCOMBOnoneBest-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)

NameTypeDescription
translated_textSTRING