Small hotfixes
parent
aa3d8bfd53
commit
5ab99d589a
11
install.py
11
install.py
|
|
@ -12,9 +12,8 @@ def install_req(check_name, install_name=None):
|
||||||
if not launch.is_installed(f"{check_name}"):
|
if not launch.is_installed(f"{check_name}"):
|
||||||
launch.run_pip(f"install {install_name}", "requirements for CivitAI Browser")
|
launch.run_pip(f"install {install_name}", "requirements for CivitAI Browser")
|
||||||
|
|
||||||
install_req("send2trash")
|
install_req("send2trash==1.8.2")
|
||||||
install_req("zip_unicode", "ZipUnicode")
|
install_req("zip_unicode", "ZipUnicode==1.1.1")
|
||||||
install_req("bs4", "beautifulsoup4")
|
install_req("bs4", "beautifulsoup4==4.12.3")
|
||||||
install_req("fake_useragent")
|
install_req("packaging==23.2")
|
||||||
install_req("packaging")
|
install_req("pysocks==1.7.1")
|
||||||
install_req("pysocks")
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
send2trash==1.8.2
|
||||||
|
ZipUnicode==1.1.1
|
||||||
|
beautifulsoup4==4.12.3
|
||||||
|
packaging==23.2
|
||||||
|
pysocks==1.7.1
|
||||||
|
|
@ -19,10 +19,6 @@ from html import escape
|
||||||
from scripts.civitai_global import print, debug_print
|
from scripts.civitai_global import print, debug_print
|
||||||
import scripts.civitai_global as gl
|
import scripts.civitai_global as gl
|
||||||
import scripts.civitai_download as _download
|
import scripts.civitai_download as _download
|
||||||
try:
|
|
||||||
from fake_useragent import UserAgent
|
|
||||||
except ImportError:
|
|
||||||
print("Python module 'fake_useragent' has not been imported correctly, please try to restart or install it manually.")
|
|
||||||
|
|
||||||
gl.init()
|
gl.init()
|
||||||
|
|
||||||
|
|
@ -66,6 +62,7 @@ def contenttype_folder(content_type, desc=None, fromCheck=False, custom_folder=N
|
||||||
folder = os.path.join(extensions_dir, "stable-diffusion-webui-aesthetic-gradients", "aesthetic_embeddings")
|
folder = os.path.join(extensions_dir, "stable-diffusion-webui-aesthetic-gradients", "aesthetic_embeddings")
|
||||||
else:
|
else:
|
||||||
folder = os.path.join(custom_folder, "aesthetic_embeddings")
|
folder = os.path.join(custom_folder, "aesthetic_embeddings")
|
||||||
|
|
||||||
elif content_type == "LORA":
|
elif content_type == "LORA":
|
||||||
if cmd_opts.lora_dir and not custom_folder:
|
if cmd_opts.lora_dir and not custom_folder:
|
||||||
folder = cmd_opts.lora_dir
|
folder = cmd_opts.lora_dir
|
||||||
|
|
@ -93,7 +90,10 @@ def contenttype_folder(content_type, desc=None, fromCheck=False, custom_folder=N
|
||||||
folder = os.path.join(main_models, "VAE")
|
folder = os.path.join(main_models, "VAE")
|
||||||
|
|
||||||
elif content_type == "Controlnet":
|
elif content_type == "Controlnet":
|
||||||
folder = os.path.join(main_models, "ControlNet")
|
if cmd_opts.controlnet_dir and not custom_folder:
|
||||||
|
folder = cmd_opts.controlnet_dir
|
||||||
|
else:
|
||||||
|
folder = os.path.join(main_models, "ControlNet")
|
||||||
|
|
||||||
elif content_type == "Poses":
|
elif content_type == "Poses":
|
||||||
folder = os.path.join(main_models, "Poses")
|
folder = os.path.join(main_models, "Poses")
|
||||||
|
|
@ -1165,16 +1165,11 @@ def get_proxies():
|
||||||
return proxies, ssl
|
return proxies, ssl
|
||||||
|
|
||||||
def get_headers(referer=None, no_api=None):
|
def get_headers(referer=None, no_api=None):
|
||||||
|
|
||||||
api_key = getattr(opts, "custom_api_key", "")
|
api_key = getattr(opts, "custom_api_key", "")
|
||||||
try:
|
|
||||||
user_agent = UserAgent().chrome
|
|
||||||
except ImportError:
|
|
||||||
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
|
|
||||||
headers = {
|
headers = {
|
||||||
"Connection": "keep-alive",
|
"Connection": "keep-alive",
|
||||||
"Sec-Ch-Ua-Platform": "Windows",
|
"Sec-Ch-Ua-Platform": "Windows",
|
||||||
"User-Agent": user_agent,
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
if referer:
|
if referer:
|
||||||
|
|
|
||||||
|
|
@ -690,15 +690,14 @@ def get_models(file_path, gen_hash=None):
|
||||||
print(f"Failed to open {json_file}: {e}")
|
print(f"Failed to open {json_file}: {e}")
|
||||||
|
|
||||||
if not modelId or not modelVersionId or not sha256:
|
if not modelId or not modelVersionId or not sha256:
|
||||||
if gen_hash:
|
if not sha256 and gen_hash:
|
||||||
if not sha256:
|
sha256 = gen_sha256(file_path)
|
||||||
sha256 = gen_sha256(file_path)
|
|
||||||
|
if sha256:
|
||||||
by_hash = f"https://civitai.com/api/v1/model-versions/by-hash/{sha256}"
|
by_hash = f"https://civitai.com/api/v1/model-versions/by-hash/{sha256}"
|
||||||
else:
|
else:
|
||||||
if modelId:
|
return modelId if modelId else None
|
||||||
return modelId
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
proxies, ssl = _api.get_proxies()
|
proxies, ssl = _api.get_proxies()
|
||||||
try:
|
try:
|
||||||
if not modelId or not modelVersionId:
|
if not modelId or not modelVersionId:
|
||||||
|
|
@ -714,8 +713,8 @@ def get_models(file_path, gen_hash=None):
|
||||||
elif response.status_code == 503:
|
elif response.status_code == 503:
|
||||||
return "offline"
|
return "offline"
|
||||||
elif response.status_code == 404:
|
elif response.status_code == 404:
|
||||||
api_response = response.json()
|
modelId = "Model not found"
|
||||||
modelId = api_response.get("error", "")
|
modelVersionId = "Model not found"
|
||||||
|
|
||||||
if os.path.exists(json_file):
|
if os.path.exists(json_file):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue