TranslateGemma
Translate 55 languages — and text inside images — without leaving your graph
- image
- translated_text
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 toexternal_textand 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 anIMAGEand it reads/translates on-screen text, resizing to the model's preferred 896×896 (theletterboxmode 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/forbiddenmeans 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 intomodels/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_tokenstoo 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.
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 | — |