'commit'
This commit is contained in:
@@ -1,18 +1,45 @@
|
||||
from Config.Config import OBS_BUCKET, OBS_SERVER
|
||||
from LibLibUtil import LibLibUtil
|
||||
import json
|
||||
from LibLibUtil import LibLibUtil, SAMPLING_METHODS
|
||||
|
||||
def test_generate_image_with_obs():
|
||||
"""测试generate_image_with_obs方法"""
|
||||
liblib = LibLibUtil()
|
||||
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
|
||||
else:
|
||||
print("❌ 生图任务失败")
|
||||
return None
|
||||
|
||||
if __name__ == '__main__':
|
||||
liblib = LibLibUtil()
|
||||
print("===== 测试生成任务处理流程 =====")
|
||||
test_generate_uuid = "df9bd6e03a204542b1daaba2f17c42e6"
|
||||
|
||||
if test_generate_uuid:
|
||||
# 调用封装好的完整处理方法
|
||||
obs_url = liblib.process_generation_task(test_generate_uuid, interval=2)
|
||||
if obs_url:
|
||||
file_url = f"https://{OBS_BUCKET}.{OBS_SERVER}/{obs_url}"
|
||||
print(f"\n✅ 处理完成,OBS地址: {file_url}")
|
||||
else:
|
||||
print("\n❌ 任务处理失败")
|
||||
else:
|
||||
print("请先设置有效的生图任务UUID")
|
||||
# 测试新的方法
|
||||
test_generate_image_with_obs()
|
||||
|
Reference in New Issue
Block a user