Nodes/ComfyUI_HF_Inference/HF Text Translation
ComfyUI Node

HF Text Translation

Machine-translate a prompt mid-workflow, no local model, no GPU

By bitaffinity·Created 2 years ago·Updated 2 years ago· 5
HF Text Translation
    • STRING
    endpoint
    text

    The dullest node in the pack is also the one most likely to actually get used. HF Text Translation does one thing - send a string to a Hugging Face translation model and hand the translated string back - and it does it with exactly two inputs. It's from the bitaffinity/ComfyUI_HF_Inference pack, so the model runs on Hugging Face's servers: no weights on disk, no VRAM, no translation-model hunting.

    What it does

    • endpoint (STRING) - the model ID, like google-t5/t5-base (the README's pick), or a full URL.
    • text (STRING, multiline) - what you want translated.

    The node POSTs {"inputs": text} to https://api-inference.huggingface.co/models/{endpoint}, and the server returns the translation, which comes out the STRING socket.

    The obvious move is prompt engineering: write your prompts in your best language, run them through this node, and feed the translated result into a CLIPTextEncode. If your checkpoint behaves better with English or Japanese or French prompts, this lets you keep authoring in one language and serving another. It's also handy for localizing captions or labels that already live in your workflow - the STRING output wires straight into a save or display node.

    The T5 gotcha nobody mentions

    The README's suggested model, google-t5/t5-base, is a text-to-text model, not a dedicated translation model with a language pair baked in. With many T5-based checkpoints you still have to tell it what to do inside the input text - something like translate English to French: A cat on a windowsill. If you feed it bare text, you might get the input echoed back, or a random target language, because the model never learned which language you wanted. If your translation comes back looking like a typo, that prefix is the first thing to check. Other translation endpoints on the Hub may take plain text - the node itself doesn't care, it just forwards the string.

    Installing it

    Same as every node in the pack, and it's one of the lightest installs in the ecosystem - the only Python dependency is requests:

    git clone https://github.com/bitaffinity/ComfyUI_HF_Inference custom_nodes/ComfyUI_HF_Inference
    cd custom_nodes/ComfyUI_HF_Inference
    pip install -r requirements.txt
    

    Restart ComfyUI (or search "ComfyUI_HF_Inference" in ComfyUI Manager), then set a Hugging Face token - free tier is fine - as an environment variable:

    HF_AUTH_TOKEN=hf_yourtokenhere python main.py
    

    The cloud caveats, in brief

    You're on Hugging Face's serverless tier, which the README openly warns only supports models 10GB and under and "fails for random reasons on different models." T5-base is comfortably under that line, so this is the safest node in the pack to actually lean on. Cold starts are the realistic annoyance - the first call to an unloaded model can sit for a minute or two while HF boots a container, and the pack waits out the reported estimated_time and retries once before giving up. After the first call it's usually fast. For a node whose entire job is "translate a string," that reliability is the whole ballgame.

    CategoryHF_Inference/Text

    Inputs (2)

    NameTypeDefaultDescription
    endpointSTRING
    textSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING