Files
dsProject/dsLightRag/Liblib/T2.py

46 lines
1.5 KiB
Python
Raw Normal View History

2025-09-04 10:08:26 +08:00
import json
from LibLibUtil import LibLibUtil, SAMPLING_METHODS
2025-09-03 14:41:08 +08:00
2025-09-04 10:08:26 +08:00
def test_generate_image_with_obs():
"""测试generate_image_with_obs方法"""
2025-09-03 16:43:07 +08:00
liblib = LibLibUtil()
2025-09-04 10:08:26 +08:00
print("===== 测试 generate_image_with_obs 方法 =====")
# 加载配置文件
with open('config.json', 'r', encoding='utf-8') as f:
config = json.load(f)
# 使用第一个模型的配置
first_model = config['models'][0]
# 设置生图参数
template_uuid = first_model["template_uuid"]
generate_params = {
"prompt": first_model["prompt"],
"negative_prompt": first_model["negative_prompt"],
"steps": first_model["steps"],
"width": first_model["width"],
"height": first_model["height"],
"cfg_scale": first_model["cfgScale"],
"sampler_name": first_model["sampler"],
"sampler_index": SAMPLING_METHODS[first_model["sampler"]],
"seed": first_model["seed"]
}
print(f"使用模型: {first_model['name']}")
print(f"模板UUID: {template_uuid}")
# 使用新的generate_image_with_obs方法
file_url = liblib.generate_image_with_obs(template_uuid, generate_params)
if file_url:
print(f"✅ 生图任务完成OBS地址: {file_url}")
return file_url
2025-09-03 14:41:08 +08:00
else:
2025-09-04 10:08:26 +08:00
print("❌ 生图任务失败")
return None
if __name__ == '__main__':
# 测试新的方法
test_generate_image_with_obs()