Nodes/tdxh_node_comfyui/TdxhStringInputTranslator
ComfyUI Node

TdxhStringInputTranslator

Translate your prompt to English offline, on your own GPU

By youyegit·Created 3 years ago·Updated 5 months ago· 2
TdxhStringInputTranslator
    • STRING
    string_valuemoon
    bool_int1
    input_language

    This is the one node in the pack that needs a real model download, and it's the reason sentencepiece is in the requirements. TdxhStringInputTranslator is an offline prompt translator: you type a prompt in Chinese (or any of ~50 languages), pick the source language in the input_language dropdown, and get English out as a STRING you can wire straight into a CLIP Text Encode node. No cloud calls, no API key - it runs Facebook's mbart-large-50-many-to-many-mmt on your own machine, with the translator code lifted from ParisNeo's prompt_translator project (the pack credits it).

    How it works: when bool_int is 1, the node loads MBART from a model/ folder inside the pack directory, translates string_value to English, and returns the translated text. When bool_int is 0, it passes your original text through untouched - and importantly, the model isn't loaded at all on that path. So you can keep the node in a workflow permanently, disabled, without paying a multi-gigabyte load on every run. That's a thoughtful design for an SD-era personal pack.

    The install is the fiddly part. The model is NOT downloaded automatically. Grab the files from https://huggingface.co/facebook/mbart-large-50-many-to-many-mmt and place them inside the pack's model/ subfolder, under the name the code expects:

    model/
    └── mbart-large-50-many-to-many-mmt__only_to_English/
        ├── pytorch_model.bin
        ├── config.json
        ├── sentencepiece.bpe.model
        ├── special_tokens_map.json
        └── tokenizer_config.json
    

    Then make sure the environment has sentencepiece (the pack's requirements.txt installs it) and transformers (ComfyUI ships it). That's roughly 2.5 GB of weights, and the first translation is slow - MBART is a full seq2seq model, not a toy, so it eats a few GB of RAM while loaded.

    Where people get burned: if the model/ folder is missing and bool_int is 1, the node throws an unfriendly traceback. And note the dropdown has a couple of duplicated language entries (हिन्दी and 한국어 appear twice) - a cosmetic wart, both map to the same code. Also, it's many-to-one: everything translates to English. If you want English-to-Chinese, this isn't the node.

    Installing it

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

    (Or ComfyUI Manager → search tdxh_node_comfyui.) Then do the Hugging Face model download above and restart.

    The honest take

    If you can use an online translator or just write prompts in English, that's faster and lighter. This node is for the offline case: you think in Chinese, you want English prompts for better CLIP semantics, and you'd rather not hit a third-party API. It's a niche within a niche pack - but it's the pack's most distinctive piece, and the offline angle genuinely matters if you're on a closed network or privacy-sensitive.

    CategoryTDXH/tdxh_data

    Inputs (3)

    NameTypeDefaultDescription
    string_valueSTRINGmoon
    bool_intINT10–1
    input_languageCOMBO52 options: 中文, عربية, Deutsch, Español, Français, हिन्दी, +46

    Outputs (1)

    NameTypeDescription
    STRINGSTRING