From ab8cac229d49b8df3104b8830dfe337ecdfcfab9 Mon Sep 17 00:00:00 2001 From: butaixianran Date: Sat, 21 Oct 2023 04:57:49 +0800 Subject: [PATCH] fix a bug of removing model --- README.md | 3 +++ about_version2.md | 3 ++- scripts/ch_lib/model.py | 20 +++++++++++++++++--- scripts/ch_lib/util.py | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d04dfd7..301570b 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,9 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl # Change Log +## v1.8.3 +* fix a bug of removing model when model name has space in it. + ## v1.8.2 * fix downloading issue when connection failed * fix nsfw is not a bool issue diff --git a/about_version2.md b/about_version2.md index ca9a3ba..29dc537 100644 --- a/about_version2.md +++ b/about_version2.md @@ -18,7 +18,8 @@ And its unified canvas system: So, for Model Info Helper, I'm re-designing it into a stand alone model and workflow management system, which should work with most popular SD UI, not just for SD webui. -And I'll take down all workflow management functions so this stand alone version can be release sooner. +And I'll take down all workflow management functions so this stand alone version can be released sooner. + Since it won't be released as estimated, I have updated the old civitai helper 1.x to work with latest SD webui. diff --git a/scripts/ch_lib/model.py b/scripts/ch_lib/model.py index 85c6698..6507afe 100644 --- a/scripts/ch_lib/model.py +++ b/scripts/ch_lib/model.py @@ -122,7 +122,7 @@ def get_model_path_by_type_and_name(model_type:str, model_name:str) -> str: # get model path by model type and search_term # parameter: model_type, search_term # return: model_path -def get_model_path_by_search_term(model_type, search_term): +def get_model_path_by_search_term(model_type:str, search_term:str): util.printD(f"Search model of {search_term} in {model_type}") if model_type not in folders.keys(): util.printD("unknow model type: " + model_type) @@ -132,10 +132,24 @@ def get_model_path_by_search_term(model_type, search_term): # for ckp: search_term = subfolderpath + model name + ext + " " + hash # for ti: search_term = subfolderpath + model name + ext + " " + hash # for hyper: search_term = subfolderpath + model name + has_hash = True + if model_type == "hyper": + has_hash = False + elif search_term.endswith(".pt") or search_term.endswith(".bin") or search_term.endswith(".safetensors") or search_term.endswith(".ckpt"): + has_hash = False + + # remove hash + # model name may have multiple spaces + splited_path = search_term.split() + model_sub_path = splited_path[0] + if has_hash and len(splited_path) > 1: + model_sub_path = "" + for i in range(0, len(splited_path)-1): + model_sub_path += splited_path[i] + " " + + model_sub_path = model_sub_path.strip() - - model_sub_path = search_term.split()[0] if model_sub_path[:1] == "/": model_sub_path = model_sub_path[1:] diff --git a/scripts/ch_lib/util.py b/scripts/ch_lib/util.py index a2e6294..d85dcc4 100644 --- a/scripts/ch_lib/util.py +++ b/scripts/ch_lib/util.py @@ -6,7 +6,7 @@ import requests import shutil -version = "1.8.2" +version = "1.8.3" 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'}