dongchangxi 6 months ago
parent
commit
c76eae5d39
  1. 36
      comfyui/main.py

36
comfyui/main.py

@ -33,35 +33,20 @@ def main(pid,orderId,styleNumber):
print("弹出版本选择按钮已成功点击") print("弹出版本选择按钮已成功点击")
time.sleep(3) time.sleep(3)
# 使用XPath定位包含特定文本的div元素 # 使用XPath定位包含特定文本的div元素
target_text = "3.小鱼AI(灰度图)图片浮雕流程-V3" target_text = "深度图批处理"
button = WebDriverWait(driver, 10).until( button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, f'//div[contains(text(), "{target_text}")]')) EC.element_to_be_clickable((By.XPATH, f'//div[contains(text(), "{target_text}")]'))
) )
button.click() button.click()
print("选择版本按钮已成功点击") print("选择版本按钮已成功点击")
time.sleep(3)
#通过url上传文件 # 使用XPath定位包含特定文本的div元素
url = f"http://127.0.0.1:8188/api/upload/image" target_text = "Extra options"
imagePath = os.path.join(inputFolder, f"{pid}_{orderId}_{styleNumber}.png") button = WebDriverWait(driver, 10).until(
with open(imagePath, 'rb') as f: EC.element_to_be_clickable((By.XPATH, f'//label[contains(text(), "{target_text}")]'))
files = {'file': f} )
response = requests.post(url, files=files)
print(response.json())
time.sleep(5)
#点击上传按钮
button = driver.find_element(By.ID, 'upload-button')
button.click() button.click()
time.sleep(5)
# #
time.sleep(5) time.sleep(5)
button = driver.find_element(By.ID, 'queue-button') button = driver.find_element(By.ID, 'queue-button')
@ -189,7 +174,7 @@ if __name__ == '__main__':
orderId = 0 orderId = 0
styleNumber = 0 styleNumber = 0
downloadPath = "D:\downloadPhotos" downloadPath = "D:\downloadPhotos"
inputFolder = "C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\input" inputFolder = "c:\deep" #"C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\input"
outputFolder = "C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\output" outputFolder = "C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\output"
jsonFilePath = "C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\pysssss-workflows" jsonFilePath = "C:\StableDiffusion_xiaoyu_V3\ComfyUI-aki-v1.6-XY\ComfyUI\pysssss-workflows"
# 设置浏览器驱动路径(以Chrome为例) # 设置浏览器驱动路径(以Chrome为例)
@ -221,12 +206,12 @@ if __name__ == '__main__':
r = utils.create_redis_connection() r = utils.create_redis_connection()
while True: while True:
try: try:
if r.llen('model:badge_cartoon_test') == 0: if r.llen('model:badge_cartoon') == 0:
print('队列为空,等待10秒') print('队列为空,等待10秒')
time.sleep(10) time.sleep(10)
continue continue
info = r.lpop('model:badge_cartoon_test') info = r.lpop('model:badge_cartoon')
if info is None: if info is None:
print('队列为空,等待10秒') print('队列为空,等待10秒')
time.sleep(10) time.sleep(10)
@ -251,7 +236,6 @@ if __name__ == '__main__':
print(f"pid:{pid} orderId:{orderId} style_number:{styleNumber}") print(f"pid:{pid} orderId:{orderId} style_number:{styleNumber}")
if pid > 0 and orderId > 0 and styleNumber > 0: if pid > 0 and orderId > 0 and styleNumber > 0:
main(pid,orderId,styleNumber) main(pid,orderId,styleNumber)
break
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
print(f'JSON解析错误:{e}') print(f'JSON解析错误:{e}')
utils.notify(f'JSON解析错误:{e}') utils.notify(f'JSON解析错误:{e}')

Loading…
Cancel
Save