find_keys.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import sys
  2. import os
  3. sys.path.append(os.path.join(os.path.dirname(__file__), '../tools/local/liblibai_controlnet'))
  4. from liblibai_client import LibLibAIClient
  5. client = LibLibAIClient()
  6. TEMPLATE_UUID = "e10adc3949ba59abbe56e057f20f883e"
  7. DEFAULT_CHECKPOINT_ID = "0ea388c7eb854be3ba3c6f65aac6bfd3"
  8. import requests
  9. def test_key(preprocessor, key_name):
  10. payload = {
  11. "templateUuid": TEMPLATE_UUID,
  12. "generateParams": {
  13. "checkPointId": DEFAULT_CHECKPOINT_ID,
  14. "prompt": "cat",
  15. "width": 512,
  16. "height": 512,
  17. "imgCount": 1,
  18. "controlNet": [{
  19. "unitOrder": 1,
  20. "sourceImage": "https://liblibai-airship-temp.oss-cn-beijing.aliyuncs.com/aliyun-cn-prod/73ed6ae42b144d21bf566e05b5a6c138.png",
  21. "width": 512,
  22. "height": 512,
  23. "preprocessor": preprocessor,
  24. "model": "b6806516962f4e1599a93ac4483c3d23", # Random UUID
  25. "controlWeight": 1.0,
  26. "startingControlStep": 0.0,
  27. "endingControlStep": 1.0,
  28. "pixelPerfect": 1,
  29. "controlMode": 0,
  30. "annotationParameters": {
  31. key_name: {
  32. "preprocessorResolution": 512
  33. }
  34. }
  35. }]
  36. }
  37. }
  38. url = client.generate_auth_url("/api/generate/webui/text2img")
  39. resp = requests.post(url, json=payload).json()
  40. if resp.get("code") == 100050:
  41. return False
  42. return True
  43. print("=== SoftEdge (preprocessor 5) ===")
  44. for k in ["softedge", "hed", "pidinet", "softedge_hed", "softedge_pidinet", "hedSafe", "hedBase"]:
  45. if test_key(5, k):
  46. print(f"FOUND SOFTEDGE KEY: {k}")
  47. break
  48. print("=== Lineart (preprocessor 32) ===")
  49. for k in ["lineart", "lineartStandard", "lineart_standard", "lineart_anime", "lineartAnime", "lineartRealistic", "lineartBase"]:
  50. if test_key(32, k):
  51. print(f"FOUND LINEART KEY: {k}")
  52. break