libdata.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import modules.scripts as scripts
  2. from modules import shared as ws
  3. import os
  4. from enum import Enum
  5. source_filename = "libdata"
  6. # root path
  7. root_path = os.getcwd()
  8. script_path = os.sep.join(__file__.split(os.sep)[0:-5]) if root_path is None else root_path
  9. models_path = os.path.join(script_path, "models")
  10. dreambooth_models_path = os.path.join(models_path, "dreambooth")
  11. try:
  12. dreambooth_models_path = ws.cmd_opts.dreambooth_models_path or dreambooth_models_path
  13. except:
  14. pass
  15. DEFAULT_KEY = "##default##"
  16. # extension path
  17. extension_path = scripts.basedir()
  18. setting_file_name = "setting.json"
  19. dreambooth_setting_file_name = "db_config.json"
  20. up_symbol = '\u2b06\ufe0f' #⬆️
  21. down_symbol ='\u2b07\ufe0f' #⬇️
  22. delete_symbol = '\u274c' #❌
  23. add_symbol = '\u2795' #➕
  24. paste_symbol ='\U0001F4CB\u200B' #📋
  25. copy_symbol = '\U0001F4DA' #📚
  26. paste_append_symbol = '\U0001F4DD' #📝
  27. refresh_symbol = '\U0001f504' # 🔄
  28. folders = {
  29. "ti": os.path.join(root_path, "embeddings"),
  30. "hyper": os.path.join(root_path, "models", "hypernetworks"),
  31. "ckp": os.path.join(root_path, "models", "Stable-diffusion"),
  32. "lora": os.path.join(root_path, "models", "Lora"),
  33. "lyco": os.path.join(root_path, "models", "LyCORIS"),
  34. }
  35. exts = (".bin", ".pt", ".safetensors", ".ckpt")
  36. info_ext = [".json", ".info", ".civitai.info"]
  37. vae_suffix = ".vae"
  38. http_state_codes = {
  39. 100 : "Continue",101 : "Switching Protocols",102 : "Processing",103 : "Early Hints",
  40. 110 : "Response is Stale",111 : "Revalidation Failed",112 : "Disconnected Operation",113 : "Heuristic Expiration",
  41. 199 : "Miscellaneous Warning",
  42. 200 : "OK",201 : "Created",202 : "Accepted",203 : "Non-Authoritative Information",204 : "No Content",205 : "Reset Content",206 : "Partial Content",207 : "Multi-Status",208 : "Already Reported",
  43. 214 : "Transformation Applied",226 : "IM Used",299 : "Miscellaneous Persistent Warning",
  44. 300 : "Multiple Choices",301 : "Moved Permanently",302 : "Found",303 : "See Other",304 : "Not Modified",305 : "Use Proxy",306 : "Switch Proxy",307 : "Temporary Redirect",308 : "Permanent Redirect",
  45. 400 : "Bad Request",401 : "Unauthorized",402 : "Payment Required",403 : "Forbidden",404 : "Not Found",405 : "Method Not Allowed",406 : "Not Acceptable",407 : "Proxy Authentication Required",408 : "Request Timeout",409 : "Conflict",
  46. 410 : "Gone",411 : "Length Required",412 : "Precondition Failed",413 : "Request Entity Too Large",414 : "Request-URI Too Long",415 : "Unsupported Media Type",416 : "Requested Range Not Satisfiable",417 : "Expectation Failed",418 : "I'm a teapot",419 : "Page Expired",
  47. 420 : "Method Failure/Enhance Your Calm",421 : "Misdirected Request",422 : "Unprocessable Entity",423 : "Locked",424 : "Failed Dependency",425 : "Too Early",426 : "Upgrade Required",428 : "Precondition Required",429 : "Too Many Requests",
  48. 430 : "Request Header Fields Too Large",431 : "Request Header Fields Too Large",
  49. 440 : "Login Time-out",444 : "No Response",449 : "Retry With",450 : "Blocked by Windows Parental Controls",451 : "Unavailable For Legal Reasons/Redirect",
  50. 460 : "Client closed the connection with the load balancer before the idle timeout period elapsed",463 : "The load balancer received an X-Forwarded-For request header with more than 30 IP addresses",
  51. 494 : "Request Header Too Large",495 : "SSL Certificate Error",496 : "SSL Certificate Required",497 : "HTTP Request Sent to HTTPS Port",498 : "Invalid Token",499 : "Client Closed Request/Token Required",
  52. 500 : "Internal Server Error",501 : "Not Implemented",502 : "Bad Gateway",503 : "Service Unavailable",504 : "Gateway Timeout",505 : "HTTP Version Not Supported",506 : "Variant Also Negotiates",507 : "Insufficient Storage",508 : "Loop Detected",509 : "Bandwidth Limit Exceeded",
  53. 510 : "Not Extended",511 : "Network Authentication Required",520 : "Web Server Returned an Unknown Error",521 : "Web Server Is Down",522 : "Connection Timed Out",523 : "Origin Is Unreachable",524 : "A Timeout Occurred",525 : "SSL Handshake Failed",526 : "Invalid SSL Certificate",527 : "Railgun Error",529 : "Site is overloaded",
  54. 530 : "Site is frozen",561 : "Unauthorized",598 : "(Informal convention) Network read timeout error",599 : "Network Connect Timeout Error",
  55. }
  56. def_headers = {'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'}
  57. proxies = None
  58. class SortOrder(Enum):
  59. ASC = 'Ascending'
  60. DESC = 'Descending'
  61. # action list
  62. ajax_actions = ( "open_url",
  63. "add_selected_trigger_word",
  64. "show_trigger_words",
  65. "update_trigger_words",
  66. "cors_request"
  67. )
  68. py_actions = ("open_url")
  69. model_type_dict = {
  70. "Checkpoint": "ckp",
  71. "TextualInversion": "ti",
  72. "Hypernetwork": "hyper",
  73. "LORA": "lora",
  74. "LoCon": "lora",
  75. "LyCORIS": "lyco",
  76. }
  77. model_type_names = {
  78. "ckp": "Checkpoint",
  79. "ti": "TextualInversion",
  80. "hyper": "Hypernetwork",
  81. "lora": "LORA",
  82. "lyco": "LyCORIS",
  83. }
  84. civitai_apis = {
  85. "modelPage":"https://civitai.com/models/",
  86. "modelId": "https://civitai.com/api/v1/models/",
  87. "modelVersionId": "https://civitai.com/api/v1/model-versions/",
  88. "hash": "https://civitai.com/api/v1/model-versions/by-hash/"
  89. }
  90. dataframe_empty_row = ["","","",""]
  91. def noop_func():
  92. return