v1.11.0
parent
6e9c228820
commit
b628255661
|
|
@ -245,6 +245,9 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl
|
||||||
|
|
||||||
|
|
||||||
# Change Log
|
# Change Log
|
||||||
|
## v1.11.0
|
||||||
|
* Added a new checkbox option "When checking model's new version, checking new version existing under all model folders". When this value is False, it gonna only checking that model's current folder.
|
||||||
|
|
||||||
## v1.10.4
|
## v1.10.4
|
||||||
* Fix a bug about model path parsing when using custom model folder
|
* Fix a bug about model path parsing when using custom model folder
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,10 +423,11 @@ def get_preview_image_by_model_path(model_path:str, max_size_preview, skip_nsfw_
|
||||||
|
|
||||||
# search local model by version id in 1 folder, no subfolder
|
# search local model by version id in 1 folder, no subfolder
|
||||||
# return - model_info
|
# return - model_info
|
||||||
def search_local_model_info_by_version_id(folder:str, version_id:int) -> dict:
|
def search_local_model_info_by_version_id(folder:str, version_id:int, walk:bool=False) -> dict:
|
||||||
util.printD("Searching local model by version id")
|
util.printD("Searching local model by version id")
|
||||||
util.printD("folder: " + folder)
|
util.printD("folder: " + folder)
|
||||||
util.printD("version_id: " + str(version_id))
|
util.printD("version_id: " + str(version_id))
|
||||||
|
util.printD("walk: " + str(walk))
|
||||||
|
|
||||||
if not folder:
|
if not folder:
|
||||||
util.printD("folder is none")
|
util.printD("folder is none")
|
||||||
|
|
@ -441,6 +442,42 @@ def search_local_model_info_by_version_id(folder:str, version_id:int) -> dict:
|
||||||
return
|
return
|
||||||
|
|
||||||
# search civitai model info file
|
# search civitai model info file
|
||||||
|
# walk from top
|
||||||
|
if walk:
|
||||||
|
util.printD(f"Searching model version id {version_id} by walking in: {folder}")
|
||||||
|
for root, dirs, files in os.walk(folder, followlinks=True):
|
||||||
|
for filename in files:
|
||||||
|
# check ext
|
||||||
|
base, ext = os.path.splitext(filename)
|
||||||
|
if ext == model.info_ext:
|
||||||
|
# find info file
|
||||||
|
if len(base) < 9:
|
||||||
|
# not a civitai info file
|
||||||
|
continue
|
||||||
|
|
||||||
|
if base[-8:] == suffix:
|
||||||
|
# find a civitai info file
|
||||||
|
path = os.path.join(root, filename)
|
||||||
|
model_info = model.load_model_info(path)
|
||||||
|
if not model_info:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if "id" not in model_info.keys():
|
||||||
|
continue
|
||||||
|
|
||||||
|
id = model_info["id"]
|
||||||
|
if not id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# util.printD(f"Compare version id, src: {id}, target:{version_id}")
|
||||||
|
if str(id) == str(version_id):
|
||||||
|
# find the one
|
||||||
|
util.printD(f"Found model: {path}")
|
||||||
|
return model_info
|
||||||
|
|
||||||
|
# only check current path
|
||||||
|
else:
|
||||||
|
util.printD(f"Searching model version id {version_id} under: {folder}")
|
||||||
for filename in os.listdir(folder):
|
for filename in os.listdir(folder):
|
||||||
# check ext
|
# check ext
|
||||||
base, ext = os.path.splitext(filename)
|
base, ext = os.path.splitext(filename)
|
||||||
|
|
@ -596,7 +633,7 @@ def check_model_new_version_by_path(model_path:str, delay:float=1) -> tuple:
|
||||||
# check model's new version
|
# check model's new version
|
||||||
# parameter: delay - float, how many seconds to delay between each request to civitai
|
# parameter: delay - float, how many seconds to delay between each request to civitai
|
||||||
# return: new_versions - a list for all new versions, each one is (model_path, model_id, model_name, new_verion_id, new_version_name, description, download_url, img_url)
|
# return: new_versions - a list for all new versions, each one is (model_path, model_id, model_name, new_verion_id, new_version_name, description, download_url, img_url)
|
||||||
def check_models_new_version_by_model_types(model_types:list, delay:float=1) -> list:
|
def check_models_new_version_by_model_types(model_types:list, delay:float=1, check_new_ver_exist_in_all_folder:bool=False) -> list:
|
||||||
util.printD("Checking models' new version")
|
util.printD("Checking models' new version")
|
||||||
|
|
||||||
if not model_types:
|
if not model_types:
|
||||||
|
|
@ -654,7 +691,12 @@ def check_models_new_version_by_model_types(model_types:list, delay:float=1) ->
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# search this new version id to check if this model is already downloaded
|
# search this new version id to check if this model is already downloaded
|
||||||
target_model_info = search_local_model_info_by_version_id(root, current_version_id)
|
if check_new_ver_exist_in_all_folder:
|
||||||
|
# walk from top folder for this model type
|
||||||
|
target_model_info = search_local_model_info_by_version_id(model_folder, current_version_id, check_new_ver_exist_in_all_folder)
|
||||||
|
else:
|
||||||
|
# only check current folder
|
||||||
|
target_model_info = search_local_model_info_by_version_id(root, current_version_id, check_new_ver_exist_in_all_folder)
|
||||||
if target_model_info:
|
if target_model_info:
|
||||||
util.printD("New version is already existed")
|
util.printD("New version is already existed")
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ def dl_model_new_version(msg, max_size_preview, skip_nsfw_preview):
|
||||||
|
|
||||||
# no need to check when downloading new version, since checking new version is already checked
|
# no need to check when downloading new version, since checking new version is already checked
|
||||||
# check if this model is already existed
|
# check if this model is already existed
|
||||||
# r = civitai.search_local_model_info_by_version_id(model_folder, version_id)
|
# r = civitai.search_local_model_info_by_version_id(model_folder, version_id, False)
|
||||||
# if r:
|
# if r:
|
||||||
# output = "This model version is already existed"
|
# output = "This model version is already existed"
|
||||||
# util.printD(output)
|
# util.printD(output)
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ def get_model_info_by_input(model_type, model_name, model_url_or_id, max_size_pr
|
||||||
|
|
||||||
|
|
||||||
# check models' new version and output to UI as markdown doc
|
# check models' new version and output to UI as markdown doc
|
||||||
def check_models_new_version_to_md(model_types:list) -> str:
|
def check_models_new_version_to_md(model_types:list, check_new_ver_exist_in_all_folder:bool) -> str:
|
||||||
new_versions = civitai.check_models_new_version_by_model_types(model_types, 1)
|
new_versions = civitai.check_models_new_version_by_model_types(model_types, 1, check_new_ver_exist_in_all_folder)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
output = ""
|
output = ""
|
||||||
|
|
@ -454,7 +454,7 @@ def dl_model_by_input(model_info:dict, model_type:str, subfolder_str:str, versio
|
||||||
|
|
||||||
|
|
||||||
# check if this model is already existed
|
# check if this model is already existed
|
||||||
r = civitai.search_local_model_info_by_version_id(model_folder, version_id)
|
r = civitai.search_local_model_info_by_version_id(model_folder, version_id, False)
|
||||||
if r:
|
if r:
|
||||||
output = "This model version is already existed"
|
output = "This model version is already existed"
|
||||||
util.printD(output)
|
util.printD(output)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ path = os.path.join(scripts.basedir(), name)
|
||||||
data = {
|
data = {
|
||||||
"model":{
|
"model":{
|
||||||
"max_size_preview": True,
|
"max_size_preview": True,
|
||||||
"skip_nsfw_preview": False
|
"skip_nsfw_preview": False,
|
||||||
|
"check_new_ver_exist_in_all_folder": False
|
||||||
},
|
},
|
||||||
"general":{
|
"general":{
|
||||||
"open_url_with_js": True,
|
"open_url_with_js": True,
|
||||||
|
|
@ -75,16 +76,20 @@ def load():
|
||||||
if "proxy" not in data["general"].keys():
|
if "proxy" not in data["general"].keys():
|
||||||
data["general"]["proxy"] = ""
|
data["general"]["proxy"] = ""
|
||||||
|
|
||||||
|
if "check_new_ver_exist_in_all_folder" not in data["model"].keys():
|
||||||
|
data["general"]["check_new_ver_exist_in_all_folder"] = False
|
||||||
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# save setting from parameter
|
# save setting from parameter
|
||||||
def save_from_input(max_size_preview, skip_nsfw_preview, open_url_with_js, proxy):
|
def save_from_input(max_size_preview, skip_nsfw_preview, open_url_with_js, proxy, check_new_ver_exist_in_all_folder):
|
||||||
global data
|
global data
|
||||||
data = {
|
data = {
|
||||||
"model":{
|
"model":{
|
||||||
"max_size_preview": max_size_preview,
|
"max_size_preview": max_size_preview,
|
||||||
"skip_nsfw_preview": skip_nsfw_preview
|
"skip_nsfw_preview": skip_nsfw_preview,
|
||||||
|
"check_new_ver_exist_in_all_folder": check_new_ver_exist_in_all_folder
|
||||||
},
|
},
|
||||||
"general":{
|
"general":{
|
||||||
"open_url_with_js": open_url_with_js,
|
"open_url_with_js": open_url_with_js,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import requests
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
version = "1.10.4"
|
version = "1.11.0"
|
||||||
|
|
||||||
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',
|
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',
|
||||||
"Authorization": ""}
|
"Authorization": ""}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ def on_ui_settings():
|
||||||
shared.opts.add_option("ch_max_size_preview", shared.OptionInfo(True, "Download Max Size Preview", gr.Checkbox, {"interactive": True}, section=ch_section))
|
shared.opts.add_option("ch_max_size_preview", shared.OptionInfo(True, "Download Max Size Preview", gr.Checkbox, {"interactive": True}, section=ch_section))
|
||||||
shared.opts.add_option("ch_skip_nsfw_preview", shared.OptionInfo(False, "Skip NSFW Preview Images", gr.Checkbox, {"interactive": True}, section=ch_section))
|
shared.opts.add_option("ch_skip_nsfw_preview", shared.OptionInfo(False, "Skip NSFW Preview Images", gr.Checkbox, {"interactive": True}, section=ch_section))
|
||||||
shared.opts.add_option("ch_open_url_with_js", shared.OptionInfo(True, "Open Url At Client Side", gr.Checkbox, {"interactive": True}, section=ch_section))
|
shared.opts.add_option("ch_open_url_with_js", shared.OptionInfo(True, "Open Url At Client Side", gr.Checkbox, {"interactive": True}, section=ch_section))
|
||||||
|
shared.opts.add_option("ch_check_new_ver_exist_in_all_folder", shared.OptionInfo(True, "When checking new model version, check new version existing in all model folders", gr.Checkbox, {"interactive": True}, section=ch_section))
|
||||||
shared.opts.add_option("ch_proxy", shared.OptionInfo("", "Civitai Helper Proxy", gr.Textbox, {"interactive": True, "lines":1, "info":"format: socks5h://127.0.0.1:port"}, section=ch_section))
|
shared.opts.add_option("ch_proxy", shared.OptionInfo("", "Civitai Helper Proxy", gr.Textbox, {"interactive": True, "lines":1, "info":"format: socks5h://127.0.0.1:port"}, section=ch_section))
|
||||||
shared.opts.add_option("ch_civiai_api_key", shared.OptionInfo("", "Civitai API Key", gr.Textbox, {"interactive": True, "lines":1, "info":"check doc:https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/tree/master#api-key"}, section=ch_section))
|
shared.opts.add_option("ch_civiai_api_key", shared.OptionInfo("", "Civitai API Key", gr.Textbox, {"interactive": True, "lines":1, "info":"check doc:https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/tree/master#api-key"}, section=ch_section))
|
||||||
|
|
||||||
|
|
@ -68,6 +69,7 @@ def on_ui_tabs():
|
||||||
max_size_preview = shared.opts.data.get("ch_max_size_preview", True)
|
max_size_preview = shared.opts.data.get("ch_max_size_preview", True)
|
||||||
skip_nsfw_preview = shared.opts.data.get("ch_skip_nsfw_preview", False)
|
skip_nsfw_preview = shared.opts.data.get("ch_skip_nsfw_preview", False)
|
||||||
open_url_with_js = shared.opts.data.get("ch_open_url_with_js", True)
|
open_url_with_js = shared.opts.data.get("ch_open_url_with_js", True)
|
||||||
|
check_new_ver_exist_in_all_folder = shared.opts.data.get("ch_check_new_ver_exist_in_all_folder", False)
|
||||||
proxy = shared.opts.data.get("ch_proxy", "")
|
proxy = shared.opts.data.get("ch_proxy", "")
|
||||||
civitai_api_key = shared.opts.data.get("ch_civiai_api_key", "")
|
civitai_api_key = shared.opts.data.get("ch_civiai_api_key", "")
|
||||||
|
|
||||||
|
|
@ -75,6 +77,7 @@ def on_ui_tabs():
|
||||||
util.printD("max_size_preview: " + str(max_size_preview))
|
util.printD("max_size_preview: " + str(max_size_preview))
|
||||||
util.printD("skip_nsfw_preview: " + str(skip_nsfw_preview))
|
util.printD("skip_nsfw_preview: " + str(skip_nsfw_preview))
|
||||||
util.printD("open_url_with_js: " + str(open_url_with_js))
|
util.printD("open_url_with_js: " + str(open_url_with_js))
|
||||||
|
util.printD("check_new_ver_exist_in_all_folder: " + str(check_new_ver_exist_in_all_folder))
|
||||||
util.printD("proxy: " + str(proxy))
|
util.printD("proxy: " + str(proxy))
|
||||||
|
|
||||||
# set civitai_api_key
|
# set civitai_api_key
|
||||||
|
|
@ -104,8 +107,8 @@ def on_ui_tabs():
|
||||||
def dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb):
|
def dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb):
|
||||||
return model_action_civitai.dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview, skip_nsfw_preview)
|
return model_action_civitai.dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview, skip_nsfw_preview)
|
||||||
|
|
||||||
def check_models_new_version_to_md(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb):
|
def check_models_new_version_to_md(model_types):
|
||||||
return model_action_civitai.check_models_new_version_to_md(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview, skip_nsfw_preview)
|
return model_action_civitai.check_models_new_version_to_md(model_types, check_new_ver_exist_in_all_folder)
|
||||||
|
|
||||||
def open_model_url(js_msg_txtbox):
|
def open_model_url(js_msg_txtbox):
|
||||||
return js_action_civitai.open_model_url(js_msg_txtbox, open_url_with_js)
|
return js_action_civitai.open_model_url(js_msg_txtbox, open_url_with_js)
|
||||||
|
|
@ -229,7 +232,7 @@ def on_ui_tabs():
|
||||||
dl_civitai_model_by_id_btn.click(dl_model_by_input, inputs=[dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb], outputs=dl_log_md)
|
dl_civitai_model_by_id_btn.click(dl_model_by_input, inputs=[dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb], outputs=dl_log_md)
|
||||||
|
|
||||||
# Check models' new version
|
# Check models' new version
|
||||||
check_models_new_version_btn.click(model_action_civitai.check_models_new_version_to_md, inputs=model_types_ckbg, outputs=check_models_new_version_log_md)
|
check_models_new_version_btn.click(check_models_new_version_to_md, inputs=model_types_ckbg, outputs=check_models_new_version_log_md)
|
||||||
|
|
||||||
# js action
|
# js action
|
||||||
js_open_url_btn.click(open_model_url, inputs=[js_msg_txtbox], outputs=py_msg_txtbox)
|
js_open_url_btn.click(open_model_url, inputs=[js_msg_txtbox], outputs=py_msg_txtbox)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue