save code

This commit is contained in:
colomi
2025-07-11 22:10:56 +08:00
parent 8de064f43e
commit 4ca55230e8
6 changed files with 1758 additions and 55 deletions
-37
View File
@@ -34,40 +34,3 @@ def RequestImgAndSave(image_url):
# 1. 提交任务
#RequestImgAndSave("https://example.com/image.jpg")
with open('/home/szlc/code/ComfyUI/change_cloth/change_bak_api.json', 'r', encoding='utf-8') as file:
prompt_text = file.read()
prompt = json.loads(prompt_text)
#set the text prompt for our positive CLIPTextEncode
# prompt["6"]["inputs"]["text"] = "one girl"
#set the seed for our KSampler node
# prompt["3"]["inputs"]["seed"] = 5
# prompt["9"]["inputs"]["image"] = "cloth_long.png"
prompt["102"]["inputs"]["filename_prefix"] = "xiangsilian"
p = {"prompt": prompt}
data = json.dumps(p).encode('utf-8')
response = requests.post("http://localhost:8188/prompt", data=data)
prompt_id = response.json()["prompt_id"]
# 2. 轮询队列,直到任务完成
while True:
queue = requests.get("http://localhost:8188/queue").json()
print(queue)
if not queue["queue_running"] and not queue["queue_pending"]:
break # 队列为空,任务已完成
time.sleep(0.5) # 避免频繁请求
# 3. 从历史记录中获取结果
history = requests.get("http://localhost:8188/history").json()
print("History:", history)
outputs = history[prompt_id]["outputs"]
print("Generated outputs:", outputs)