From 6e9c228820d1ef401ed967bd21c2b1fd8229e521 Mon Sep 17 00:00:00 2001 From: butaixianran Date: Wed, 17 Apr 2024 14:39:38 +0800 Subject: [PATCH] fix a bug when using custom model path --- README.md | 5 ++++- javascript/civitai_helper.js | 25 +++++++++++++------------ scripts/ch_lib/civitai.py | 10 +++++++++- scripts/ch_lib/util.py | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index da910d1a..6949484f 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,10 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl -# Change Log3 +# Change Log +## v1.10.4 +* Fix a bug about model path parsing when using custom model folder + ## v1.10.2 * Bring back this addon's green refresh button to SD webui v1.8.x diff --git a/javascript/civitai_helper.js b/javascript/civitai_helper.js index 6152a8d6..fd37a2c6 100644 --- a/javascript/civitai_helper.js +++ b/javascript/civitai_helper.js @@ -1166,6 +1166,7 @@ onUiLoaded(() => { let sd_version = ch_sd_version(); console.log(`sd version is: ${sd_version}`); if (compareVersions(sd_version, "1.8.0") >= 0){ + console.log("get sd version v1.8.0+"); for (let prefix of tab_prefix_list) { toolbar_id = prefix + "_lora_controls"; @@ -1190,18 +1191,18 @@ onUiLoaded(() => { // from sd v1.8.0, we add refresh function to official's refresh button - refresh_btn.onclick = function(event){ - console.log("run refresh button on click"); - //official's refresh function - //it will send msg to python to reload card list and won't wait for that. - extraNetworksControlRefreshOnClick(event, prefix, js_model_type); - - //this will not get card list if cards need to be reloaded from python side. - //user need to click refresh button again, after card list is reloaded. - //which does not feel right by user. - //so, this addon's green refresh button is still needed. - update_card_for_civitai_with_sd1_8(); - }; + // refresh_btn.onclick = function(event){ + // console.log("run refresh button on click"); + // //official's refresh function + // //it will send msg to python to reload card list and won't wait for that. + // extraNetworksControlRefreshOnClick(event, prefix, js_model_type); + + // //this will not get card list if cards need to be reloaded from python side. + // //user need to click refresh button again, after card list is reloaded. + // //which does not feel right by user. + // //so, this addon's green refresh button is still needed. + // update_card_for_civitai_with_sd1_8(); + // }; // add refresh button to toolbar let ch_refresh = document.createElement("button"); diff --git a/scripts/ch_lib/civitai.py b/scripts/ch_lib/civitai.py index 6992f528..6fd2a2a4 100644 --- a/scripts/ch_lib/civitai.py +++ b/scripts/ch_lib/civitai.py @@ -213,6 +213,7 @@ def load_model_info_by_search_term(model_type, search_term): model_info_base = model_info_base[1:] + model_folder_name = ""; if model_type == "ti": model_folder_name = "embeddings" @@ -223,6 +224,13 @@ def load_model_info_by_search_term(model_type, search_term): else: model_folder_name = "Lora" + # model folder path could be customized + model_folder = model.folders[model_type] + + model_folder_name = os.path.basename(model_folder) + + + # check if model folder is already in search_term if model_info_base.startswith(model_folder_name): # this is sd webui v1.8.0+'s search_term @@ -237,7 +245,7 @@ def load_model_info_by_search_term(model_type, search_term): # util.printD("final model_info_base: " + model_info_base) - model_folder = model.folders[model_type] + model_info_filename = model_info_base + suffix + model.info_ext model_info_filepath = os.path.join(model_folder, model_info_filename) diff --git a/scripts/ch_lib/util.py b/scripts/ch_lib/util.py index 71b32960..094d9efb 100644 --- a/scripts/ch_lib/util.py +++ b/scripts/ch_lib/util.py @@ -6,7 +6,7 @@ import shutil -version = "1.10.3" +version = "1.10.4" 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": ""}