43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
"""ComfyUI-HyMT2 — Tencent Hy-MT2 translation nodes for ComfyUI.
|
|
|
|
Hy-MT2 is Tencent's multilingual translation model family supporting 38 languages.
|
|
This pack wraps the 1.8B / 7B / 30B-A3B variants as ComfyUI nodes.
|
|
"""
|
|
import os as _os
|
|
import sys as _sys
|
|
|
|
__version__ = "0.1.2"
|
|
|
|
# Self-verification banner (v2.0 §4: same banner pattern, stdout + stderr, flush=True)
|
|
_banner = f"[ComfyUI-HyMT2] v{__version__} loaded from {_os.path.abspath(__file__)}"
|
|
print(_banner, flush=True)
|
|
print(_banner, file=_sys.stderr, flush=True)
|
|
|
|
# Defensive imports — if torch / transformers / accelerate are missing (e.g. in a
|
|
# pure test environment, or before scripts/install_deps.sh has been run), we
|
|
# don't want to take down ComfyUI's whole startup. We just expose empty
|
|
# mappings and log the reason. The banner still appears so the user knows the
|
|
# pack was found.
|
|
try:
|
|
from .nodes.loader import HyMT2Loader
|
|
from .nodes.translate import HyMT2Translate
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
"HyMT2Loader": HyMT2Loader,
|
|
"HyMT2Translate": HyMT2Translate,
|
|
}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"HyMT2Loader": "Hy-MT2 Loader",
|
|
"HyMT2Translate": "Hy-MT2 Translate",
|
|
}
|
|
except ImportError as _e:
|
|
_warn = (f"[ComfyUI-HyMT2] WARNING: failed to import nodes — {_e!r}\n"
|
|
f"[ComfyUI-HyMT2] The pack is loaded but nodes are NOT registered.\n"
|
|
f"[ComfyUI-HyMT2] Run scripts/install_deps.sh, then restart ComfyUI.")
|
|
print(_warn, flush=True)
|
|
print(_warn, file=_sys.stderr, flush=True)
|
|
NODE_CLASS_MAPPINGS = {}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "__version__"]
|