A ComfyUI node for TranslateGemma — Google's open source translation models with 55 languages & multimodal image translation.
32
stars
42
commits
Python
primary language
Aug 9, 2026
updated
A ComfyUI integration for TranslateGemma — Google's open source translation model family built on Gemma 3. It supports 55 languages, multimodal image-to-text translation, and 4B / 12B / 27B model variants for different hardware budgets.
TranslateGemma: A new suite of open translation models
default, cpu, or gpu:N when availableSupported runtime:
>=3.12,<3.14 (Python 3.12 or 3.13)>=4.57.0TranslateGemma.custom_nodes directory (from your ComfyUI root):cd custom_nodes
git clone https://github.com/rookiestar28/ComfyUI-TranslateGemma.git
cd ComfyUI-TranslateGemma
pip install -r requirements.txt
quantization=bnb-8bit / quantization=bnb-4bit on this project's CUDA path:pip install -r requirements-quantization.txt
ComfyUI Desktop and portable ComfyUI users must run this with the Python environment used by ComfyUI, not a separate global Python. This installs bitsandbytes>=0.49.2 and does not replace ComfyUI's PyTorch build. If the optional install or backend check fails, keep quantization=none.
TranslateGemma repos are gated under the Gemma terms.
google/translategemma-4b-itgoogle/translategemma-12b-itgoogle/translategemma-27b-ithf auth login
Alternatively, set one of these environment variables for the ComfyUI process:
HF_TOKENHUGGINGFACE_HUB_TOKENIf the model download stalls at Fetching ... or fails with connection errors, it is usually not a node bug.
Common causes: unstable network, corporate firewall/proxy, DNS issues, or regions where huggingface.co is blocked
(some China networks).
Things to try:
HTTP_PROXY / HTTPS_PROXY for the ComfyUI process.HF_ENDPOINT (or HUGGINGFACE_HUB_ENDPOINT) to a mirror URL, then restart ComfyUI.Notes:
401/403/gated/forbidden, you likely need to accept the license and/or set HF_TOKEN.Models are stored under ComfyUI's models directory in a per-repo folder:
Preferred: ComfyUI/models/LLM/TranslateGemma/<repo_name>/
Fallback (legacy): ComfyUI/models/translate_gemma/<repo_name>/
ComfyUI/models/LLM/TranslateGemma/translategemma-4b-it/
ComfyUI/models/LLM/TranslateGemma/translategemma-12b-it/
ComfyUI/models/LLM/TranslateGemma/translategemma-27b-it/
Yes — you can manually download the model files and place them into the folders above.
This is useful if auto-download is slow/unreliable due to network restrictions (e.g. firewall/proxy, unstable DNS, or
regions where huggingface.co is blocked).
What to do:
ComfyUI/
models/
LLM/
TranslateGemma/
translategemma-4b-it/
config.json
generation_config.json
model.safetensors.index.json
*.safetensors
pytorch_model*.bin (only with the explicit unsafe-weight opt-in)
tokenizer_config.json
special_tokens_map.json
processor_config.json
preprocessor_config.json
chat_template.jinja (if present)
... (other files from the repo)
Notes:
.bin weights remain blocked unless TRANSLATEGEMMA_ALLOW_UNSAFE_WEIGHTS=1 is explicitly set for a reviewed, pinned source. Prefer safetensors.Category: text/translation
All established controls are visible when the node is created in Classic or Vue Nodes. The image and external_text link sockets remain available, and existing positional and named workflow values continue to load without migration.
| Name | Type | Description |
|---|---|---|
text | STRING | Built-in text input (multiline). Ignored when external_text is connected. Empty/whitespace returns empty output. |
external_text | STRING | When connected, overrides text (even if empty). Intended for chaining from other nodes. |
image | IMAGE | If connected, uses multimodal path to translate text from the image. Requires explicit source_language (Auto Detect is not supported for images). |
image_enhance | BOOLEAN | Mild contrast/sharpening to help small text visibility; may introduce artifacts (default: false). |
image_resize_mode | COMBO | letterbox (preserve aspect ratio, recommended) / processor (official resize, may stretch) / stretch (force 896×896, may distort). Default: letterbox. |
image_two_pass | BOOLEAN | Extract text from image first, then translate extracted text (more accurate, slower). Default: true. |
target_language | COMBO | Translation target language. Does not affect chinese_conversion_only=true. |
source_language | COMBO | Auto Detect is supported for text only. Images require explicit source language. Default: Auto Detect. |
model_size | COMBO | 4B (fastest) / 12B / 27B trade-off (speed vs quality vs VRAM). Gated repos require HF authentication. See VRAM Notes below for rough estimates. |
device | COMBO | Device override. default uses ComfyUI's active device; cpu forces CPU; gpu:N selects the Nth host GPU option when available. Invalid saved values fall back to default. |
prompt_mode | COMBO | auto (structured first, fallback to plain) / structured (fail if unavailable) / plain (instruction only). Default: auto. |
max_new_tokens | INT | Maximum output tokens. 0 = Auto (based on input length and remaining context budget). Also clamped by the model context window. Default: 512. |
max_input_tokens | INT | Input truncation limit. 0 = Auto (reserve room for output within context). Too low can break multimodal inputs/templates. Default: 2048. |
truncate_input | BOOLEAN | Truncate input if it exceeds max_input_tokens. Disable may cause OOM. Default: true. |
strict_context_limit | BOOLEAN | Clamp output so input+output stays within model context window. Default: true. |
keep_model_loaded | BOOLEAN | Keep model in memory for faster repeated use; may keep VRAM allocated. Default: true. |
debug | BOOLEAN | Enable debug logging. Sensitive data redacted by default; set TRANSLATEGEMMA_VERBOSE_DEBUG=1 for full details. Default: false. |
chinese_conversion_only | BOOLEAN | OpenCC conversion only (Simplified↔Traditional) without loading the model. Text-only; image not supported. Default: false. |
chinese_conversion_direction | COMBO | auto_flip (detect and flip variant) / to_traditional (force s→t) / to_simplified (force t→s). Default: auto_flip. |
long_text_strategy | COMBO | disable (default single-call) / auto-continue (continue if model stops early) / segmented (paragraph-by-paragraph). Default: disable. |
quantization | COMBO | Best-effort VRAM reduction via bitsandbytes. none (default) / bnb-8bit (~50% VRAM reduction) / bnb-4bit (~75% VRAM reduction). none does not require bitsandbytes; BnB modes require CUDA + optional bitsandbytes install. |
| Name | Type | Description |
|---|---|---|
translated_text | STRING | Translated text |
ComfyUI can expose the JSON files in example_workflows/ through its workflow template browser, or you can import them manually:
basic_text_translation.json: simple text translation.external_text_override_template.json: template for connecting an upstream STRING to external_text.chinese_conversion_only.json: OpenCC Simplified/Traditional conversion without model loading.image_translation_explicit_source.json: image translation template; connect an IMAGE input and keep source_language explicit.long_text_segmented.json: paragraph-by-paragraph long text translation.The shipped templates retain positional widget values for older frontends and include equivalent named values for newer save/restore paths. They do not require a workflow migration.
TranslateGemma's official chat template requires an explicit source_lang_code.
When source_language=Auto Detect, this node performs a best-effort local detection for text inputs.
If you see wrong-language behavior, pick the source_language explicitly.
For images, source_language=Auto Detect is not supported (no OCR pre-pass). Select the correct source_language.
For image translation, the node supports multiple preprocessing modes via image_resize_mode:
letterbox (default): preserve aspect ratio (no stretching) by padding, then resizeprocessor: rely on the official Gemma3 image processor resize to 896×896 (may stretch)stretch: force resize to 896×896 (may distort)If small text is missed, try enabling image_enhance=true to apply mild pixel-only enhancement.
Enhancement tuning (experimental):
TRANSLATEGEMMA_IMAGE_ENHANCE_MODE: gentle (default) or legacyTRANSLATEGEMMA_IMAGE_ENHANCE_CONTRAST: contrast factor (default 1.10)TRANSLATEGEMMA_IMAGE_ENHANCE_SHARPNESS: sharpness factor (default 1.10)TRANSLATEGEMMA_AUTO_MAX_NEW_TOKENS_MAX: optional hard cap for max_new_tokens=0 (Auto) to limit long-form outputs. If unset, Auto is only limited by context budget + other safeguards.When debug=true, the node prints a redacted filename for the preprocessed temporary PNG and keeps it for inspection. Set TRANSLATEGEMMA_VERBOSE_DEBUG=1 only when an exact path is required for local troubleshooting.
Additionally, when debug=true, the node saves intermediate images under debug/:
resize_mode + enhance_mode prefixed filesNote: For image translation, max_input_tokens values that are too small can truncate the model’s visual tokens and cause unrelated outputs. The node enforces a safe minimum when truncation is enabled.
For better Traditional Chinese output consistency, the node maps:
zhzh-HantWhen source_language=Auto Detect, the node will try to distinguish Simplified vs Traditional Chinese:
zh_TW/zh_HK/zh_MO -> zh_Hant, zh_CN/zh_SG/zh_MY -> zhzh_Hant only when the signal is strongIf the text is too short or ambiguous, Auto Detect may still resolve to zh. For guaranteed behavior, select the desired source_language explicitly.
Tip: If your input is Simplified Chinese but you want Traditional output, set source_language=Auto Detect (or Chinese (Simplified)) and target_language=Chinese (Traditional).
If you still see mixed Simplified/Traditional output when targeting Traditional Chinese, you can enable a best-effort post-edit conversion using OpenCC:
pip install opencc-python-reimplementedtarget_language=Chinese (Traditional) the node will convert Simplified → Traditional if OpenCC is availableTRANSLATEGEMMA_TRADITIONAL_POSTEDIT=0For workflows that only need script conversion (Simplified ↔ Traditional) without translation, enable chinese_conversion_only=true. This mode:
target_language to be a Chinese variant (direction is controlled separately)Direction selector (chinese_conversion_direction):
auto_flip (default): Auto-detect input variant and convert to the opposite script
to_traditional: Force Simplified → Traditional (s2t)to_simplified: Force Traditional → Simplified (t2s)Requirements:
pip install opencc-python-reimplementedLimitations:
image is connected, returns an error (use normal translation mode for images)auto_flip may fail on short/ambiguous inputs; use forced direction in those casesWhen to use:
For long texts, the model may stop early (emitting <end_of_turn>) before completing the translation. The long_text_strategy option provides two approaches:
disable (default): Standard single-call behavior. Suitable for most inputs.
auto-continue (also accepts auto_continue): Best-effort continuation when the model stops early on long input.
<end_of_turn>, and input was not truncated.segmented: Translate paragraph-by-paragraph.
When to use:
| Scenario | Recommended |
|---|---|
| Short/medium text (<2000 chars) | disable |
| Long text that sometimes truncates early | auto-continue |
| Very long document with many paragraphs | segmented |
| Speed is critical | disable |
Recommended settings for long documents:
max_input_tokens=0 and max_new_tokens=0 (Auto) so the node stays context-aware.long_text_strategy=auto-continue.long_text_strategy=segmented (more robust, but slower).Limitations:
segmented mode has higher latency for many-paragraph documents.auto-continue continuation quality depends on model; may occasionally repeat or diverge.The node accepts both _ and - variants for language codes (e.g., zh_Hant and zh-Hant). Internally, codes are normalized to match the official TranslateGemma template format.
If an unsupported language is passed, the node prints a warning and defaults to English. Set TRANSLATEGEMMA_STRICT_LANG=1 to raise an error instead.
The following are the authoritative default values for node inputs:
| Setting | Default | Notes |
|---|---|---|
model_size | 4B | Smallest, fastest |
device | default | Use ComfyUI's active device |
max_new_tokens | 512 | Use 0 for auto-sizing |
max_input_tokens | 2048 | Input truncation limit (0 = Auto) |
keep_model_loaded | true | Avoids reload overhead |
truncate_input | true | Prevents OOM on long texts |
debug | false | Enable for diagnostics |
image_resize_mode | letterbox | Preserves aspect ratio |
image_enhance | false | Enables contrast/sharpening |
image_two_pass | true | Extract then translate |
chinese_conversion_only | false | OpenCC conversion without model |
chinese_conversion_direction | auto_flip | Auto-detect and flip variant |
long_text_strategy | disable | Single-call (no continuation) |
quantization | none | No quantization (full precision) |
keep_model_loaded=true for repeated use (avoids reload time).keep_model_loaded=false when memory release after each run is more important than reload latency.Best-effort VRAM reduction for running larger models (12B/27B) on consumer GPUs.
The quantization input allows you to load the model in lower precision using bitsandbytes:
| Mode | VRAM Reduction | Quality | Notes |
|---|---|---|---|
none (default) | — | Best | Full precision (BF16/FP16) |
bnb-8bit | ~50% | Good | 8-bit quantization |
bnb-4bit | ~75% | Acceptable | 4-bit NF4 quantization |
bitsandbytes>=0.49.2 into the Python environment already used by ComfyUI: python -m pip install -r requirements-quantization.txt.pyproject.toml.bitsandbytes is intentionally absent from base requirements.txt. Base installs and quantization=none do not import or require it.
Official upstream packages currently describe NVIDIA CUDA, AMD ROCm, Intel XPU, Intel HPU/Gaudi, CPU, and Apple Silicon/MPS paths. That upstream availability is not the same as project support. This release keeps TranslateGemma's BnB integration on the existing CUDA-only, best-effort path. ROCm, XPU, HPU, CPU, and MPS model loading remain deferred until this project has device-map, load, and inference evidence for each backend. Official Windows x86-64 wheels include CUDA 13.0 builds, but this repository's package-only check does not prove a real TranslateGemma GPU run.
"TranslateGemma bitsandbytes mode ... only for this project's CUDA device path":
quantization=none or select a CUDA device already supported by the active ComfyUI environment."bitsandbytes not installed":
python -m pip install -r requirements-quantization.txt or python -m pip install "bitsandbytes>=0.49.2".quantization=none or the 4B model."BitsAndBytesConfig not found":
"CUDA Setup failed" or "libbitsandbytes_cudaXXX not found" (import succeeds but loading fails):
quantization=none as a workaroundTRANSLATEGEMMA_BNB_4BIT_COMPUTE_DTYPE: Force compute dtype for 4-bit (bf16 or fp16). Default: auto-detect.TRANSLATEGEMMA_BNB_4BIT_DOUBLE_QUANT: Enable double quantization (1 = enabled, 0 = disabled). Default: 1.trust_remote_code=False and retries only when Transformers explicitly reports that repository custom code is required.TRANSLATEGEMMA_ALLOW_REMOTE_CODE=1 only after reviewing the repository code.TRANSLATEGEMMA_REMOTE_CODE_ALLOWLIST=google/translategemma-4b-it,google/translategemma-12b-it to require an exact repository match in addition to the explicit opt-in.TRANSLATEGEMMA_ALLOW_UNSAFE_WEIGHTS=1 as a separate explicit opt-in.TRANSLATEGEMMA_REVISION=<commit-hash>, especially whenever remote code or non-safetensors weights are enabled.debug=true redacts sensitive data (user text content, full filesystem paths).TRANSLATEGEMMA_VERBOSE_DEBUG=1 to enable full diagnostics (for troubleshooting).ComfyUI/models/LLM/TranslateGemma/ and retry.This repository is licensed under the MIT License (see LICENSE). TranslateGemma model weights are governed by Google's Gemma Terms of Use.
42 commits
Python
90.5%
JavaScript
9.5%
A ComfyUI node for TranslateGemma — Google's open source translation models with 55 languages & multimodal image translation.
32
stars
42
commits
Python
primary language
Aug 9, 2026
updated
A ComfyUI integration for TranslateGemma — Google's open source translation model family built on Gemma 3. It supports 55 languages, multimodal image-to-text translation, and 4B / 12B / 27B model variants for different hardware budgets.
TranslateGemma: A new suite of open translation models
default, cpu, or gpu:N when availableSupported runtime:
>=3.12,<3.14 (Python 3.12 or 3.13)>=4.57.0TranslateGemma.custom_nodes directory (from your ComfyUI root):cd custom_nodes
git clone https://github.com/rookiestar28/ComfyUI-TranslateGemma.git
cd ComfyUI-TranslateGemma
pip install -r requirements.txt
quantization=bnb-8bit / quantization=bnb-4bit on this project's CUDA path:pip install -r requirements-quantization.txt
ComfyUI Desktop and portable ComfyUI users must run this with the Python environment used by ComfyUI, not a separate global Python. This installs bitsandbytes>=0.49.2 and does not replace ComfyUI's PyTorch build. If the optional install or backend check fails, keep quantization=none.
TranslateGemma repos are gated under the Gemma terms.
google/translategemma-4b-itgoogle/translategemma-12b-itgoogle/translategemma-27b-ithf auth login
Alternatively, set one of these environment variables for the ComfyUI process:
HF_TOKENHUGGINGFACE_HUB_TOKENIf the model download stalls at Fetching ... or fails with connection errors, it is usually not a node bug.
Common causes: unstable network, corporate firewall/proxy, DNS issues, or regions where huggingface.co is blocked
(some China networks).
Things to try:
HTTP_PROXY / HTTPS_PROXY for the ComfyUI process.HF_ENDPOINT (or HUGGINGFACE_HUB_ENDPOINT) to a mirror URL, then restart ComfyUI.Notes:
401/403/gated/forbidden, you likely need to accept the license and/or set HF_TOKEN.Models are stored under ComfyUI's models directory in a per-repo folder:
Preferred: ComfyUI/models/LLM/TranslateGemma/<repo_name>/
Fallback (legacy): ComfyUI/models/translate_gemma/<repo_name>/
ComfyUI/models/LLM/TranslateGemma/translategemma-4b-it/
ComfyUI/models/LLM/TranslateGemma/translategemma-12b-it/
ComfyUI/models/LLM/TranslateGemma/translategemma-27b-it/
Yes — you can manually download the model files and place them into the folders above.
This is useful if auto-download is slow/unreliable due to network restrictions (e.g. firewall/proxy, unstable DNS, or
regions where huggingface.co is blocked).
What to do:
ComfyUI/
models/
LLM/
TranslateGemma/
translategemma-4b-it/
config.json
generation_config.json
model.safetensors.index.json
*.safetensors
pytorch_model*.bin (only with the explicit unsafe-weight opt-in)
tokenizer_config.json
special_tokens_map.json
processor_config.json
preprocessor_config.json
chat_template.jinja (if present)
... (other files from the repo)
Notes:
.bin weights remain blocked unless TRANSLATEGEMMA_ALLOW_UNSAFE_WEIGHTS=1 is explicitly set for a reviewed, pinned source. Prefer safetensors.Category: text/translation
All established controls are visible when the node is created in Classic or Vue Nodes. The image and external_text link sockets remain available, and existing positional and named workflow values continue to load without migration.
| Name | Type | Description |
|---|---|---|
text | STRING | Built-in text input (multiline). Ignored when external_text is connected. Empty/whitespace returns empty output. |
external_text | STRING | When connected, overrides text (even if empty). Intended for chaining from other nodes. |
image | IMAGE | If connected, uses multimodal path to translate text from the image. Requires explicit source_language (Auto Detect is not supported for images). |
image_enhance | BOOLEAN | Mild contrast/sharpening to help small text visibility; may introduce artifacts (default: false). |
image_resize_mode | COMBO | letterbox (preserve aspect ratio, recommended) / processor (official resize, may stretch) / stretch (force 896×896, may distort). Default: letterbox. |
image_two_pass | BOOLEAN | Extract text from image first, then translate extracted text (more accurate, slower). Default: true. |
target_language | COMBO | Translation target language. Does not affect chinese_conversion_only=true. |
source_language | COMBO | Auto Detect is supported for text only. Images require explicit source language. Default: Auto Detect. |
model_size | COMBO | 4B (fastest) / 12B / 27B trade-off (speed vs quality vs VRAM). Gated repos require HF authentication. See VRAM Notes below for rough estimates. |
device | COMBO | Device override. default uses ComfyUI's active device; cpu forces CPU; gpu:N selects the Nth host GPU option when available. Invalid saved values fall back to default. |
prompt_mode | COMBO | auto (structured first, fallback to plain) / structured (fail if unavailable) / plain (instruction only). Default: auto. |
max_new_tokens | INT | Maximum output tokens. 0 = Auto (based on input length and remaining context budget). Also clamped by the model context window. Default: 512. |
max_input_tokens | INT | Input truncation limit. 0 = Auto (reserve room for output within context). Too low can break multimodal inputs/templates. Default: 2048. |
truncate_input | BOOLEAN | Truncate input if it exceeds max_input_tokens. Disable may cause OOM. Default: true. |
strict_context_limit | BOOLEAN | Clamp output so input+output stays within model context window. Default: true. |
keep_model_loaded | BOOLEAN | Keep model in memory for faster repeated use; may keep VRAM allocated. Default: true. |
debug | BOOLEAN | Enable debug logging. Sensitive data redacted by default; set TRANSLATEGEMMA_VERBOSE_DEBUG=1 for full details. Default: false. |
chinese_conversion_only | BOOLEAN | OpenCC conversion only (Simplified↔Traditional) without loading the model. Text-only; image not supported. Default: false. |
chinese_conversion_direction | COMBO | auto_flip (detect and flip variant) / to_traditional (force s→t) / to_simplified (force t→s). Default: auto_flip. |
long_text_strategy | COMBO | disable (default single-call) / auto-continue (continue if model stops early) / segmented (paragraph-by-paragraph). Default: disable. |
quantization | COMBO | Best-effort VRAM reduction via bitsandbytes. none (default) / bnb-8bit (~50% VRAM reduction) / bnb-4bit (~75% VRAM reduction). none does not require bitsandbytes; BnB modes require CUDA + optional bitsandbytes install. |
| Name | Type | Description |
|---|---|---|
translated_text | STRING | Translated text |
ComfyUI can expose the JSON files in example_workflows/ through its workflow template browser, or you can import them manually:
basic_text_translation.json: simple text translation.external_text_override_template.json: template for connecting an upstream STRING to external_text.chinese_conversion_only.json: OpenCC Simplified/Traditional conversion without model loading.image_translation_explicit_source.json: image translation template; connect an IMAGE input and keep source_language explicit.long_text_segmented.json: paragraph-by-paragraph long text translation.The shipped templates retain positional widget values for older frontends and include equivalent named values for newer save/restore paths. They do not require a workflow migration.
TranslateGemma's official chat template requires an explicit source_lang_code.
When source_language=Auto Detect, this node performs a best-effort local detection for text inputs.
If you see wrong-language behavior, pick the source_language explicitly.
For images, source_language=Auto Detect is not supported (no OCR pre-pass). Select the correct source_language.
For image translation, the node supports multiple preprocessing modes via image_resize_mode:
letterbox (default): preserve aspect ratio (no stretching) by padding, then resizeprocessor: rely on the official Gemma3 image processor resize to 896×896 (may stretch)stretch: force resize to 896×896 (may distort)If small text is missed, try enabling image_enhance=true to apply mild pixel-only enhancement.
Enhancement tuning (experimental):
TRANSLATEGEMMA_IMAGE_ENHANCE_MODE: gentle (default) or legacyTRANSLATEGEMMA_IMAGE_ENHANCE_CONTRAST: contrast factor (default 1.10)TRANSLATEGEMMA_IMAGE_ENHANCE_SHARPNESS: sharpness factor (default 1.10)TRANSLATEGEMMA_AUTO_MAX_NEW_TOKENS_MAX: optional hard cap for max_new_tokens=0 (Auto) to limit long-form outputs. If unset, Auto is only limited by context budget + other safeguards.When debug=true, the node prints a redacted filename for the preprocessed temporary PNG and keeps it for inspection. Set TRANSLATEGEMMA_VERBOSE_DEBUG=1 only when an exact path is required for local troubleshooting.
Additionally, when debug=true, the node saves intermediate images under debug/:
resize_mode + enhance_mode prefixed filesNote: For image translation, max_input_tokens values that are too small can truncate the model’s visual tokens and cause unrelated outputs. The node enforces a safe minimum when truncation is enabled.
For better Traditional Chinese output consistency, the node maps:
zhzh-HantWhen source_language=Auto Detect, the node will try to distinguish Simplified vs Traditional Chinese:
zh_TW/zh_HK/zh_MO -> zh_Hant, zh_CN/zh_SG/zh_MY -> zhzh_Hant only when the signal is strongIf the text is too short or ambiguous, Auto Detect may still resolve to zh. For guaranteed behavior, select the desired source_language explicitly.
Tip: If your input is Simplified Chinese but you want Traditional output, set source_language=Auto Detect (or Chinese (Simplified)) and target_language=Chinese (Traditional).
If you still see mixed Simplified/Traditional output when targeting Traditional Chinese, you can enable a best-effort post-edit conversion using OpenCC:
pip install opencc-python-reimplementedtarget_language=Chinese (Traditional) the node will convert Simplified → Traditional if OpenCC is availableTRANSLATEGEMMA_TRADITIONAL_POSTEDIT=0For workflows that only need script conversion (Simplified ↔ Traditional) without translation, enable chinese_conversion_only=true. This mode:
target_language to be a Chinese variant (direction is controlled separately)Direction selector (chinese_conversion_direction):
auto_flip (default): Auto-detect input variant and convert to the opposite script
to_traditional: Force Simplified → Traditional (s2t)to_simplified: Force Traditional → Simplified (t2s)Requirements:
pip install opencc-python-reimplementedLimitations:
image is connected, returns an error (use normal translation mode for images)auto_flip may fail on short/ambiguous inputs; use forced direction in those casesWhen to use:
For long texts, the model may stop early (emitting <end_of_turn>) before completing the translation. The long_text_strategy option provides two approaches:
disable (default): Standard single-call behavior. Suitable for most inputs.
auto-continue (also accepts auto_continue): Best-effort continuation when the model stops early on long input.
<end_of_turn>, and input was not truncated.segmented: Translate paragraph-by-paragraph.
When to use:
| Scenario | Recommended |
|---|---|
| Short/medium text (<2000 chars) | disable |
| Long text that sometimes truncates early | auto-continue |
| Very long document with many paragraphs | segmented |
| Speed is critical | disable |
Recommended settings for long documents:
max_input_tokens=0 and max_new_tokens=0 (Auto) so the node stays context-aware.long_text_strategy=auto-continue.long_text_strategy=segmented (more robust, but slower).Limitations:
segmented mode has higher latency for many-paragraph documents.auto-continue continuation quality depends on model; may occasionally repeat or diverge.The node accepts both _ and - variants for language codes (e.g., zh_Hant and zh-Hant). Internally, codes are normalized to match the official TranslateGemma template format.
If an unsupported language is passed, the node prints a warning and defaults to English. Set TRANSLATEGEMMA_STRICT_LANG=1 to raise an error instead.
The following are the authoritative default values for node inputs:
| Setting | Default | Notes |
|---|---|---|
model_size | 4B | Smallest, fastest |
device | default | Use ComfyUI's active device |
max_new_tokens | 512 | Use 0 for auto-sizing |
max_input_tokens | 2048 | Input truncation limit (0 = Auto) |
keep_model_loaded | true | Avoids reload overhead |
truncate_input | true | Prevents OOM on long texts |
debug | false | Enable for diagnostics |
image_resize_mode | letterbox | Preserves aspect ratio |
image_enhance | false | Enables contrast/sharpening |
image_two_pass | true | Extract then translate |
chinese_conversion_only | false | OpenCC conversion without model |
chinese_conversion_direction | auto_flip | Auto-detect and flip variant |
long_text_strategy | disable | Single-call (no continuation) |
quantization | none | No quantization (full precision) |
keep_model_loaded=true for repeated use (avoids reload time).keep_model_loaded=false when memory release after each run is more important than reload latency.Best-effort VRAM reduction for running larger models (12B/27B) on consumer GPUs.
The quantization input allows you to load the model in lower precision using bitsandbytes:
| Mode | VRAM Reduction | Quality | Notes |
|---|---|---|---|
none (default) | — | Best | Full precision (BF16/FP16) |
bnb-8bit | ~50% | Good | 8-bit quantization |
bnb-4bit | ~75% | Acceptable | 4-bit NF4 quantization |
bitsandbytes>=0.49.2 into the Python environment already used by ComfyUI: python -m pip install -r requirements-quantization.txt.pyproject.toml.bitsandbytes is intentionally absent from base requirements.txt. Base installs and quantization=none do not import or require it.
Official upstream packages currently describe NVIDIA CUDA, AMD ROCm, Intel XPU, Intel HPU/Gaudi, CPU, and Apple Silicon/MPS paths. That upstream availability is not the same as project support. This release keeps TranslateGemma's BnB integration on the existing CUDA-only, best-effort path. ROCm, XPU, HPU, CPU, and MPS model loading remain deferred until this project has device-map, load, and inference evidence for each backend. Official Windows x86-64 wheels include CUDA 13.0 builds, but this repository's package-only check does not prove a real TranslateGemma GPU run.
"TranslateGemma bitsandbytes mode ... only for this project's CUDA device path":
quantization=none or select a CUDA device already supported by the active ComfyUI environment."bitsandbytes not installed":
python -m pip install -r requirements-quantization.txt or python -m pip install "bitsandbytes>=0.49.2".quantization=none or the 4B model."BitsAndBytesConfig not found":
"CUDA Setup failed" or "libbitsandbytes_cudaXXX not found" (import succeeds but loading fails):
quantization=none as a workaroundTRANSLATEGEMMA_BNB_4BIT_COMPUTE_DTYPE: Force compute dtype for 4-bit (bf16 or fp16). Default: auto-detect.TRANSLATEGEMMA_BNB_4BIT_DOUBLE_QUANT: Enable double quantization (1 = enabled, 0 = disabled). Default: 1.trust_remote_code=False and retries only when Transformers explicitly reports that repository custom code is required.TRANSLATEGEMMA_ALLOW_REMOTE_CODE=1 only after reviewing the repository code.TRANSLATEGEMMA_REMOTE_CODE_ALLOWLIST=google/translategemma-4b-it,google/translategemma-12b-it to require an exact repository match in addition to the explicit opt-in.TRANSLATEGEMMA_ALLOW_UNSAFE_WEIGHTS=1 as a separate explicit opt-in.TRANSLATEGEMMA_REVISION=<commit-hash>, especially whenever remote code or non-safetensors weights are enabled.debug=true redacts sensitive data (user text content, full filesystem paths).TRANSLATEGEMMA_VERBOSE_DEBUG=1 to enable full diagnostics (for troubleshooting).ComfyUI/models/LLM/TranslateGemma/ and retry.This repository is licensed under the MIT License (see LICENSE). TranslateGemma model weights are governed by Google's Gemma Terms of Use.
42 commits
Python
90.5%
JavaScript
9.5%