Skip to content

Commit

Permalink
fix a bug when using custom model path
Browse files Browse the repository at this point in the history
  • Loading branch information
butaixianran committed Apr 17, 2024
1 parent 8ee7e6d commit 6e9c228
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 13 additions & 12 deletions javascript/civitai_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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");
Expand Down
10 changes: 9 additions & 1 deletion scripts/ch_lib/civitai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion scripts/ch_lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""}
Expand Down

0 comments on commit 6e9c228

Please sign in to comment.