Files
2024-11-24 16:21:12 +08:00

66 lines
2.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import importlib.util
import subprocess
import os
import re
def install_package(full_name, package_name):
try:
spec = importlib.util.find_spec(package_name)
if spec is None:
raise ImportError(f"{package_name} 未安装")
except ImportError:
print(f"{package_name} 未安装,正在安装...")
subprocess.check_call(["python", "-m", "pip", "install", full_name])
print(f"{package_name} 安装完成。")
def check_and_install_packages():
packages = ["pygtrans", "fake_useragent", "lxml", "openai"]
for package in packages:
package_name = re.match(r"^([^\s=<>!]+)", package.strip())
if package_name:
install_package(package, package_name.group(1))
# 检查 requirements.txt 文件中的包
check_and_install_packages()
from .nodes.Translate import TranslateNode
from .nodes.JoyTag.JoyTag import JoyTagNode
from .nodes.JoyCaption.JoyCaption import JoyCaptionNode
from .nodes.JoyCaption.JoyCaption import (
JoyCaptionAlpha2OnlineNode,
JoyCaptionAlpha1OnlineNode,
)
from .nodes.civitai_prompt import CivitaiPromptNode
from .nodes.image_tools import CustomLatentImageNode, CustomLatentImageSimpleNode
from .nodes.number_tools import FloatSliderNode
NODE_CLASS_MAPPINGS = {
"Translate": TranslateNode,
"JoyTag": JoyTagNode,
"JoyCaption": JoyCaptionNode,
"JoyCaptionAlpha2Online": JoyCaptionAlpha2OnlineNode,
"JoyCaptionAlpha1Online": JoyCaptionAlpha1OnlineNode,
"CivitaiPrompt": CivitaiPromptNode,
"CustomLatentImage-NYJY": CustomLatentImageNode,
"CustomLatentImageSimple": CustomLatentImageSimpleNode,
"FloatSlider-NYJY": FloatSliderNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Translate": "Translate (NYJY)",
"JoyTag": "JoyTag (NYJY)",
"JoyCaption": "JoyCaption (NYJY)",
"JoyCaptionAlpha2Online": "JoyCaptionAlpha2Online (NYJY)",
"JoyCaptionAlpha1Online": "JoyCaptionAlphaOneOnline (NYJY)",
"CivitaiPrompt": "CivitaiPrompt(NYJY)",
"CustomLatentImage-NYJY": "CustomLatentImage(NYJY)",
"CustomLatentImageSimple": "CustomLatentImageSimple(NYJY)",
"FloatSlider-NYJY": "FloatSlider(NYJY)",
}
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]