ComfyUI Node

TranslateGemma

Translate 55 languages — and text inside images — without leaving your graph

By rookiestar28·Created 8 months ago·Updated 22 days ago· 32
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

TranslateGemma is Google's open-weight translation family, built on Gemma 3, and this node drops it straight into your ComfyUI graph. Fifty-five languages, no API key, no monthly bill - the whole thing runs on your own GPU. The name is a lie in the best way: it doesn't call any API, and "translate" here covers text and the text you can point at inside an image.

The reason most people reach for it is simpler than the multimodal stuff: prompt translation. If English isn't your first language, you've got two bad options - write weaker English prompts, or tab out to Google Translate every other workflow. This node lets you write the prompt in your native language, pipe it through TranslateGemma, and hand clean English to the text encoder. That's the exact use case the community post about this pack led with: "tired of switching tabs to DeepL or Google Translate just to build your prompts."

How it works

Under the hood it's the official google/translategemma-* repos loaded through transformers (AutoModelForImageTextToText, so it's the same multimodal path whether you feed it a string or an image). First run downloads the model snapshot from Hugging Face into ComfyUI/models/LLM/TranslateGemma/<repo>/ - which is where the friction starts, because these repos are gated. The README walks you through accepting the Gemma terms and running hf auth login, or setting HF_TOKEN, then restarting.

You pick a size with model_size: 4B (the default), 12B, or 27B. This is the trade-off dial - speed and VRAM against translation quality. For source_language it does a best-effort local detect (via langid, which is why langid is in requirements.txt), and the node also normalizes Chinese Simplified/Traditional variants. There's even a chinese_conversion_only mode that converts between Simplified and Traditional script via OpenCC without loading a model at all - handy, deterministic, and free of VRAM cost.

The inputs that actually matter

You can ignore most of the 20-ish widgets on first run. The ones worth touching:

  • text / external_text - the string to translate. Connect a prompt from an upstream node to external_text and it overrides the built-in box.
  • target_language - where you're going (default English).
  • source_language - leave on Auto Detect for text, but images require an explicit source. No OCR pre-pass, so Auto Detect doesn't work there.
  • model_size - start with 4B; bump up only if the quality bugs you.
  • image - the fun one. Feed an IMAGE and it reads/translates on-screen text, resizing to the model's preferred 896×896 (the letterbox mode is the sensible default).

The single output is translated_text, a STRING - wire it straight into a CLIP text encode or any node that eats strings. That's the whole pipeline: native language in, English prompt out, no browser involved.

Installing it

Easiest via ComfyUI Manager - search TranslateGemma and install. Manual works too:

cd custom_nodes
git clone https://github.com/rookiestar28/ComfyUI-TranslateGemma.git
cd ComfyUI-TranslateGemma
pip install -r requirements.txt

Then restart, accept the Gemma license on Hugging Face, and authenticate (hf auth login or a HF_TOKEN env var) or the download 401s. ComfyUI Desktop/portable users must run that pip install with ComfyUI's own Python environment, not a global one. Quantization (bnb-8bit / bnb-4bit) is a separate optional install and CUDA-only - skip it unless you're chasing the 12B/27B on a consumer card.

Where people get burned

  • The gated download. 401/403/gated/forbidden means you haven't accepted the terms or set a token. Not a node bug. Downloads are resumable, and if you're behind a proxy or in a region where Hugging Face is flaky, you can manually copy a complete snapshot into models/LLM/TranslateGemma/<repo>/.
  • VRAM reality check. Native, that's ~12 GB for the 4B, ~27 GB for 12B, ~56 GB for 27B. A 4B model eating 12 GB still shocks people - plan around it, or lean on bitsandbytes quantization.
  • Images need an explicit source language. Forget this and you'll get garbage or an error, not a surprise.
  • max_input_tokens too low can truncate the model's visual tokens on image input and produce unrelated output - the node enforces a safe floor, but don't go tweaking it down for fun.
  • Auto Detect can guess Chinese script wrong on short ambiguous text. When it matters, pick the language explicitly.

It also runs remote code with trust_remote_code=False by default and only falls back when required, with an allowlist env var - nice to see after the whole custom-node supply-chain scare, since an LLM node like this is exactly the shape of thing that needs that care. Worth a look if you're a non-English speaker who's been living in browser tabs; it's the one translation node I'd actually reach for.

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