feat: add Video Prompt Helper node (English name), MIT info, and config files
This commit is contained in:
+12
@@ -539,6 +539,16 @@ except ImportError as e:
|
||||
KONTEXT_PRESETS_MAPPINGS = {}
|
||||
KONTEXT_PRESETS_DISPLAY_MAPPINGS = {}
|
||||
|
||||
try:
|
||||
from .nodes.tools.prompt_helper import \
|
||||
NODE_CLASS_MAPPINGS as PROMPT_HELPER_MAPPINGS
|
||||
from .nodes.tools.prompt_helper import \
|
||||
NODE_DISPLAY_NAME_MAPPINGS as PROMPT_HELPER_DISPLAY_MAPPINGS
|
||||
except ImportError as e:
|
||||
print(f"导入错误: {e}")
|
||||
PROMPT_HELPER_MAPPINGS = {}
|
||||
PROMPT_HELPER_DISPLAY_MAPPINGS = {}
|
||||
|
||||
# 合并所有节点映射
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_CLASS_MAPPINGS.update(EMPTY_UNIT_MAPPINGS)
|
||||
@@ -568,6 +578,7 @@ NODE_CLASS_MAPPINGS.update(MATH_EXPRESSION_MAPPINGS)
|
||||
NODE_CLASS_MAPPINGS.update(THINK_REMOVER_MAPPINGS)
|
||||
NODE_CLASS_MAPPINGS.update(LORA_INFO_MAPPINGS)
|
||||
NODE_CLASS_MAPPINGS.update(KONTEXT_PRESETS_MAPPINGS)
|
||||
NODE_CLASS_MAPPINGS.update(PROMPT_HELPER_MAPPINGS)
|
||||
|
||||
# 合并显示名称映射
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
@@ -598,6 +609,7 @@ NODE_DISPLAY_NAME_MAPPINGS.update(MATH_EXPRESSION_DISPLAY_MAPPINGS)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(THINK_REMOVER_DISPLAY_MAPPINGS)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(LORA_INFO_DISPLAY_MAPPINGS)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(KONTEXT_PRESETS_DISPLAY_MAPPINGS)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(PROMPT_HELPER_DISPLAY_MAPPINGS)
|
||||
|
||||
NODE_CATEGORIES = {
|
||||
"UniversalToolkit": [
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# 视频提示词生成器 (Video Prompt Generator)
|
||||
|
||||
## 简介
|
||||
|
||||
视频提示词生成器是一个专为 ComfyUI 设计的自定义节点插件,提供强大的视频提示词生成功能。该插件支持中英文双语界面,帮助用户快速构建专业的电影化提示词。
|
||||
|
||||
## 原作者信息
|
||||
|
||||
- **原作者**: flybirdxx
|
||||
- **项目地址**: https://github.com/flybirdxx/ComfyUI_Prompt_Helper
|
||||
- **许可证**: MIT License
|
||||
|
||||
## 功能特点
|
||||
|
||||
* 🎬 **专业电影化提示词生成** - 构建高质量的视频生成提示词
|
||||
* 🌐 **双语支持** - 自动检测系统语言,支持中文和英文界面
|
||||
* 📋 **14个专业分类** - 覆盖电影制作的各个方面
|
||||
* 🎯 **三种格式输出** - 专业、简单、详细三种提示词格式
|
||||
* 🔧 **高度可定制** - 丰富的配置选项和预设
|
||||
* 📚 **内置示例** - 包含多个使用示例和最佳实践
|
||||
|
||||
## 分类选项
|
||||
|
||||
插件提供以下14个专业分类:
|
||||
|
||||
1. **镜头大小 / Shot Size** - 全景、中景、特写等
|
||||
2. **灯光类型 / Lighting Type** - 自然光、戏剧化灯光、柔光等
|
||||
3. **光源 / Light Source** - 阳光、月光、火光等
|
||||
4. **色调 / Color Tone** - 暖色调、冷色调、高对比度等
|
||||
5. **摄像机角度 / Camera Angle** - 平视、仰视、俯视等
|
||||
6. **镜头 / Lens** - 广角、人像、长焦等
|
||||
7. **基础摄像机运动 / Basic Camera Movement** - 静态、平移、缩放等
|
||||
8. **高级摄像机运动 / Advanced Camera Movement** - 推轨、斯坦尼康、航拍等
|
||||
9. **时间 / Time of Day** - 黎明、黄昏、夜晚等
|
||||
10. **运动 / Motion** - 慢动作、快动作、正常速度等
|
||||
11. **视觉效果 / Visual Effects** - 镜头光晕、雨滴、雾气等
|
||||
12. **视觉风格 / Visual Style** - 电影风格、纪录片、动作等
|
||||
13. **角色情感 / Character Emotion** - 开心、悲伤、紧张等
|
||||
14. **构图 / Composition** - 三分法、对称、非对称等
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. **启动 ComfyUI** - 插件会自动加载并检测系统语言
|
||||
2. **添加节点** - 在节点菜单中找到 "🎬 视频提示词生成器" 或 "🎬 Video Prompt Generator"
|
||||
3. **配置参数** - 从各个分类中选择所需的选项
|
||||
4. **生成提示词** - 插件会自动组合生成专业的提示词
|
||||
|
||||
### 示例工作流
|
||||
|
||||
```
|
||||
用户输入: "一个战士在战场上奔跑"
|
||||
配置选项:
|
||||
- 镜头大小: 中景
|
||||
- 灯光类型: 戏剧化灯光
|
||||
- 色调: 高对比度
|
||||
- 摄像机角度: 仰视角度
|
||||
- 提示词格式: 专业
|
||||
|
||||
输出结果: "一个战士在战场上奔跑,中景,戏剧化灯光,高对比度,仰视角度,专业电影质量,高细节,4K分辨率"
|
||||
```
|
||||
|
||||
## 文件结构
|
||||
|
||||
```
|
||||
nodes/tools/
|
||||
├── prompt_helper.py # 主要功能代码
|
||||
├── prompt_presets.json # 预设配置文件
|
||||
├── prompt_ui_labels.json # 界面标签文件
|
||||
└── README_prompt_helper.md # 说明文档
|
||||
```
|
||||
|
||||
## 配置文件
|
||||
|
||||
* **prompt_presets.json** - 包含所有分类的预设选项
|
||||
* **prompt_ui_labels.json** - 定义界面标签的多语言文本
|
||||
|
||||
## 自定义配置
|
||||
|
||||
您可以通过编辑 JSON 配置文件来自定义选项:
|
||||
|
||||
1. 编辑 `prompt_presets.json` 添加新的预设选项
|
||||
2. 修改 `prompt_ui_labels.json` 更新界面文本
|
||||
|
||||
## 兼容性
|
||||
|
||||
* **ComfyUI** - 支持最新版本的 ComfyUI
|
||||
* **Python** - 需要 Python 3.7+
|
||||
* **操作系统** - 支持 Windows、macOS、Linux
|
||||
|
||||
## 许可证
|
||||
|
||||
本项目采用 MIT 许可证 - 详见 LICENSE 文件
|
||||
|
||||
## 致谢
|
||||
|
||||
* 感谢 flybirdxx 提供的优秀视频提示词生成工具
|
||||
* 感谢 ComfyUI 提供的优秀平台
|
||||
|
||||
---
|
||||
|
||||
## 更新日志
|
||||
|
||||
### v1.0.0 (集成版本)
|
||||
|
||||
* 初始集成到 ComfyUI-UniversalToolkit
|
||||
* 支持14个专业分类
|
||||
* 双语界面支持
|
||||
* 三种提示词格式
|
||||
* 保持原作者信息和 MIT 协议
|
||||
@@ -0,0 +1,364 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
视频提示词生成器 ComfyUI 自定义节点 (双语版本)
|
||||
Video Prompt Generator ComfyUI Custom Node (Bilingual Version)
|
||||
|
||||
原作者 / Original Author: flybirdxx
|
||||
项目地址 / Project URL: https://github.com/flybirdxx/ComfyUI_Prompt_Helper
|
||||
许可证 / License: MIT License
|
||||
|
||||
基于 Denge AI 的视频提示词生成工具创建
|
||||
支持中文和英文两种语言
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import locale
|
||||
|
||||
# 获取当前文件所在的目录路径
|
||||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 检测系统语言
|
||||
def detect_system_language():
|
||||
"""检测系统语言并返回支持的语言代码"""
|
||||
try:
|
||||
# 获取系统语言设置
|
||||
system_locale = locale.getdefaultlocale()[0]
|
||||
if system_locale:
|
||||
# 如果是中文相关的locale,返回zh
|
||||
if system_locale.startswith('zh'):
|
||||
return 'zh'
|
||||
# 其他情况返回英文
|
||||
else:
|
||||
return 'en'
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
# 默认返回中文
|
||||
return 'zh'
|
||||
|
||||
# 获取系统默认语言
|
||||
DEFAULT_LANGUAGE = detect_system_language()
|
||||
|
||||
# 构建 JSON 文件的完整路径
|
||||
PRESETS_FILE_PATH = os.path.join(CURRENT_DIR, 'prompt_presets.json')
|
||||
UI_LABELS_FILE_PATH = os.path.join(CURRENT_DIR, 'prompt_ui_labels.json')
|
||||
|
||||
# 从 JSON 文件加载预设数据
|
||||
def load_video_presets():
|
||||
try:
|
||||
with open(PRESETS_FILE_PATH, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
print(f"Error loading prompt_presets.json: {e}")
|
||||
return {}
|
||||
|
||||
# 从 JSON 文件加载UI标签
|
||||
def load_ui_labels():
|
||||
try:
|
||||
with open(UI_LABELS_FILE_PATH, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
print(f"Error loading prompt_ui_labels.json: {e}")
|
||||
# 返回基本的英文标签作为回退
|
||||
return {
|
||||
"zh": {"language": "语言", "default_prompt": "一个美丽的场景"},
|
||||
"en": {"language": "Language", "default_prompt": "A beautiful scene"},
|
||||
"messages": {"zh": {}, "en": {}},
|
||||
"display_names": {"zh": "视频提示词生成器", "en": "Video Prompt Generator"}
|
||||
}
|
||||
|
||||
# 加载预设数据和UI标签
|
||||
VIDEO_PRESETS = load_video_presets()
|
||||
UI_LABELS_DATA = load_ui_labels()
|
||||
UI_LABELS = UI_LABELS_DATA # 保持向后兼容
|
||||
|
||||
class WanVideoPromptGenerator:
|
||||
"""
|
||||
视频提示词生成器节点(双语版本)
|
||||
Video Prompt Generator Node (Bilingual Version)
|
||||
|
||||
允许用户从14个不同的电影分类中选择选项来构建专业的电影化提示词
|
||||
Allows users to build professional cinematic prompts by selecting from 14 different film categories
|
||||
|
||||
原作者 / Original Author: flybirdxx
|
||||
项目地址 / Project URL: https://github.com/flybirdxx/ComfyUI_Prompt_Helper
|
||||
许可证 / License: MIT License
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
"""定义输入类型"""
|
||||
|
||||
# 为每个分类创建选项列表,添加 "none" 选项在前面
|
||||
def get_options(category, language=DEFAULT_LANGUAGE):
|
||||
if language in VIDEO_PRESETS and category in VIDEO_PRESETS[language]:
|
||||
# 获取本地化的显示文本,而不是键名
|
||||
category_data = VIDEO_PRESETS[language][category]
|
||||
options = []
|
||||
|
||||
# 先添加 "none" 选项,显示为本地化的文本
|
||||
if "none" in category_data:
|
||||
none_text = UI_LABELS_DATA[language].get("none_option", "none")
|
||||
options.append(none_text)
|
||||
|
||||
# 添加其他选项的本地化文本
|
||||
for key, value in category_data.items():
|
||||
if key != "none" and value: # 跳过none和空值
|
||||
options.append(value)
|
||||
|
||||
return options
|
||||
none_text = UI_LABELS_DATA[language].get("none_option", "none")
|
||||
return [none_text]
|
||||
|
||||
# 根据默认语言设置默认提示词和属性名称
|
||||
default_prompt = UI_LABELS[DEFAULT_LANGUAGE]["default_prompt"]
|
||||
labels = UI_LABELS[DEFAULT_LANGUAGE]
|
||||
|
||||
# 本地化的属性名称映射
|
||||
return {
|
||||
"required": {
|
||||
labels["language"]: (["zh", "en"], {"default": DEFAULT_LANGUAGE}),
|
||||
labels["user_prompt"]: ("STRING", {
|
||||
"multiline": True,
|
||||
"default": default_prompt
|
||||
}),
|
||||
labels["shot_size"]: (get_options("shot_size"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["lighting_type"]: (get_options("lighting_type"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["light_source"]: (get_options("light_source"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["color_tone"]: (get_options("color_tone"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["camera_angle"]: (get_options("camera_angle"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["lens"]: (get_options("lens"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["camera_movement_basic"]: (get_options("camera_movement_basic"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["camera_movement_advanced"]: (get_options("camera_movement_advanced"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["time_of_day"]: (get_options("time_of_day"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["motion"]: (get_options("motion"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["visual_effects"]: (get_options("visual_effects"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["stylization_visual_style"]: (get_options("stylization_visual_style"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["character_emotion"]: (get_options("character_emotion"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["composition"]: (get_options("composition"), {"default": UI_LABELS_DATA[DEFAULT_LANGUAGE].get("none_option", "none")}),
|
||||
labels["prompt_format"]: ([
|
||||
labels["format_professional"],
|
||||
labels["format_simple"],
|
||||
labels["format_detailed"]
|
||||
], {"default": labels["format_professional"]})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("generated_prompt",)
|
||||
FUNCTION = "generate_video_prompt"
|
||||
CATEGORY = "UniversalToolkit/Tools"
|
||||
|
||||
def generate_video_prompt(self, **kwargs):
|
||||
"""生成视频提示词"""
|
||||
|
||||
# 创建参数映射以支持本地化的参数名称
|
||||
# 将本地化的参数名映射回英文键名
|
||||
param_mapping = {}
|
||||
for lang_code in ["zh", "en"]:
|
||||
labels = UI_LABELS[lang_code]
|
||||
for en_key, localized_name in labels.items():
|
||||
if en_key in ["language", "user_prompt", "shot_size", "lighting_type", "light_source",
|
||||
"color_tone", "camera_angle", "lens", "camera_movement_basic",
|
||||
"camera_movement_advanced", "time_of_day", "motion", "visual_effects",
|
||||
"stylization_visual_style", "character_emotion", "composition", "prompt_format"]:
|
||||
param_mapping[localized_name] = en_key
|
||||
|
||||
# 创建选项值的反向映射(本地化文本 -> 键名)
|
||||
def create_value_to_key_mapping(language):
|
||||
value_to_key = {}
|
||||
if language in VIDEO_PRESETS:
|
||||
for category, items in VIDEO_PRESETS[language].items():
|
||||
for key, value in items.items():
|
||||
if value: # 只映射非空值
|
||||
value_to_key[value] = key
|
||||
# 处理"无"选项
|
||||
none_text = UI_LABELS_DATA[language].get("none_option", "none")
|
||||
value_to_key[none_text] = "none"
|
||||
|
||||
# 处理prompt_format选项的映射
|
||||
labels = UI_LABELS[language]
|
||||
value_to_key[labels["format_professional"]] = "professional"
|
||||
value_to_key[labels["format_simple"]] = "simple"
|
||||
value_to_key[labels["format_detailed"]] = "detailed"
|
||||
return value_to_key
|
||||
|
||||
# 将本地化参数名和值映射为英文参数名和键名
|
||||
params = {}
|
||||
for key, value in kwargs.items():
|
||||
mapped_key = param_mapping.get(key, key)
|
||||
params[mapped_key] = value
|
||||
|
||||
# 提取参数
|
||||
language = params.get("language", DEFAULT_LANGUAGE)
|
||||
|
||||
# 创建当前语言的值到键的映射
|
||||
value_to_key = create_value_to_key_mapping(language)
|
||||
|
||||
# 提取并转换参数值
|
||||
user_prompt = params.get("user_prompt", UI_LABELS[language]["default_prompt"])
|
||||
|
||||
# 对于选项类型的参数,需要将本地化文本转换回键名
|
||||
def convert_value_to_key(value, default="none"):
|
||||
if not value:
|
||||
return default
|
||||
return value_to_key.get(value, value)
|
||||
|
||||
shot_size = convert_value_to_key(params.get("shot_size"))
|
||||
lighting_type = convert_value_to_key(params.get("lighting_type"))
|
||||
light_source = convert_value_to_key(params.get("light_source"))
|
||||
color_tone = convert_value_to_key(params.get("color_tone"))
|
||||
camera_angle = convert_value_to_key(params.get("camera_angle"))
|
||||
lens = convert_value_to_key(params.get("lens"))
|
||||
camera_movement_basic = convert_value_to_key(params.get("camera_movement_basic"))
|
||||
camera_movement_advanced = convert_value_to_key(params.get("camera_movement_advanced"))
|
||||
time_of_day = convert_value_to_key(params.get("time_of_day"))
|
||||
motion = convert_value_to_key(params.get("motion"))
|
||||
visual_effects = convert_value_to_key(params.get("visual_effects"))
|
||||
stylization_visual_style = convert_value_to_key(params.get("stylization_visual_style"))
|
||||
character_emotion = convert_value_to_key(params.get("character_emotion"))
|
||||
composition = convert_value_to_key(params.get("composition"))
|
||||
prompt_format = convert_value_to_key(params.get("prompt_format"), "professional")
|
||||
|
||||
# 验证语言参数
|
||||
if language not in VIDEO_PRESETS:
|
||||
messages = UI_LABELS_DATA.get("messages", {}).get(DEFAULT_LANGUAGE, {})
|
||||
unsupported_msg = messages.get("unsupported_language", "Unsupported language")
|
||||
fallback_msg = messages.get("fallback_to_default", ", fallback to default language")
|
||||
print(f"[VideoPromptGenerator] {unsupported_msg}: {language}{fallback_msg}: {DEFAULT_LANGUAGE}")
|
||||
language = DEFAULT_LANGUAGE
|
||||
|
||||
# 获取当前语言的预设数据
|
||||
current_presets = VIDEO_PRESETS[language]
|
||||
current_labels = UI_LABELS[language]
|
||||
|
||||
# 收集所有选择的元素
|
||||
selected_elements = []
|
||||
|
||||
# 定义参数映射
|
||||
category_params = {
|
||||
"shot_size": shot_size,
|
||||
"lighting_type": lighting_type,
|
||||
"light_source": light_source,
|
||||
"color_tone": color_tone,
|
||||
"camera_angle": camera_angle,
|
||||
"lens": lens,
|
||||
"camera_movement_basic": camera_movement_basic,
|
||||
"camera_movement_advanced": camera_movement_advanced,
|
||||
"time_of_day": time_of_day,
|
||||
"motion": motion,
|
||||
"visual_effects": visual_effects,
|
||||
"stylization_visual_style": stylization_visual_style,
|
||||
"character_emotion": character_emotion,
|
||||
"composition": composition
|
||||
}
|
||||
|
||||
# 提取选中的非空元素
|
||||
for category, value in category_params.items():
|
||||
if value != "none" and category in current_presets and value in current_presets[category]:
|
||||
element_text = current_presets[category][value]
|
||||
if element_text: # 确保元素文本不为空
|
||||
selected_elements.append(element_text)
|
||||
|
||||
# 根据格式生成提示词
|
||||
if prompt_format == "professional":
|
||||
if selected_elements:
|
||||
cinematic_elements = ",".join(selected_elements) if language == "zh" else ", ".join(selected_elements)
|
||||
separator = "," if language == "zh" else ", "
|
||||
generated_prompt = f"{user_prompt}{separator}{cinematic_elements}{current_labels['professional_suffix']}"
|
||||
else:
|
||||
generated_prompt = f"{user_prompt}{current_labels['professional_suffix']}"
|
||||
|
||||
elif prompt_format == "detailed":
|
||||
if selected_elements:
|
||||
# 按类别组织元素
|
||||
shot_elements = []
|
||||
lighting_elements = []
|
||||
camera_elements = []
|
||||
style_elements = []
|
||||
|
||||
# 分类整理元素
|
||||
shot_categories = ["shot_size", "camera_angle", "composition"]
|
||||
lighting_categories = ["lighting_type", "light_source", "color_tone", "time_of_day"]
|
||||
camera_categories = ["lens", "camera_movement_basic", "camera_movement_advanced", "motion"]
|
||||
style_categories = ["visual_effects", "stylization_visual_style", "character_emotion"]
|
||||
|
||||
for category, value in category_params.items():
|
||||
if value != "none" and category in current_presets and value in current_presets[category]:
|
||||
element_text = current_presets[category][value]
|
||||
if element_text:
|
||||
if category in shot_categories:
|
||||
shot_elements.append(element_text)
|
||||
elif category in lighting_categories:
|
||||
lighting_elements.append(element_text)
|
||||
elif category in camera_categories:
|
||||
camera_elements.append(element_text)
|
||||
elif category in style_categories:
|
||||
style_elements.append(element_text)
|
||||
|
||||
# 构建详细提示词
|
||||
prompt_parts = [user_prompt]
|
||||
separator = "," if language == "zh" else ", "
|
||||
|
||||
if language == "zh":
|
||||
if shot_elements:
|
||||
prompt_parts.append(f"镜头构图:{separator.join(shot_elements)}")
|
||||
if lighting_elements:
|
||||
prompt_parts.append(f"灯光:{separator.join(lighting_elements)}")
|
||||
if camera_elements:
|
||||
prompt_parts.append(f"摄像机工作:{separator.join(camera_elements)}")
|
||||
if style_elements:
|
||||
prompt_parts.append(f"视觉风格:{separator.join(style_elements)}")
|
||||
else:
|
||||
if shot_elements:
|
||||
prompt_parts.append(f"Shot composition: {separator.join(shot_elements)}")
|
||||
if lighting_elements:
|
||||
prompt_parts.append(f"Lighting: {separator.join(lighting_elements)}")
|
||||
if camera_elements:
|
||||
prompt_parts.append(f"Camera work: {separator.join(camera_elements)}")
|
||||
if style_elements:
|
||||
prompt_parts.append(f"Visual style: {separator.join(style_elements)}")
|
||||
|
||||
prompt_parts.append(current_labels['detailed_suffix'].lstrip(". "))
|
||||
connector = "。" if language == "zh" else ". "
|
||||
generated_prompt = connector.join(prompt_parts)
|
||||
else:
|
||||
connector = "。" if language == "zh" else ". "
|
||||
generated_prompt = f"{user_prompt}{connector}{current_labels['detailed_suffix'].lstrip('. ')}"
|
||||
|
||||
else: # simple format
|
||||
if selected_elements:
|
||||
# 选择最重要的几个元素
|
||||
key_elements = selected_elements[:3] # 只取前3个元素
|
||||
separator = "," if language == "zh" else ", "
|
||||
generated_prompt = f"{user_prompt}{separator}{separator.join(key_elements)}"
|
||||
else:
|
||||
generated_prompt = user_prompt
|
||||
|
||||
# 本地化的输出信息
|
||||
messages = UI_LABELS_DATA.get("messages", {}).get(language, {})
|
||||
generated_msg = messages.get("generated_prompt", "Generated prompt with")
|
||||
elements_msg = messages.get("cinematic_elements", "cinematic elements")
|
||||
selected_msg = messages.get("selected_elements", "Selected elements")
|
||||
|
||||
if language == "zh":
|
||||
print(f"视频提示词生成器 ({language}): {generated_msg} {len(selected_elements)} {elements_msg}")
|
||||
else:
|
||||
print(f"VideoPromptGenerator ({language}): {generated_msg} {len(selected_elements)} {elements_msg}")
|
||||
|
||||
if selected_elements:
|
||||
print(f"{selected_msg}: {selected_elements}")
|
||||
|
||||
return (generated_prompt,)
|
||||
|
||||
# ComfyUI 节点注册
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Video_Prompt_Helper": WanVideoPromptGenerator
|
||||
}
|
||||
|
||||
# 节点显示名称的本地化映射
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Video_Prompt_Helper": "Video Prompt Helper"
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
{
|
||||
"zh": {
|
||||
"shot_size": {
|
||||
"none": "",
|
||||
"medium_wide_shot": "中景",
|
||||
"wide_shot": "全景",
|
||||
"medium_shot": "中景",
|
||||
"medium_close_up": "中近景",
|
||||
"extreme_close_up": "大特写",
|
||||
"clean_single_shot": "单人镜头",
|
||||
"two_shot": "双人镜头",
|
||||
"three_shot": "三人镜头",
|
||||
"group_shot": "群体镜头",
|
||||
"close_up_shot": "特写镜头",
|
||||
"long_shot": "远景",
|
||||
"establishing_shot": "建立镜头",
|
||||
"medium_long_shot": "中远景",
|
||||
"extreme_wide_shot": "大远景",
|
||||
"overhead_wide_shot": "俯视全景"
|
||||
},
|
||||
"lighting_type": {
|
||||
"none": "",
|
||||
"natural_light": "自然光",
|
||||
"studio_lighting": "影棚灯光",
|
||||
"soft_lighting": "柔光",
|
||||
"hard_lighting": "硬光",
|
||||
"dramatic_lighting": "戏剧化灯光",
|
||||
"rim_lighting": "轮廓光",
|
||||
"backlighting": "逆光",
|
||||
"side_lighting": "侧光",
|
||||
"top_lighting": "顶光",
|
||||
"bottom_lighting": "底光",
|
||||
"ambient_lighting": "环境光",
|
||||
"practical_lighting": "实用灯光"
|
||||
},
|
||||
"light_source": {
|
||||
"none": "",
|
||||
"sunlight": "阳光",
|
||||
"moonlight": "月光",
|
||||
"candlelight": "烛光",
|
||||
"firelight": "火光",
|
||||
"neon_lights": "霓虹灯",
|
||||
"fluorescent": "荧光灯",
|
||||
"tungsten": "钨丝灯",
|
||||
"led_lights": "LED灯",
|
||||
"street_lights": "路灯",
|
||||
"car_headlights": "车前灯",
|
||||
"spotlight": "聚光灯",
|
||||
"window_light": "窗光"
|
||||
},
|
||||
"color_tone": {
|
||||
"none": "",
|
||||
"warm_tones": "暖色调",
|
||||
"cool_tones": "冷色调",
|
||||
"neutral_tones": "中性色调",
|
||||
"vibrant_colors": "鲜艳色彩",
|
||||
"muted_colors": "柔和色彩",
|
||||
"monochromatic": "单色调",
|
||||
"high_contrast": "高对比度",
|
||||
"low_contrast": "低对比度",
|
||||
"desaturated": "去饱和色彩",
|
||||
"oversaturated": "过饱和色彩",
|
||||
"sepia_tone": "棕褐色调",
|
||||
"blue_tint": "蓝色调"
|
||||
},
|
||||
"camera_angle": {
|
||||
"none": "",
|
||||
"eye_level": "平视角度",
|
||||
"high_angle": "俯视角度",
|
||||
"low_angle": "仰视角度",
|
||||
"birds_eye": "鸟瞰视角",
|
||||
"worms_eye": "虫眼视角",
|
||||
"dutch_angle": "荷兰角度",
|
||||
"over_shoulder": "过肩镜头",
|
||||
"point_of_view": "主观视角",
|
||||
"profile_shot": "侧面镜头",
|
||||
"three_quarter": "四分之三角度",
|
||||
"frontal_shot": "正面镜头",
|
||||
"back_shot": "背面镜头"
|
||||
},
|
||||
"lens": {
|
||||
"none": "",
|
||||
"wide_angle": "广角镜头",
|
||||
"ultra_wide": "超广角镜头",
|
||||
"telephoto": "长焦镜头",
|
||||
"macro": "微距镜头",
|
||||
"fisheye": "鱼眼镜头",
|
||||
"standard_lens": "标准镜头",
|
||||
"portrait_lens": "人像镜头",
|
||||
"zoom_lens": "变焦镜头",
|
||||
"prime_lens": "定焦镜头",
|
||||
"tilt_shift": "移轴镜头",
|
||||
"anamorphic": "变形镜头"
|
||||
},
|
||||
"camera_movement_basic": {
|
||||
"none": "",
|
||||
"static_shot": "静态镜头",
|
||||
"pan_left": "向左摇摆",
|
||||
"pan_right": "向右摇摆",
|
||||
"tilt_up": "向上倾斜",
|
||||
"tilt_down": "向下倾斜",
|
||||
"zoom_in": "推镜",
|
||||
"zoom_out": "拉镜",
|
||||
"dolly_in": "推轨前进",
|
||||
"dolly_out": "推轨后退",
|
||||
"track_left": "向左跟拍",
|
||||
"track_right": "向右跟拍",
|
||||
"track_forward": "向前跟拍",
|
||||
"track_backward": "向后跟拍"
|
||||
},
|
||||
"camera_movement_advanced": {
|
||||
"none": "",
|
||||
"steadicam": "斯坦尼康",
|
||||
"handheld": "手持拍摄",
|
||||
"crane_shot": "升降镜头",
|
||||
"jib_shot": "摇臂镜头",
|
||||
"drone_shot": "航拍镜头",
|
||||
"underwater": "水下拍摄",
|
||||
"aerial_shot": "空中镜头",
|
||||
"helicopter_shot": "直升机镜头",
|
||||
"car_mount": "车载拍摄",
|
||||
"gimbal": "云台稳定器",
|
||||
"motion_control": "运动控制",
|
||||
"bullet_time": "子弹时间"
|
||||
},
|
||||
"time_of_day": {
|
||||
"none": "",
|
||||
"dawn": "黎明",
|
||||
"sunrise": "日出",
|
||||
"morning": "早晨",
|
||||
"noon": "正午",
|
||||
"afternoon": "下午",
|
||||
"sunset": "日落",
|
||||
"dusk": "黄昏",
|
||||
"night": "夜晚",
|
||||
"midnight": "午夜",
|
||||
"late_night": "深夜",
|
||||
"early_morning": "凌晨",
|
||||
"golden_hour": "黄金时段"
|
||||
},
|
||||
"motion": {
|
||||
"none": "",
|
||||
"slow_motion": "慢动作",
|
||||
"fast_motion": "快动作",
|
||||
"normal_speed": "正常速度",
|
||||
"time_lapse": "延时摄影",
|
||||
"freeze_frame": "定格画面",
|
||||
"motion_blur": "运动模糊",
|
||||
"sharp_motion": "清晰运动",
|
||||
"smooth_motion": "平滑运动",
|
||||
"jerky_motion": "抖动运动",
|
||||
"fluid_motion": "流畅运动",
|
||||
"staccato_motion": "断奏运动",
|
||||
"graceful_motion": "优雅运动"
|
||||
},
|
||||
"visual_effects": {
|
||||
"none": "",
|
||||
"lens_flare": "镜头光晕",
|
||||
"rain": "雨滴",
|
||||
"fog": "雾气",
|
||||
"smoke": "烟雾",
|
||||
"fire": "火焰",
|
||||
"explosion": "爆炸",
|
||||
"lightning": "闪电",
|
||||
"snow": "雪花",
|
||||
"dust": "灰尘",
|
||||
"particles": "粒子效果",
|
||||
"glow": "发光效果",
|
||||
"reflection": "反射效果"
|
||||
},
|
||||
"stylization_visual_style": {
|
||||
"none": "",
|
||||
"cinematic": "电影风格",
|
||||
"documentary": "纪录片风格",
|
||||
"action": "动作风格",
|
||||
"romance": "浪漫风格",
|
||||
"horror": "恐怖风格",
|
||||
"comedy": "喜剧风格",
|
||||
"drama": "戏剧风格",
|
||||
"sci_fi": "科幻风格",
|
||||
"fantasy": "奇幻风格",
|
||||
"noir": "黑色电影",
|
||||
"western": "西部风格",
|
||||
"period": "古装风格"
|
||||
},
|
||||
"character_emotion": {
|
||||
"none": "",
|
||||
"happy": "开心",
|
||||
"sad": "悲伤",
|
||||
"angry": "愤怒",
|
||||
"fearful": "恐惧",
|
||||
"surprised": "惊讶",
|
||||
"disgusted": "厌恶",
|
||||
"confident": "自信",
|
||||
"nervous": "紧张",
|
||||
"calm": "平静",
|
||||
"excited": "兴奋",
|
||||
"melancholy": "忧郁",
|
||||
"joyful": "喜悦"
|
||||
},
|
||||
"composition": {
|
||||
"none": "",
|
||||
"rule_of_thirds": "三分法",
|
||||
"symmetrical": "对称构图",
|
||||
"asymmetrical": "非对称构图",
|
||||
"leading_lines": "引导线",
|
||||
"framing": "框架构图",
|
||||
"depth_of_field": "景深",
|
||||
"shallow_focus": "浅景深",
|
||||
"deep_focus": "深景深",
|
||||
"low_angle": "低角度",
|
||||
"high_angle": "高角度",
|
||||
"eye_level": "平视角度",
|
||||
"dutch_angle": "倾斜角度"
|
||||
}
|
||||
},
|
||||
"en": {
|
||||
"shot_size": {
|
||||
"none": "",
|
||||
"medium_wide_shot": "Medium Wide Shot",
|
||||
"wide_shot": "Wide Shot",
|
||||
"medium_shot": "Medium Shot",
|
||||
"medium_close_up": "Medium Close Up",
|
||||
"extreme_close_up": "Extreme Close Up",
|
||||
"clean_single_shot": "Clean Single Shot",
|
||||
"two_shot": "Two Shot",
|
||||
"three_shot": "Three Shot",
|
||||
"group_shot": "Group Shot",
|
||||
"close_up_shot": "Close Up Shot",
|
||||
"long_shot": "Long Shot",
|
||||
"establishing_shot": "Establishing Shot",
|
||||
"medium_long_shot": "Medium Long Shot",
|
||||
"extreme_wide_shot": "Extreme Wide Shot",
|
||||
"overhead_wide_shot": "Overhead Wide Shot"
|
||||
},
|
||||
"lighting_type": {
|
||||
"none": "",
|
||||
"natural_light": "Natural Light",
|
||||
"studio_lighting": "Studio Lighting",
|
||||
"soft_lighting": "Soft Lighting",
|
||||
"hard_lighting": "Hard Lighting",
|
||||
"dramatic_lighting": "Dramatic Lighting",
|
||||
"rim_lighting": "Rim Lighting",
|
||||
"backlighting": "Backlighting",
|
||||
"side_lighting": "Side Lighting",
|
||||
"top_lighting": "Top Lighting",
|
||||
"bottom_lighting": "Bottom Lighting",
|
||||
"ambient_lighting": "Ambient Lighting",
|
||||
"practical_lighting": "Practical Lighting"
|
||||
},
|
||||
"light_source": {
|
||||
"none": "",
|
||||
"sunlight": "Sunlight",
|
||||
"moonlight": "Moonlight",
|
||||
"candlelight": "Candlelight",
|
||||
"firelight": "Firelight",
|
||||
"neon_lights": "Neon Lights",
|
||||
"fluorescent": "Fluorescent",
|
||||
"tungsten": "Tungsten",
|
||||
"led_lights": "LED Lights",
|
||||
"street_lights": "Street Lights",
|
||||
"car_headlights": "Car Headlights",
|
||||
"spotlight": "Spotlight",
|
||||
"window_light": "Window Light"
|
||||
},
|
||||
"color_tone": {
|
||||
"none": "",
|
||||
"warm_tones": "Warm Tones",
|
||||
"cool_tones": "Cool Tones",
|
||||
"neutral_tones": "Neutral Tones",
|
||||
"vibrant_colors": "Vibrant Colors",
|
||||
"muted_colors": "Muted Colors",
|
||||
"monochromatic": "Monochromatic",
|
||||
"high_contrast": "High Contrast",
|
||||
"low_contrast": "Low Contrast",
|
||||
"desaturated": "Desaturated",
|
||||
"oversaturated": "Oversaturated",
|
||||
"sepia_tone": "Sepia Tone",
|
||||
"blue_tint": "Blue Tint"
|
||||
},
|
||||
"camera_angle": {
|
||||
"none": "",
|
||||
"eye_level": "Eye Level",
|
||||
"high_angle": "High Angle",
|
||||
"low_angle": "Low Angle",
|
||||
"birds_eye": "Bird's Eye",
|
||||
"worms_eye": "Worm's Eye",
|
||||
"dutch_angle": "Dutch Angle",
|
||||
"over_shoulder": "Over the Shoulder",
|
||||
"point_of_view": "Point of View",
|
||||
"profile_shot": "Profile Shot",
|
||||
"three_quarter": "Three Quarter",
|
||||
"frontal_shot": "Frontal Shot",
|
||||
"back_shot": "Back Shot"
|
||||
},
|
||||
"lens": {
|
||||
"none": "",
|
||||
"wide_angle": "Wide Angle",
|
||||
"ultra_wide": "Ultra Wide",
|
||||
"telephoto": "Telephoto",
|
||||
"macro": "Macro",
|
||||
"fisheye": "Fisheye",
|
||||
"standard_lens": "Standard Lens",
|
||||
"portrait_lens": "Portrait Lens",
|
||||
"zoom_lens": "Zoom Lens",
|
||||
"prime_lens": "Prime Lens",
|
||||
"tilt_shift": "Tilt Shift",
|
||||
"anamorphic": "Anamorphic"
|
||||
},
|
||||
"camera_movement_basic": {
|
||||
"none": "",
|
||||
"static_shot": "Static Shot",
|
||||
"pan_left": "Pan Left",
|
||||
"pan_right": "Pan Right",
|
||||
"tilt_up": "Tilt Up",
|
||||
"tilt_down": "Tilt Down",
|
||||
"zoom_in": "Zoom In",
|
||||
"zoom_out": "Zoom Out",
|
||||
"dolly_in": "Dolly In",
|
||||
"dolly_out": "Dolly Out",
|
||||
"track_left": "Track Left",
|
||||
"track_right": "Track Right",
|
||||
"track_forward": "Track Forward",
|
||||
"track_backward": "Track Backward"
|
||||
},
|
||||
"camera_movement_advanced": {
|
||||
"none": "",
|
||||
"steadicam": "Steadicam",
|
||||
"handheld": "Handheld",
|
||||
"crane_shot": "Crane Shot",
|
||||
"jib_shot": "Jib Shot",
|
||||
"drone_shot": "Drone Shot",
|
||||
"underwater": "Underwater",
|
||||
"aerial_shot": "Aerial Shot",
|
||||
"helicopter_shot": "Helicopter Shot",
|
||||
"car_mount": "Car Mount",
|
||||
"gimbal": "Gimbal",
|
||||
"motion_control": "Motion Control",
|
||||
"bullet_time": "Bullet Time"
|
||||
},
|
||||
"time_of_day": {
|
||||
"none": "",
|
||||
"dawn": "Dawn",
|
||||
"sunrise": "Sunrise",
|
||||
"morning": "Morning",
|
||||
"noon": "Noon",
|
||||
"afternoon": "Afternoon",
|
||||
"sunset": "Sunset",
|
||||
"dusk": "Dusk",
|
||||
"night": "Night",
|
||||
"midnight": "Midnight",
|
||||
"late_night": "Late Night",
|
||||
"early_morning": "Early Morning",
|
||||
"golden_hour": "Golden Hour"
|
||||
},
|
||||
"motion": {
|
||||
"none": "",
|
||||
"slow_motion": "Slow Motion",
|
||||
"fast_motion": "Fast Motion",
|
||||
"normal_speed": "Normal Speed",
|
||||
"time_lapse": "Time Lapse",
|
||||
"freeze_frame": "Freeze Frame",
|
||||
"motion_blur": "Motion Blur",
|
||||
"sharp_motion": "Sharp Motion",
|
||||
"smooth_motion": "Smooth Motion",
|
||||
"jerky_motion": "Jerky Motion",
|
||||
"fluid_motion": "Fluid Motion",
|
||||
"staccato_motion": "Staccato Motion",
|
||||
"graceful_motion": "Graceful Motion"
|
||||
},
|
||||
"visual_effects": {
|
||||
"none": "",
|
||||
"lens_flare": "Lens Flare",
|
||||
"rain": "Rain",
|
||||
"fog": "Fog",
|
||||
"smoke": "Smoke",
|
||||
"fire": "Fire",
|
||||
"explosion": "Explosion",
|
||||
"lightning": "Lightning",
|
||||
"snow": "Snow",
|
||||
"dust": "Dust",
|
||||
"particles": "Particles",
|
||||
"glow": "Glow",
|
||||
"reflection": "Reflection"
|
||||
},
|
||||
"stylization_visual_style": {
|
||||
"none": "",
|
||||
"cinematic": "Cinematic",
|
||||
"documentary": "Documentary",
|
||||
"action": "Action",
|
||||
"romance": "Romance",
|
||||
"horror": "Horror",
|
||||
"comedy": "Comedy",
|
||||
"drama": "Drama",
|
||||
"sci_fi": "Sci-Fi",
|
||||
"fantasy": "Fantasy",
|
||||
"noir": "Noir",
|
||||
"western": "Western",
|
||||
"period": "Period"
|
||||
},
|
||||
"character_emotion": {
|
||||
"none": "",
|
||||
"happy": "Happy",
|
||||
"sad": "Sad",
|
||||
"angry": "Angry",
|
||||
"fearful": "Fearful",
|
||||
"surprised": "Surprised",
|
||||
"disgusted": "Disgusted",
|
||||
"confident": "Confident",
|
||||
"nervous": "Nervous",
|
||||
"calm": "Calm",
|
||||
"excited": "Excited",
|
||||
"melancholy": "Melancholy",
|
||||
"joyful": "Joyful"
|
||||
},
|
||||
"composition": {
|
||||
"none": "",
|
||||
"rule_of_thirds": "Rule of Thirds",
|
||||
"symmetrical": "Symmetrical",
|
||||
"asymmetrical": "Asymmetrical",
|
||||
"leading_lines": "Leading Lines",
|
||||
"framing": "Framing",
|
||||
"depth_of_field": "Depth of Field",
|
||||
"shallow_focus": "Shallow Focus",
|
||||
"deep_focus": "Deep Focus",
|
||||
"low_angle": "Low Angle",
|
||||
"high_angle": "High Angle",
|
||||
"eye_level": "Eye Level",
|
||||
"dutch_angle": "Dutch Angle"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"zh": {
|
||||
"language": "语言",
|
||||
"user_prompt": "用户提示词",
|
||||
"shot_size": "镜头大小",
|
||||
"lighting_type": "灯光类型",
|
||||
"light_source": "光源",
|
||||
"color_tone": "色调",
|
||||
"camera_angle": "摄像机角度",
|
||||
"lens": "镜头",
|
||||
"camera_movement_basic": "基础摄像机运动",
|
||||
"camera_movement_advanced": "高级摄像机运动",
|
||||
"time_of_day": "时间",
|
||||
"motion": "运动",
|
||||
"visual_effects": "视觉效果",
|
||||
"stylization_visual_style": "视觉风格",
|
||||
"character_emotion": "角色情感",
|
||||
"composition": "构图",
|
||||
"prompt_format": "提示词格式",
|
||||
"default_prompt": "一个美丽的场景",
|
||||
"professional_suffix": ",专业电影质量,高细节,4K分辨率",
|
||||
"detailed_suffix": "。专业电影制作,高质量,详细渲染",
|
||||
"format_professional": "专业",
|
||||
"format_simple": "简单",
|
||||
"format_detailed": "详细",
|
||||
"none_option": "无"
|
||||
},
|
||||
"en": {
|
||||
"language": "Language",
|
||||
"user_prompt": "User Prompt",
|
||||
"shot_size": "Shot Size",
|
||||
"lighting_type": "Lighting Type",
|
||||
"light_source": "Light Source",
|
||||
"color_tone": "Color Tone",
|
||||
"camera_angle": "Camera Angle",
|
||||
"lens": "Lens",
|
||||
"camera_movement_basic": "Camera Movement Basic",
|
||||
"camera_movement_advanced": "Camera Movement Advanced",
|
||||
"time_of_day": "Time of Day",
|
||||
"motion": "Motion",
|
||||
"visual_effects": "Visual Effects",
|
||||
"stylization_visual_style": "Visual Style",
|
||||
"character_emotion": "Character Emotion",
|
||||
"composition": "Composition",
|
||||
"prompt_format": "Prompt Format",
|
||||
"default_prompt": "A beautiful scene",
|
||||
"professional_suffix": ", professional cinematic quality, high detail, 4K resolution",
|
||||
"detailed_suffix": ". Professional cinematic production, high quality, detailed rendering",
|
||||
"format_professional": "Professional",
|
||||
"format_simple": "Simple",
|
||||
"format_detailed": "Detailed",
|
||||
"none_option": "none"
|
||||
},
|
||||
"messages": {
|
||||
"zh": {
|
||||
"load_message": "[Self Nodes] 已加载以下节点:",
|
||||
"detected_locale": "检测到中文语言环境",
|
||||
"using_default": "语言检测失败,使用默认中文",
|
||||
"unsupported_language": "不支持的语言",
|
||||
"fallback_to_default": ",回退到默认语言",
|
||||
"generated_prompt": "已生成包含",
|
||||
"cinematic_elements": "个电影元素的提示词",
|
||||
"selected_elements": "选中的元素"
|
||||
},
|
||||
"en": {
|
||||
"load_message": "[Self Nodes] Loaded the following nodes:",
|
||||
"detected_locale": "Detected non-Chinese locale",
|
||||
"using_default": "Language detection failed, using default Chinese",
|
||||
"unsupported_language": "Unsupported language",
|
||||
"fallback_to_default": ", fallback to default language",
|
||||
"generated_prompt": "Generated prompt with",
|
||||
"cinematic_elements": "cinematic elements",
|
||||
"selected_elements": "Selected elements"
|
||||
}
|
||||
},
|
||||
"display_names": {
|
||||
"zh": "🎬 视频提示词生成器",
|
||||
"en": "🎬 Video Prompt Generator"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user