2025-09-04 08:17:22 +08:00
|
|
|
import json
|
2025-09-04 08:49:37 +08:00
|
|
|
|
|
|
|
from Liblib.LibLibUtil import SAMPLING_METHODS
|
2025-09-03 16:43:07 +08:00
|
|
|
from PuLIDGenerator import PuLIDGenerator
|
2025-09-03 15:32:20 +08:00
|
|
|
|
2025-09-04 08:17:22 +08:00
|
|
|
# 加载配置文件
|
|
|
|
with open('config.json', 'r', encoding='utf-8') as f:
|
|
|
|
config = json.load(f)
|
|
|
|
|
2025-09-03 15:43:10 +08:00
|
|
|
if __name__ == "__main__":
|
2025-09-04 08:17:22 +08:00
|
|
|
# 获取第一个模型的配置
|
2025-09-04 08:49:37 +08:00
|
|
|
model_config = config["models"][1]
|
2025-09-04 08:50:35 +08:00
|
|
|
# 完成的例子
|
|
|
|
# https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/LibLib/484eba61d6e74f8ea0cb3d8ff2d14341.jpg
|
2025-09-04 08:49:37 +08:00
|
|
|
|
|
|
|
# 通过枚举转换
|
|
|
|
print(f'使用采样方法: {model_config["sampler"]}')
|
|
|
|
model_config["sampler"] = SAMPLING_METHODS[model_config["sampler"]]
|
2025-09-04 08:17:22 +08:00
|
|
|
# 创建生成器实例
|
2025-09-03 16:43:07 +08:00
|
|
|
generator = PuLIDGenerator()
|
2025-09-04 08:49:37 +08:00
|
|
|
|
2025-09-04 08:17:22 +08:00
|
|
|
# 使用配置参数
|
2025-09-04 07:53:00 +08:00
|
|
|
generator.set_default_params(
|
2025-09-04 08:17:22 +08:00
|
|
|
template_uuid=model_config["template_uuid"],
|
|
|
|
steps=model_config["steps"],
|
|
|
|
width=model_config["width"],
|
|
|
|
height=model_config["height"]
|
2025-09-04 07:53:00 +08:00
|
|
|
)
|
2025-09-04 08:49:37 +08:00
|
|
|
|
2025-09-03 15:43:10 +08:00
|
|
|
# 生成图像
|
2025-09-03 16:43:07 +08:00
|
|
|
obs_url = generator.generate_image(
|
2025-09-04 08:17:22 +08:00
|
|
|
prompt=model_config["prompt"],
|
|
|
|
reference_image_url=model_config["reference_image_url"],
|
|
|
|
control_weight=model_config["control_weight"]
|
2025-09-03 16:43:07 +08:00
|
|
|
)
|
2025-09-04 08:49:37 +08:00
|
|
|
|
2025-09-03 16:43:07 +08:00
|
|
|
if obs_url:
|
|
|
|
print(f"最终OBS地址: {obs_url}")
|