合并代码仓库
This commit is contained in:
parent
90fe8dbd11
commit
a29e1c8db0
@ -1,5 +1,5 @@
|
|||||||
description: "Generated prompt based on user input: \u7AEF\u5348\u8282\u6D77\u62A5\
|
description: "Generated prompt based on user input: \u7AEF\u5348\u8282\u6D77\u62A5\
|
||||||
\uFF0C\u5305\u542B\u80CC\u666F\u3001\u6D3B\u52A8\u4EAE\u70B9\u548C\u56FE\u6807"
|
\uFF0C\u5305\u542B\u80CC\u666F\u3001\u6D3B\u52A8\u4EAE\u70B9\u548C\u56FE\u6807"
|
||||||
generated_at: 03:05 PM HKT on Monday, June 09, 2025
|
generated_at: 02:50 PM HKT on Monday, June 09, 2025
|
||||||
user_prompt: "\u7AEF\u5348\u8282\u6D77\u62A5\uFF0C\u5305\u542B\u80CC\u666F\u3001\u6D3B\
|
user_prompt: "\u7AEF\u5348\u8282\u6D77\u62A5\uFF0C\u5305\u542B\u80CC\u666F\u3001\u6D3B\
|
||||||
\u52A8\u4EAE\u70B9\u548C\u56FE\u6807"
|
\u52A8\u4EAE\u70B9\u548C\u56FE\u6807"
|
||||||
|
@ -1,9 +1,52 @@
|
|||||||
fastapi>=0.68.0
|
# LLM和API相关
|
||||||
uvicorn>=0.18.0
|
fastapi==0.104.1
|
||||||
python-dotenv>=0.21.0
|
uvicorn==0.24.0
|
||||||
pyyaml>=6.0
|
python-dotenv==1.0.0
|
||||||
websocket-client>=1.5.0
|
requests==2.31.0
|
||||||
requests>=2.28.0
|
httpx==0.25.1
|
||||||
pillow>=9.0.0
|
pydantic==2.4.2
|
||||||
psd-tools>=1.9.0
|
|
||||||
openai>=1.0.0
|
# 图像处理
|
||||||
|
Pillow==10.1.0
|
||||||
|
numpy==1.26.2
|
||||||
|
opencv-python==4.8.1.78
|
||||||
|
photoshop-python-api==0.19.0 # PSD文件处理
|
||||||
|
|
||||||
|
# 深度学习和AI
|
||||||
|
torch==2.1.1
|
||||||
|
transformers==4.35.2
|
||||||
|
diffusers==0.24.0
|
||||||
|
accelerate==0.24.1
|
||||||
|
|
||||||
|
# 工具和辅助库
|
||||||
|
python-multipart==0.0.6
|
||||||
|
pyyaml==6.0.1
|
||||||
|
tqdm==4.66.1
|
||||||
|
colorama==0.4.6
|
||||||
|
loguru==0.7.2
|
||||||
|
|
||||||
|
# 数据处理和存储
|
||||||
|
pandas==2.1.3
|
||||||
|
sqlalchemy==2.0.23
|
||||||
|
pymongo==4.6.0
|
||||||
|
redis==5.0.1
|
||||||
|
|
||||||
|
# 测试和开发工具
|
||||||
|
pytest==7.4.3
|
||||||
|
black==23.11.0
|
||||||
|
isort==5.12.0
|
||||||
|
mypy==1.7.0
|
||||||
|
|
||||||
|
# Web服务和异步
|
||||||
|
aiohttp==3.9.0
|
||||||
|
websockets==12.0
|
||||||
|
gunicorn==21.2.0
|
||||||
|
|
||||||
|
# 文件处理
|
||||||
|
python-magic==0.4.27
|
||||||
|
python-multipart==0.0.6
|
||||||
|
aiofiles==23.2.1
|
||||||
|
|
||||||
|
# 监控和日志
|
||||||
|
prometheus-client==0.19.0
|
||||||
|
sentry-sdk==1.32.0
|
||||||
|
BIN
requirments.txt
Normal file
BIN
requirments.txt
Normal file
Binary file not shown.
BIN
scripts/__pycache__/flux_con.cpython-311.pyc
Normal file
BIN
scripts/__pycache__/flux_con.cpython-311.pyc
Normal file
Binary file not shown.
282
scripts/flux_con.py
Normal file
282
scripts/flux_con.py
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
import random
|
||||||
|
from datetime import datetime
|
||||||
|
from websocket import create_connection, WebSocketTimeoutException, WebSocketConnectionClosedException
|
||||||
|
import urllib.request
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
def comfyui_img_info(user_input_analysis_result, system_prompt):
|
||||||
|
"""
|
||||||
|
根据提示词分析结果生成图片,并返回parse_imglist列表
|
||||||
|
|
||||||
|
参数:
|
||||||
|
user_input_analysis_result: 用户输入的分析结果(字典)
|
||||||
|
system_prompt: 用户输入的system prompt内容
|
||||||
|
|
||||||
|
返回:
|
||||||
|
parse_imglist (list): 图片解析列表,包含图片信息的字典
|
||||||
|
"""
|
||||||
|
# 从分析结果中提取参数
|
||||||
|
width = user_input_analysis_result.get('width', 1024)
|
||||||
|
height = user_input_analysis_result.get('height', 768)
|
||||||
|
batch_size = user_input_analysis_result.get('batch_size', 1)
|
||||||
|
|
||||||
|
# 配置参数
|
||||||
|
WORKING_DIR = 'outputs'
|
||||||
|
COMFYUI_ENDPOINT = '101.201.50.90:8188'
|
||||||
|
DEFAULT_WORKFLOW = './workflows/flux_work.json'
|
||||||
|
TEMP_WORKFLOW_DIR = './workflows/temp'
|
||||||
|
|
||||||
|
# 创建临时目录
|
||||||
|
os.makedirs(TEMP_WORKFLOW_DIR, exist_ok=True)
|
||||||
|
PROCESSED_WORKFLOW = os.path.join(TEMP_WORKFLOW_DIR, f"processed_workflow_{uuid.uuid4().hex}.json")
|
||||||
|
|
||||||
|
# 1. 预处理工作流
|
||||||
|
workflow_file = preprocess_workflow(
|
||||||
|
system_prompt=system_prompt,
|
||||||
|
width=width,
|
||||||
|
height=height,
|
||||||
|
batch_size=batch_size,
|
||||||
|
input_json=DEFAULT_WORKFLOW,
|
||||||
|
output_json=PROCESSED_WORKFLOW
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2. 准备输出目录
|
||||||
|
os.makedirs(WORKING_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
# 创建客户端ID
|
||||||
|
client_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
# 生成图像
|
||||||
|
saved_files = generate_images(
|
||||||
|
workflow_file=workflow_file,
|
||||||
|
server_address=COMFYUI_ENDPOINT,
|
||||||
|
output_dir=WORKING_DIR,
|
||||||
|
client_id=client_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# 构建parse_imglist
|
||||||
|
parse_imglist = []
|
||||||
|
for file_path in saved_files:
|
||||||
|
# 提取图片信息
|
||||||
|
filename = os.path.basename(file_path)
|
||||||
|
name_without_ext = os.path.splitext(filename)[0]
|
||||||
|
|
||||||
|
# 构造图片信息字典
|
||||||
|
img_info = {
|
||||||
|
"picture_name": name_without_ext,
|
||||||
|
"picture_type": "png",
|
||||||
|
"picture_description": system_prompt,
|
||||||
|
"picture_size": f"{width}x{height}"
|
||||||
|
}
|
||||||
|
parse_imglist.append(img_info)
|
||||||
|
|
||||||
|
return parse_imglist
|
||||||
|
|
||||||
|
def preprocess_workflow(system_prompt, width, height, batch_size, input_json='flux_work.json', output_json='processed_workflow.json'):
|
||||||
|
"""
|
||||||
|
预处理工作流文件,更新系统提示和图像参数
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with open(input_json, 'r') as f:
|
||||||
|
workflow = json.load(f)
|
||||||
|
|
||||||
|
# 更新系统提示
|
||||||
|
workflow['31']['inputs']['system_prompt'] = system_prompt
|
||||||
|
|
||||||
|
# 更新图像参数
|
||||||
|
workflow['27']['inputs']['width'] = str(width)
|
||||||
|
workflow['27']['inputs']['height'] = str(height)
|
||||||
|
workflow['27']['inputs']['batch_size'] = str(batch_size)
|
||||||
|
|
||||||
|
# 保存更新后的工作流
|
||||||
|
with open(output_json, 'w') as f:
|
||||||
|
json.dump(workflow, f, indent=2)
|
||||||
|
|
||||||
|
print(f"工作流已更新并保存到: {output_json}")
|
||||||
|
return output_json
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"预处理工作流出错: {str(e)}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def queue_prompt(prompt, server_address, client_id):
|
||||||
|
"""向服务器队列发送提示信息"""
|
||||||
|
p = {"prompt": prompt, "client_id": client_id}
|
||||||
|
data = json.dumps(p).encode('utf-8')
|
||||||
|
req = urllib.request.Request(f"http://{server_address}/prompt", data=data)
|
||||||
|
return json.loads(urllib.request.urlopen(req).read())
|
||||||
|
|
||||||
|
def get_image(filename, subfolder, folder_type, server_address):
|
||||||
|
"""获取生成的图像"""
|
||||||
|
data = {"filename": filename, "subfolder": subfolder, "type": folder_type}
|
||||||
|
url_values = urllib.parse.urlencode(data)
|
||||||
|
with urllib.request.urlopen(f"http://{server_address}/view?{url_values}") as response:
|
||||||
|
return response.read()
|
||||||
|
|
||||||
|
def get_history(prompt_id, server_address):
|
||||||
|
"""获取历史记录"""
|
||||||
|
with urllib.request.urlopen(f"http://{server_address}/history/{prompt_id}") as response:
|
||||||
|
return json.loads(response.read())
|
||||||
|
|
||||||
|
def get_images(ws, prompt, server_address, client_id, timeout=600):
|
||||||
|
"""获取生成的所有图像"""
|
||||||
|
prompt_id = queue_prompt(prompt, server_address, client_id)['prompt_id']
|
||||||
|
print(f'提示ID: {prompt_id}')
|
||||||
|
output_images = {}
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
while True:
|
||||||
|
if time.time() - start_time > timeout:
|
||||||
|
print(f"超时:等待执行超过{timeout}秒")
|
||||||
|
break
|
||||||
|
|
||||||
|
try:
|
||||||
|
out = ws.recv()
|
||||||
|
if isinstance(out, str):
|
||||||
|
message = json.loads(out)
|
||||||
|
if message['type'] == 'executing':
|
||||||
|
data = message['data']
|
||||||
|
if data['node'] is None and data['prompt_id'] == prompt_id:
|
||||||
|
print('执行完成')
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"接收消息出错: {str(e)}")
|
||||||
|
break
|
||||||
|
|
||||||
|
history = get_history(prompt_id, server_address).get(prompt_id, {})
|
||||||
|
if not history:
|
||||||
|
print("未找到该提示的历史记录")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
for node_id, node_output in history['outputs'].items():
|
||||||
|
if 'images' in node_output:
|
||||||
|
images_output = []
|
||||||
|
for image in node_output['images']:
|
||||||
|
try:
|
||||||
|
image_data = get_image(image['filename'], image['subfolder'], image['type'], server_address)
|
||||||
|
images_output.append({
|
||||||
|
'data': image_data,
|
||||||
|
'filename': image['filename'],
|
||||||
|
'subfolder': image['subfolder'],
|
||||||
|
'type': image['type']
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取图像错误: {str(e)}")
|
||||||
|
output_images[node_id] = images_output
|
||||||
|
|
||||||
|
print(f'获取到 {len(output_images)} 组图像输出')
|
||||||
|
return output_images
|
||||||
|
|
||||||
|
def generate_images(workflow_file, server_address, output_dir, client_id):
|
||||||
|
"""生成图像主函数"""
|
||||||
|
try:
|
||||||
|
# 加载工作流
|
||||||
|
with open(workflow_file, 'r', encoding='utf-8') as f:
|
||||||
|
workflow_data = json.load(f)
|
||||||
|
|
||||||
|
# 使用随机种子
|
||||||
|
seed = random.randint(1, 10**8)
|
||||||
|
print(f'使用种子: {seed}')
|
||||||
|
|
||||||
|
# 更新种子
|
||||||
|
workflow_data['25']['inputs']['noise_seed'] = seed
|
||||||
|
|
||||||
|
# 创建WebSocket连接
|
||||||
|
ws_url = f"ws://{server_address}/ws?clientId={client_id}"
|
||||||
|
ws = create_connection(ws_url, timeout=600)
|
||||||
|
|
||||||
|
# 获取图像
|
||||||
|
images = get_images(ws, workflow_data, server_address, client_id)
|
||||||
|
ws.close()
|
||||||
|
|
||||||
|
# 保存图像
|
||||||
|
saved_files = []
|
||||||
|
if images:
|
||||||
|
for node_id, image_list in images.items():
|
||||||
|
for i, img in enumerate(image_list):
|
||||||
|
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
|
filename = f"{seed}_{timestamp}_{i}.png"
|
||||||
|
file_path = os.path.join(output_dir, filename)
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(file_path, "wb") as f:
|
||||||
|
f.write(img['data'])
|
||||||
|
saved_files.append(file_path)
|
||||||
|
print(f'已保存: {file_path}')
|
||||||
|
except Exception as e:
|
||||||
|
print(f"保存图像错误: {str(e)}")
|
||||||
|
|
||||||
|
return saved_files
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"生成图像出错: {str(e)}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 配置参数
|
||||||
|
WORKING_DIR = 'output'
|
||||||
|
COMFYUI_ENDPOINT = '101.201.50.90:8188'
|
||||||
|
DEFAULT_WORKFLOW = './workflows/flux_work.json'
|
||||||
|
TEMP_WORKFLOW_DIR = './workflows/temp'
|
||||||
|
|
||||||
|
# 从命令行获取输入参数
|
||||||
|
if len(sys.argv) != 5:
|
||||||
|
print("用法: python test.py <prompt> <width> <height> <batch_size>")
|
||||||
|
print("示例: python test.py \"南开大学图书馆,大雨天\" 2048 1024 1")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
system_prompt = sys.argv[1]
|
||||||
|
width = int(sys.argv[2])
|
||||||
|
height = int(sys.argv[3])
|
||||||
|
batch_size = int(sys.argv[4])
|
||||||
|
|
||||||
|
# 创建临时目录
|
||||||
|
os.makedirs(TEMP_WORKFLOW_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
# 创建临时文件路径
|
||||||
|
PROCESSED_WORKFLOW = os.path.join(TEMP_WORKFLOW_DIR, f"processed_workflow_{uuid.uuid4().hex}.json")
|
||||||
|
|
||||||
|
# 1. 预处理工作流
|
||||||
|
workflow_file = preprocess_workflow(
|
||||||
|
system_prompt=system_prompt,
|
||||||
|
width=width,
|
||||||
|
height=height,
|
||||||
|
batch_size=batch_size,
|
||||||
|
input_json=DEFAULT_WORKFLOW,
|
||||||
|
output_json=PROCESSED_WORKFLOW
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2. 准备输出目录
|
||||||
|
os.makedirs(WORKING_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
# 创建客户端ID
|
||||||
|
client_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
print(f"系统提示: {system_prompt}")
|
||||||
|
print(f"图像尺寸: {width}x{height}")
|
||||||
|
print(f"批次大小: {batch_size}")
|
||||||
|
print(f"工作流文件: {workflow_file}")
|
||||||
|
print(f"客户端ID: {client_id}")
|
||||||
|
print(f"开始使用ComfyUI生成图像: {COMFYUI_ENDPOINT}")
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
# 生成图像
|
||||||
|
print(f"\n===== 开始生成图像 =====")
|
||||||
|
saved_files = generate_images(
|
||||||
|
workflow_file=workflow_file,
|
||||||
|
server_address=COMFYUI_ENDPOINT,
|
||||||
|
output_dir=WORKING_DIR,
|
||||||
|
client_id=client_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# 输出结果
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
print(f"\n处理完成,耗时 {elapsed:.2f} 秒")
|
||||||
|
print(f"共生成 {len(saved_files)} 张图像")
|
||||||
|
print(f"保存位置: {WORKING_DIR}")
|
@ -5,7 +5,7 @@ from generate_layout import call_deepseek, generate_vue_code, save_code
|
|||||||
from generate_text import load_config_from_file, get_poster_content_suggestions
|
from generate_text import load_config_from_file, get_poster_content_suggestions
|
||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from ComfyUI.flux_con import comfyui_img_info # 导入已实现的图像生成函数
|
from flux_con import comfyui_img_info # 导入已实现的图像生成函数
|
||||||
|
|
||||||
# 配置路径
|
# 配置路径
|
||||||
config_paths = {
|
config_paths = {
|
||||||
|
220
scripts/test.py
Normal file
220
scripts/test.py
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
import json
|
||||||
|
from websocket import create_connection, WebSocketTimeoutException, WebSocketConnectionClosedException
|
||||||
|
import uuid
|
||||||
|
import urllib.request
|
||||||
|
import urllib.parse
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
# 定义一个函数来显示GIF图片
|
||||||
|
def show_gif(fname):
|
||||||
|
import base64
|
||||||
|
from IPython import display
|
||||||
|
with open(fname, 'rb') as fd:
|
||||||
|
b64 = base64.b64encode(fd.read()).decode('ascii')
|
||||||
|
return display.HTML(f'<img src="data:image/gif;base64,{b64}" />')
|
||||||
|
|
||||||
|
# 定义一个函数向服务器队列发送提示信息
|
||||||
|
def queue_prompt(prompt):
|
||||||
|
p = {"prompt": prompt, "client_id": client_id}
|
||||||
|
data = json.dumps(p).encode('utf-8')
|
||||||
|
req = urllib.request.Request("http://{}/prompt".format(server_address), data=data)
|
||||||
|
return json.loads(urllib.request.urlopen(req).read())
|
||||||
|
|
||||||
|
# 定义一个函数来获取图片
|
||||||
|
def get_image(filename, subfolder, folder_type):
|
||||||
|
data = {"filename": filename, "subfolder": subfolder, "type": folder_type}
|
||||||
|
url_values = urllib.parse.urlencode(data)
|
||||||
|
with urllib.request.urlopen("http://{}/view?{}".format(server_address, url_values)) as response:
|
||||||
|
return response.read()
|
||||||
|
|
||||||
|
# 定义一个函数来获取历史记录
|
||||||
|
def get_history(prompt_id):
|
||||||
|
with urllib.request.urlopen("http://{}/history/{}".format(server_address, prompt_id)) as response:
|
||||||
|
return json.loads(response.read())
|
||||||
|
|
||||||
|
# 定义一个函数来获取图片,这涉及到监听WebSocket消息
|
||||||
|
def get_images(ws, prompt):
|
||||||
|
prompt_id = queue_prompt(prompt)['prompt_id']
|
||||||
|
print('Prompt: ', prompt)
|
||||||
|
print('Prompt ID: ', prompt_id)
|
||||||
|
output_images = {}
|
||||||
|
|
||||||
|
# 等待执行完成
|
||||||
|
start_time = time.time()
|
||||||
|
while True:
|
||||||
|
if time.time() - start_time > 1200: # 设置2分钟超时
|
||||||
|
print("超时:等待执行完成超过120秒")
|
||||||
|
break
|
||||||
|
|
||||||
|
out = ws.recv()
|
||||||
|
if isinstance(out, str):
|
||||||
|
message = json.loads(out)
|
||||||
|
if message['type'] == 'executing':
|
||||||
|
data = message['data']
|
||||||
|
if data['node'] is None and data['prompt_id'] == prompt_id:
|
||||||
|
print('Execution complete')
|
||||||
|
break # 执行完成
|
||||||
|
else:
|
||||||
|
continue # 预览为二进制数据
|
||||||
|
|
||||||
|
# 获取完成的历史记录
|
||||||
|
history = get_history(prompt_id).get(prompt_id, {})
|
||||||
|
|
||||||
|
if not history:
|
||||||
|
print("未找到该提示的历史记录")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
for node_id in history['outputs']:
|
||||||
|
node_output = history['outputs'][node_id]
|
||||||
|
# 图片分支
|
||||||
|
if 'images' in node_output:
|
||||||
|
images_output = []
|
||||||
|
for image in node_output['images']:
|
||||||
|
try:
|
||||||
|
image_data = get_image(image['filename'], image['subfolder'], image['type'])
|
||||||
|
images_output.append(image_data)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取图像错误: {str(e)}")
|
||||||
|
output_images[node_id] = images_output
|
||||||
|
# 视频分支
|
||||||
|
elif 'videos' in node_output:
|
||||||
|
videos_output = []
|
||||||
|
for video in node_output['videos']:
|
||||||
|
try:
|
||||||
|
video_data = get_image(video['filename'], video['subfolder'], video['type'])
|
||||||
|
videos_output.append(video_data)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"获取视频错误: {str(e)}")
|
||||||
|
output_images[node_id] = videos_output
|
||||||
|
|
||||||
|
print(f'Obtained {len(output_images)} image/video sets')
|
||||||
|
return output_images
|
||||||
|
|
||||||
|
# 解析工作流并获取图片
|
||||||
|
def parse_workflow(prompt, seed, workflowfile):
|
||||||
|
print(f'Workflow file: {workflowfile}')
|
||||||
|
try:
|
||||||
|
with open(workflowfile, 'r', encoding="utf-8") as f:
|
||||||
|
prompt_data = json.load(f)
|
||||||
|
# 设置文本提示
|
||||||
|
prompt_data["6"]["inputs"]["text"] = prompt
|
||||||
|
# 设置随机种子(如果需要)
|
||||||
|
if "Ksampler" in prompt_data:
|
||||||
|
if "seed" in prompt_data["Ksampler"]["inputs"]:
|
||||||
|
prompt_data["Ksampler"]["inputs"]["seed"] = seed
|
||||||
|
elif "noise_seed" in prompt_data["Ksampler"]["inputs"]:
|
||||||
|
prompt_data["Ksampler"]["inputs"]["noise_seed"] = seed
|
||||||
|
return prompt_data
|
||||||
|
except Exception as e:
|
||||||
|
print(f"工作流解析错误: {str(e)}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
# 生成图像并保存
|
||||||
|
def generate_clip(prompt, seed, workflowfile, idx):
|
||||||
|
print(f'Processing prompt #{idx}: "{prompt[:50]}{"..." if len(prompt) > 50 else ""}"')
|
||||||
|
print(f'Using seed: {seed}')
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 使用正确的WebSocket连接方式
|
||||||
|
ws_url = f"ws://{server_address}/ws?clientId={client_id}"
|
||||||
|
|
||||||
|
# 使用 create_connection
|
||||||
|
ws = create_connection(ws_url, timeout=600)
|
||||||
|
|
||||||
|
# 解析工作流
|
||||||
|
workflow_data = parse_workflow(prompt, seed, workflowfile)
|
||||||
|
if not workflow_data:
|
||||||
|
print("工作流数据为空")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 获取图像
|
||||||
|
images = get_images(ws, workflow_data)
|
||||||
|
|
||||||
|
# 关闭连接
|
||||||
|
ws.close()
|
||||||
|
except WebSocketTimeoutException as e:
|
||||||
|
print(f"WebSocket连接超时: {str(e)}")
|
||||||
|
return
|
||||||
|
except WebSocketConnectionClosedException as e:
|
||||||
|
print(f"WebSocket连接已关闭: {str(e)}")
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
print(f"WebSocket错误: {str(e)}")
|
||||||
|
return
|
||||||
|
|
||||||
|
saved_files = []
|
||||||
|
if images:
|
||||||
|
for node_id, image_list in images.items():
|
||||||
|
for i, image_data in enumerate(image_list):
|
||||||
|
# 格式化时间戳
|
||||||
|
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
|
# 创建唯一文件名
|
||||||
|
filename = f"{idx}_{seed}_{timestamp}_{i}.png"
|
||||||
|
file_path = f"{WORKING_DIR}/{filename}"
|
||||||
|
|
||||||
|
print(f'Saving to: {file_path}')
|
||||||
|
try:
|
||||||
|
with open(file_path, "wb") as f:
|
||||||
|
f.write(image_data)
|
||||||
|
saved_files.append(file_path)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"文件保存错误: {str(e)}")
|
||||||
|
else:
|
||||||
|
print("未获取到图像数据")
|
||||||
|
|
||||||
|
if saved_files:
|
||||||
|
print(f"成功生成 {len(saved_files)} 张图片")
|
||||||
|
else:
|
||||||
|
print("未保存任何图片")
|
||||||
|
|
||||||
|
# 直接在代码中定义提示词列表
|
||||||
|
PROMPTS = [
|
||||||
|
"A beautiful sunset over the ocean, realistic, cinematic lighting",
|
||||||
|
"A futuristic cityscape at night, cyberpunk style, neon lights",
|
||||||
|
"An ancient forest with magical creatures, fantasy, photorealistic",
|
||||||
|
"A steampunk laboratory with bubbling beakers and intricate machinery",
|
||||||
|
"Abstract geometric patterns in vibrant colors, digital art",
|
||||||
|
"A majestic lion in the African savannah, golden hour lighting",
|
||||||
|
"A cozy cabin in the mountains during winter, warm lights inside",
|
||||||
|
"A detailed close-up of a butterfly on a flower, macro photography",
|
||||||
|
"Underwater scene with coral reef and tropical fish, crystal clear water"
|
||||||
|
]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 设置工作目录和项目相关的路径
|
||||||
|
WORKING_DIR = 'output'
|
||||||
|
workflowfile = './workflows/flux_redux.json'
|
||||||
|
COMFYUI_ENDPOINT = '101.201.50.90:8188'
|
||||||
|
|
||||||
|
# 服务器配置
|
||||||
|
global server_address, client_id
|
||||||
|
server_address = COMFYUI_ENDPOINT
|
||||||
|
client_id = str(uuid.uuid4()) # 生成一个唯一的客户端ID
|
||||||
|
|
||||||
|
# 种子设置 - 可以选择固定或随机
|
||||||
|
USE_RANDOM_SEED = True # 设为False则使用固定种子
|
||||||
|
base_seed = 15465856
|
||||||
|
|
||||||
|
print(f"Starting image generation with ComfyUI at {server_address}")
|
||||||
|
print(f"Working directory: {WORKING_DIR}")
|
||||||
|
print(f"Workflow file: {workflowfile}")
|
||||||
|
print(f"Client ID: {client_id}")
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
# 处理每个提示词
|
||||||
|
for idx, prompt in enumerate(PROMPTS, start=1):
|
||||||
|
# 设置种子
|
||||||
|
current_seed = random.randint(1, 10**8) if USE_RANDOM_SEED else base_seed
|
||||||
|
|
||||||
|
print(f"\n===== Processing Prompt #{idx} of {len(PROMPTS)} =====")
|
||||||
|
generate_clip(prompt, current_seed, workflowfile, idx)
|
||||||
|
|
||||||
|
# 添加延迟以避免服务器过载
|
||||||
|
time.sleep(2) # 2秒延迟
|
||||||
|
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
print(f"\nProcessing completed in {elapsed:.2f} seconds")
|
||||||
|
print(f"Generated images for {len(PROMPTS)} prompts")
|
0
scripts/workflows/20250526_163432_chat_history.json
Normal file
0
scripts/workflows/20250526_163432_chat_history.json
Normal file
0
scripts/workflows/20250526_163433_chat_history.json
Normal file
0
scripts/workflows/20250526_163433_chat_history.json
Normal file
292
scripts/workflows/flux_redux.json
Normal file
292
scripts/workflows/flux_redux.json
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
{
|
||||||
|
"6": {
|
||||||
|
"inputs": {
|
||||||
|
"text": [
|
||||||
|
"45",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"clip": [
|
||||||
|
"11",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "CLIPTextEncode",
|
||||||
|
"_meta": {
|
||||||
|
"title": "CLIP Text Encode (Positive Prompt)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"8": {
|
||||||
|
"inputs": {
|
||||||
|
"samples": [
|
||||||
|
"13",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"vae": [
|
||||||
|
"10",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "VAEDecode",
|
||||||
|
"_meta": {
|
||||||
|
"title": "VAE解码"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"9": {
|
||||||
|
"inputs": {
|
||||||
|
"filename_prefix": "ComfyUI",
|
||||||
|
"images": [
|
||||||
|
"8",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SaveImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "保存图像"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"10": {
|
||||||
|
"inputs": {
|
||||||
|
"vae_name": "ae.safetensors"
|
||||||
|
},
|
||||||
|
"class_type": "VAELoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "加载VAE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"11": {
|
||||||
|
"inputs": {
|
||||||
|
"clip_name1": "t5xxl_fp16.safetensors",
|
||||||
|
"clip_name2": "clip_l.safetensors",
|
||||||
|
"type": "flux",
|
||||||
|
"device": "default"
|
||||||
|
},
|
||||||
|
"class_type": "DualCLIPLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "双CLIP加载器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"12": {
|
||||||
|
"inputs": {
|
||||||
|
"unet_name": "flux1-dev.safetensors",
|
||||||
|
"weight_dtype": "default"
|
||||||
|
},
|
||||||
|
"class_type": "UNETLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "UNet加载器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"13": {
|
||||||
|
"inputs": {
|
||||||
|
"noise": [
|
||||||
|
"25",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"guider": [
|
||||||
|
"22",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"sampler": [
|
||||||
|
"16",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"sigmas": [
|
||||||
|
"17",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"latent_image": [
|
||||||
|
"27",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SamplerCustomAdvanced",
|
||||||
|
"_meta": {
|
||||||
|
"title": "自定义采样器(高级)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"16": {
|
||||||
|
"inputs": {
|
||||||
|
"sampler_name": "euler"
|
||||||
|
},
|
||||||
|
"class_type": "KSamplerSelect",
|
||||||
|
"_meta": {
|
||||||
|
"title": "K采样器选择"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"17": {
|
||||||
|
"inputs": {
|
||||||
|
"scheduler": "simple",
|
||||||
|
"steps": 20,
|
||||||
|
"denoise": 1,
|
||||||
|
"model": [
|
||||||
|
"30",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "BasicScheduler",
|
||||||
|
"_meta": {
|
||||||
|
"title": "基本调度器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"22": {
|
||||||
|
"inputs": {
|
||||||
|
"model": [
|
||||||
|
"30",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"conditioning": [
|
||||||
|
"41",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "BasicGuider",
|
||||||
|
"_meta": {
|
||||||
|
"title": "基本引导器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"25": {
|
||||||
|
"inputs": {
|
||||||
|
"noise_seed": 214516345808749
|
||||||
|
},
|
||||||
|
"class_type": "RandomNoise",
|
||||||
|
"_meta": {
|
||||||
|
"title": "随机噪波"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"26": {
|
||||||
|
"inputs": {
|
||||||
|
"guidance": 3.5,
|
||||||
|
"conditioning": [
|
||||||
|
"6",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "FluxGuidance",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Flux引导"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"27": {
|
||||||
|
"inputs": {
|
||||||
|
"width": 1024,
|
||||||
|
"height": 1024,
|
||||||
|
"batch_size": 4
|
||||||
|
},
|
||||||
|
"class_type": "EmptySD3LatentImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "空Latent图像(SD3)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"30": {
|
||||||
|
"inputs": {
|
||||||
|
"max_shift": 1.15,
|
||||||
|
"base_shift": 0.5,
|
||||||
|
"width": 1024,
|
||||||
|
"height": 1024,
|
||||||
|
"model": [
|
||||||
|
"12",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "ModelSamplingFlux",
|
||||||
|
"_meta": {
|
||||||
|
"title": "采样算法(Flux)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"38": {
|
||||||
|
"inputs": {
|
||||||
|
"clip_name": "sigclip_vision_patch14_384.safetensors"
|
||||||
|
},
|
||||||
|
"class_type": "CLIPVisionLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "加载CLIP视觉"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"39": {
|
||||||
|
"inputs": {
|
||||||
|
"crop": "center",
|
||||||
|
"clip_vision": [
|
||||||
|
"38",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"image": [
|
||||||
|
"40",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "CLIPVisionEncode",
|
||||||
|
"_meta": {
|
||||||
|
"title": "CLIP视觉编码"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"40": {
|
||||||
|
"inputs": {
|
||||||
|
"image": "WechatIMG16695.jpeg"
|
||||||
|
},
|
||||||
|
"class_type": "LoadImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "加载图像"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"41": {
|
||||||
|
"inputs": {
|
||||||
|
"strength": 1,
|
||||||
|
"strength_type": "multiply",
|
||||||
|
"conditioning": [
|
||||||
|
"26",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"style_model": [
|
||||||
|
"42",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"clip_vision_output": [
|
||||||
|
"39",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "StyleModelApply",
|
||||||
|
"_meta": {
|
||||||
|
"title": "应用风格模型"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"inputs": {
|
||||||
|
"style_model_name": "flux1-redux-dev.safetensors"
|
||||||
|
},
|
||||||
|
"class_type": "StyleModelLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "加载风格模型"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"45": {
|
||||||
|
"inputs": {
|
||||||
|
"user_prompt": "作为一个AI提示词专家,请你仿照范例,根据我给出的主题,生成一条符合下列要求的提示词,来让CLIP模型可以更好地理解画面主体。注意:你的输出将提供给图生图(image-to-image)模型,所以你只需要对用户输入中的风格和细节部分作扩展。\n 要求共五条,请严格遵守:\n 1: 用自然语言简单句来描述画面,请避免出现过于长的,或者格式过于复杂的句子,句子中不要出现*等特殊符号。\n 2.用英语表达。 \n 3.直接给出prompt内容即可,不需要解释和说明。\n 4. 每条prompt至少50词,不超过200词。\n 5.避免模棱两可的说法。\n 例如:[Reference Image Weight: 0.7] Cartoonized Nankai University Main Building, \nGothic-Revival architecture with rounded edges, crimson bricks and golden arched windows (ultra-high texture details), whimsical cloud-shaped eaves dripping liquid clock gears (steampunk elements), soft pastel gradients. \nDynamic elements: \nTranslucent 1919-era scholar phantoms floating with glowing books (semi-transparent mercury texture), oversized origami maple leaves spiraling around twin bell towers (visible musical notes in air). \nEnvironment: \nSurreal candy-pink to indigo gradient sky, emerald velvet lawns with squirrels wearing graduation caps (playful proportions:1.5x). Ground puddles reflecting calculus formula ripples (mathematical glow effect). \nTechnical parameters: \nStudio Ghibli style, watercolor rendering, 8K resolution, cinematic lighting, symmetry composition, ultra-detailed lineart",
|
||||||
|
"system_prompt": "南开大学鸟瞰图,3D电影高级风格。",
|
||||||
|
"enable_history": false,
|
||||||
|
"max_history": 10,
|
||||||
|
"history_json": "",
|
||||||
|
"save_path": "./chat_history.json",
|
||||||
|
"api_config": [
|
||||||
|
"46",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "DeepSeekChat",
|
||||||
|
"_meta": {
|
||||||
|
"title": "LLM Model Input Box"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"46": {
|
||||||
|
"inputs": {
|
||||||
|
"config_name": "DeepSeek官方Chat API",
|
||||||
|
"temperature": 1,
|
||||||
|
"max_tokens": 512,
|
||||||
|
"stream": false,
|
||||||
|
"api_key": ""
|
||||||
|
},
|
||||||
|
"class_type": "DeepSeekAPIConfig",
|
||||||
|
"_meta": {
|
||||||
|
"title": "LLM API Model Selector"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
226
scripts/workflows/flux_work.json
Normal file
226
scripts/workflows/flux_work.json
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
{
|
||||||
|
"6": {
|
||||||
|
"inputs": {
|
||||||
|
"text": [
|
||||||
|
"31",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"clip": [
|
||||||
|
"11",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "CLIPTextEncode",
|
||||||
|
"_meta": {
|
||||||
|
"title": "CLIP Text Encode (Positive Prompt)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"8": {
|
||||||
|
"inputs": {
|
||||||
|
"samples": [
|
||||||
|
"13",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"vae": [
|
||||||
|
"10",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "VAEDecode",
|
||||||
|
"_meta": {
|
||||||
|
"title": "VAE解码"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"9": {
|
||||||
|
"inputs": {
|
||||||
|
"filename_prefix": "ComfyUI",
|
||||||
|
"images": [
|
||||||
|
"8",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SaveImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "保存图像"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"10": {
|
||||||
|
"inputs": {
|
||||||
|
"vae_name": "ae.safetensors"
|
||||||
|
},
|
||||||
|
"class_type": "VAELoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "加载VAE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"11": {
|
||||||
|
"inputs": {
|
||||||
|
"clip_name1": "t5xxl_fp16.safetensors",
|
||||||
|
"clip_name2": "clip_l.safetensors",
|
||||||
|
"type": "flux",
|
||||||
|
"device": "default"
|
||||||
|
},
|
||||||
|
"class_type": "DualCLIPLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "双CLIP加载器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"12": {
|
||||||
|
"inputs": {
|
||||||
|
"unet_name": "flux1-dev.safetensors",
|
||||||
|
"weight_dtype": "default"
|
||||||
|
},
|
||||||
|
"class_type": "UNETLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "UNet加载器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"13": {
|
||||||
|
"inputs": {
|
||||||
|
"noise": [
|
||||||
|
"25",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"guider": [
|
||||||
|
"22",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"sampler": [
|
||||||
|
"16",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"sigmas": [
|
||||||
|
"17",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"latent_image": [
|
||||||
|
"27",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SamplerCustomAdvanced",
|
||||||
|
"_meta": {
|
||||||
|
"title": "自定义采样器(高级)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"16": {
|
||||||
|
"inputs": {
|
||||||
|
"sampler_name": "euler"
|
||||||
|
},
|
||||||
|
"class_type": "KSamplerSelect",
|
||||||
|
"_meta": {
|
||||||
|
"title": "K采样器选择"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"17": {
|
||||||
|
"inputs": {
|
||||||
|
"scheduler": "simple",
|
||||||
|
"steps": 25,
|
||||||
|
"denoise": 1,
|
||||||
|
"model": [
|
||||||
|
"30",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "BasicScheduler",
|
||||||
|
"_meta": {
|
||||||
|
"title": "基本调度器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"22": {
|
||||||
|
"inputs": {
|
||||||
|
"model": [
|
||||||
|
"30",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"conditioning": [
|
||||||
|
"26",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "BasicGuider",
|
||||||
|
"_meta": {
|
||||||
|
"title": "基本引导器"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"25": {
|
||||||
|
"inputs": {
|
||||||
|
"noise_seed": 142213168350829
|
||||||
|
},
|
||||||
|
"class_type": "RandomNoise",
|
||||||
|
"_meta": {
|
||||||
|
"title": "随机噪波"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"26": {
|
||||||
|
"inputs": {
|
||||||
|
"guidance": 3.5,
|
||||||
|
"conditioning": [
|
||||||
|
"6",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "FluxGuidance",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Flux引导"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"27": {
|
||||||
|
"inputs": {
|
||||||
|
"width": "{{width}}",
|
||||||
|
"height": "{{height}}",
|
||||||
|
"batch_size": "{{batch_size}}"
|
||||||
|
},
|
||||||
|
"class_type": "EmptySD3LatentImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "空Latent图像(SD3)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"30": {
|
||||||
|
"inputs": {
|
||||||
|
"max_shift": 1.1500000000000001,
|
||||||
|
"base_shift": 0.5000000000000001,
|
||||||
|
"width": 1024,
|
||||||
|
"height": 1024,
|
||||||
|
"model": [
|
||||||
|
"12",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "ModelSamplingFlux",
|
||||||
|
"_meta": {
|
||||||
|
"title": "采样算法(Flux)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"31": {
|
||||||
|
"inputs": {
|
||||||
|
"user_prompt": "作为一个AI提示词专家,请你仿照范例,根据我给出的主题,生成一条符合下列要求的提示词,来让CLIP模型可以更好地理解画面主体。注意:你需要仿照下面的示例详细分析(仅仿照写法,而不仿照任何内容),将用户的需求转化为详细的提示词。\\n 要求共六条,请严格遵守:\\n 1: 用自然语言简单句来描述画面,请避免出现过于长的,或者格式过于复杂的句子,句子中不要出现*等特殊符号。\\n 2.用英语表达。 \\n 3.直接给出prompt内容即可,不需要任何解释和说明。\\n 4. 每条prompt至少50词,不超过200词。\\n 5.避免模棱两可的说法。\\n 6.描述的最开始加入:“no text, no AI style”\\n 例如:\nCartoon-Style Nankai University Main Building,\nvividly depicted with rounded edges and pastel gradients, the iconic Gothic-Revival structure stands majestically. Crimson brick façade contrasts with golden-glowing arched windows, while whimsical cloud-shaped eaves drip melted clock details. A giant smiling sun hangs low, casting honey-golden rays through simplified pine trees, creating striped shadows dancing on marble stairs.\n\nTranslucent ghostly scholars from 1919 float near pillars holding glowing books, their outlines shimmering like liquid mercury. Oversized autumn leaves (stylized as maple-red origami) spiral around twin bell towers chiming visible musical notes. Puddles on the ground mirror upside-down building reflections rippling with calculus formulas.\n\nEnvironment:\nSurreal candy-pink sunset gradients blend into starry indigo sky above. Playful squirrels wearing tiny graduation caps scamper across emerald lawns textured like green velvet.",
|
||||||
|
"system_prompt": "{{system_prompt}}",
|
||||||
|
"enable_history": false,
|
||||||
|
"max_history": 10,
|
||||||
|
"history_json": "",
|
||||||
|
"save_path": "./chat_history.json",
|
||||||
|
"api_config": [
|
||||||
|
"32",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "DeepSeekChat",
|
||||||
|
"_meta": {
|
||||||
|
"title": "LLM Model Input Box"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"32": {
|
||||||
|
"inputs": {
|
||||||
|
"config_name": "DeepSeek官方Chat API",
|
||||||
|
"temperature": 1,
|
||||||
|
"max_tokens": 512,
|
||||||
|
"stream": false,
|
||||||
|
"api_key": ""
|
||||||
|
},
|
||||||
|
"class_type": "DeepSeekAPIConfig",
|
||||||
|
"_meta": {
|
||||||
|
"title": "LLM API Model Selector"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user