'commit'
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import json
|
||||||
from Liblib.LibLibGenerator import LibLibGenerator
|
from Liblib.LibLibGenerator import LibLibGenerator
|
||||||
|
from Config.Config import OBS_BUCKET, OBS_SERVER
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# - Checkpoint默认为官方模型
|
# - Checkpoint默认为官方模型
|
||||||
@@ -33,5 +35,44 @@ if __name__ == '__main__':
|
|||||||
"/api/generate/webui/text2img",
|
"/api/generate/webui/text2img",
|
||||||
generate_params
|
generate_params
|
||||||
)
|
)
|
||||||
# {'generateUuid': 'f16463d55e144214ae12d5177f8256fc'}
|
|
||||||
print(response)
|
print(f"API响应: {json.dumps(response, ensure_ascii=False, indent=2)}")
|
||||||
|
|
||||||
|
if response and "generateUuid" in response:
|
||||||
|
generate_uuid = response["generateUuid"]
|
||||||
|
print("✅ 图像生成任务已成功提交!")
|
||||||
|
print(f"生成UUID: {generate_uuid}")
|
||||||
|
print("开始轮询生成状态...")
|
||||||
|
|
||||||
|
# 每2秒探测一次生成状态,直到完成
|
||||||
|
status_data = liblib.wait_for_generation_completion(
|
||||||
|
generate_uuid, interval=2
|
||||||
|
)
|
||||||
|
|
||||||
|
# 检查生成状态
|
||||||
|
if status_data and status_data.get("generateStatus") == 5:
|
||||||
|
print("🎉 图像生成完成!开始处理文件...")
|
||||||
|
|
||||||
|
# 提取图片URL
|
||||||
|
if status_data.get("images") and len(status_data["images"]) > 0:
|
||||||
|
image_url = status_data["images"][0]["imageUrl"]
|
||||||
|
|
||||||
|
# 下载并上传到OBS
|
||||||
|
obs_url = liblib.download_and_upload_to_obs(
|
||||||
|
image_url, generate_uuid
|
||||||
|
)
|
||||||
|
|
||||||
|
if obs_url:
|
||||||
|
print(f"✅ 文件处理完成,OBS地址: {obs_url}")
|
||||||
|
file_url = f"https://{OBS_BUCKET}.{OBS_SERVER}/{obs_url}"
|
||||||
|
print(f"完整OBS URL: {file_url}")
|
||||||
|
else:
|
||||||
|
print("❌ 文件上传OBS失败")
|
||||||
|
else:
|
||||||
|
print("❌ 未找到生成的图片数据")
|
||||||
|
else:
|
||||||
|
error_msg = status_data.get('message', '未知错误') if status_data else '生成状态查询失败'
|
||||||
|
print(f"❌ 图像生成失败: {error_msg}")
|
||||||
|
else:
|
||||||
|
error_msg = response.get('message', '未知错误') if response else 'API无响应'
|
||||||
|
print(f"❌ 图像生成失败: {error_msg}")
|
||||||
|
Reference in New Issue
Block a user