From 4f199fc9f72324f4cfadf09f4cda4223e69634df Mon Sep 17 00:00:00 2001 From: BlafKing <9644716+BlafKing@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:01:40 +0200 Subject: [PATCH] Update to v1.14.5 --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 ++--- .github/ISSUE_TEMPLATE/config.yml | 4 +-- README.md | 11 ++++++-- javascript/civitai-html.js | 37 --------------------------- scripts/civitai_api.py | 37 +++++++++++++++++---------- scripts/civitai_gui.py | 20 +++------------ 6 files changed, 41 insertions(+), 74 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ab78359..d55765a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -19,7 +19,7 @@ body: id: steps attributes: label: Steps to reproduce the problem. - description: Please provide me with precise step by step instructions on how to reproduce the bug. + description: Precise step by step instructions on how to reproduce the bug. value: | 1. Go to .... 2. Press .... @@ -49,7 +49,7 @@ body: id: logs attributes: label: Console logs - description: Please provide **full** cmd/terminal logs from the moment you started UI to the end of it, after your bug happened. If it's very long, provide a link to pastebin or similar service. + description: Please share the complete cmd/terminal logs from the time the error occurred, ensuring you include all associated error messages. render: Shell validations: required: true @@ -57,4 +57,4 @@ body: id: misc attributes: label: Additional information - description: Please provide me with any relevant additional info or context. + description: Please provide any relevant additional info or context. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index d332ab6..95d6450 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ -blank_issues_enabled: true +blank_issues_enabled: false contact_links: - name: "🌟 Feature Request" url: "https://github.com/BlafKing/sd-civitai-browser-plus/discussions/new?category=ideas" about: "Feature requests are handled in the Discussions tab under 'Ideas'." - - name: "❓ Questions" + - name: "❓ Question" url: "https://github.com/BlafKing/sd-civitai-browser-plus/discussions/new?category=q-a" about: "If you have questions, please ask them in the Discussions tab under 'Q&A'." diff --git a/README.md b/README.md index f023e3b..16a976d 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,18 @@ https://github.com/BlafKing/sd-civitai-browser/assets/9644716/ea873c3e-a7e4-44a8 # Changelog 📋 +

v1.14.5

+ +* Feature: Base Model filter now impacts search results. +* Feature: Ability to input model URL into search bar to find corresponding model. +* Bug fix: Adetailer models now get placed in the correct folder + +---

v1.14.4

* Bug fix: Page slider broke the Next Page button when loaded from "Update Models". -* Bug fix: Save settings as default inserted broken .json data. -* Bug fix: Triggering "Scan for available updates" resulted in an error. +* Bug fix: "Save settings as default" button inserted broken .json data. +* Bug fix: Triggering "Scan for available updates" twice resulted in an error. ---

v1.14.3

diff --git a/javascript/civitai-html.js b/javascript/civitai-html.js index 09c150e..771d92d 100644 --- a/javascript/civitai-html.js +++ b/javascript/civitai-html.js @@ -58,43 +58,6 @@ function addOrUpdateRule(styleSheet, selector, newRules) { styleSheet.insertRule(`${selector} { ${newRules} }`, styleSheet.cssRules.length); } -function filterByBaseModel(selectedBaseModels) { - if (!selectedBaseModels || selectedBaseModels.length === 0) { - document.querySelectorAll('.civmodelcard').forEach(card => { - card.style.opacity = '1'; - }); - return; - } - - if (!Array.isArray(selectedBaseModels)) { - selectedBaseModels = [selectedBaseModels]; - } - - document.querySelectorAll('.civmodelcard').forEach(card => { - const cardBaseModel = card.getAttribute('base-model'); - let shouldDisplay = false; - - for (let i = 0; i < selectedBaseModels.length; i++) { - if (cardBaseModel === selectedBaseModels[i]) { - shouldDisplay = true; - break; - } - - if (selectedBaseModels[i] === "SD 2.0" && (cardBaseModel === "SD 2.0" || cardBaseModel === "SD 2.0 768")) { - shouldDisplay = true; - break; - } - - if (selectedBaseModels[i] === "SD 2.1" && ["SD 2.1", "SD 2.1 768", "SD 2.1 Unclip"].includes(cardBaseModel)) { - shouldDisplay = true; - break; - } - } - - card.style.opacity = shouldDisplay ? '1' : '0.1'; - }); -} - function updateCard(modelNameWithSuffix) { const lastDotIndex = modelNameWithSuffix.lastIndexOf('.'); const modelName = modelNameWithSuffix.slice(0, lastDotIndex); diff --git a/scripts/civitai_api.py b/scripts/civitai_api.py index 1fa4996..09acd77 100644 --- a/scripts/civitai_api.py +++ b/scripts/civitai_api.py @@ -116,7 +116,10 @@ def contenttype_folder(content_type, desc=None, fromCheck=False): folder = os.path.join(models_path,"Workflows") elif content_type == "Other": - folder = os.path.join(models_path,"Other") + if "ADETAILER" in desc: + folder = os.path.join(models_path,"adetailer") + else: + folder = os.path.join(models_path,"Other") elif content_type == "Wildcards": folder = os.path.join(extensions_dir, "UnivAICharGen", "wildcards") @@ -125,7 +128,7 @@ def contenttype_folder(content_type, desc=None, fromCheck=False): return folder -def api_to_data(content_type, sort_type, period_type, use_search_term, current_page, search_term=None, timeOut=None, isNext=None): +def api_to_data(content_type, sort_type, period_type, use_search_term, current_page, base_filter, search_term=None, timeOut=None, isNext=None): if current_page in [0, None, ""]: current_page = 1 if search_term != gl.previous_search_term or gl.tile_count != gl.previous_tile_count or gl.inputs_changed or gl.contentChange: @@ -148,7 +151,7 @@ def api_to_data(content_type, sort_type, period_type, use_search_term, current_p query = {'sort': sort_type, 'period': period_type} types_query_str = "" - + if content_type: types_query_str = "".join([f"&types={type}" for type in content_type]) @@ -158,12 +161,20 @@ def api_to_data(content_type, sort_type, period_type, use_search_term, current_p query_str += types_query_str if use_search_term != "None" and search_term: - if use_search_term == "User name": + if "civitai.com" in search_term: + match = re.search(r'models/(\d+)', search_term) + model_number = match.group(1) + query_str = f"&ids={urllib.parse.quote(model_number)}" + elif use_search_term == "User name": query_str += f"&username={urllib.parse.quote(search_term)}" elif use_search_term == "Tag": query_str += f"&tag={urllib.parse.quote(search_term)}" else: query_str += f"&query={urllib.parse.quote(search_term)}" + + if base_filter: + for base in base_filter: + query_str += f"&baseModels={urllib.parse.quote(base)}" full_url = f"{api_url}&{query_str}" @@ -289,10 +300,10 @@ def model_list_html(json_data, model_dict): HTML += '' return HTML -def update_prev_page(content_type, sort_type, period_type, use_search_term, search_term, current_page): - return update_next_page(content_type, sort_type, period_type, use_search_term, search_term, current_page, isNext=False) +def update_prev_page(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter): + return update_next_page(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter, isNext=False) -def update_next_page(content_type, sort_type, period_type, use_search_term, search_term, current_page, isNext=True): +def update_next_page(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter, isNext=True): use_LORA = getattr(opts, "use_LORA", False) if content_type: @@ -305,14 +316,14 @@ def update_next_page(content_type, sort_type, period_type, use_search_term, sear if gl.json_data is None or gl.json_data == "timeout": timeOut = True - return_values = update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page, timeOut, isNext) + return_values = update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter, timeOut, isNext) timeOut = False return return_values gl.pageChange = True - current_inputs = (content_type, sort_type, period_type, use_search_term, search_term, gl.tile_count) + current_inputs = (content_type, sort_type, period_type, use_search_term, search_term, gl.tile_count, base_filter) if gl.previous_inputs and current_inputs != gl.previous_inputs: gl.inputs_changed = True else: @@ -323,7 +334,7 @@ def update_next_page(content_type, sort_type, period_type, use_search_term, sear if not gl.file_scan: if gl.inputs_changed or gl.contentChange: - return_values = update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page) + return_values = update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter) return return_values if isNext: @@ -421,7 +432,7 @@ def pagecontrol(json_data): hasPrev = True return hasPrev, hasNext, current_page, total_pages -def update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page, timeOut=None, isNext=None, from_ver=False, from_installed=False): +def update_model_list(content_type, sort_type, period_type, use_search_term, search_term, current_page, base_filter, timeOut=None, isNext=None, from_ver=False, from_installed=False): use_LORA = getattr(opts, "use_LORA", False) if content_type: @@ -436,7 +447,7 @@ def update_model_list(content_type, sort_type, period_type, use_search_term, sea gl.ver_json = None if not gl.pageChange and not gl.file_scan: - current_inputs = (content_type, sort_type, period_type, use_search_term, search_term, gl.tile_count) + current_inputs = (content_type, sort_type, period_type, use_search_term, search_term, gl.tile_count, base_filter) if gl.previous_inputs and current_inputs != gl.previous_inputs: gl.inputs_changed = True @@ -445,7 +456,7 @@ def update_model_list(content_type, sort_type, period_type, use_search_term, sea gl.previous_inputs = current_inputs - gl.json_data = api_to_data(content_type, sort_type, period_type, use_search_term, current_page, search_term, timeOut, isNext) + gl.json_data = api_to_data(content_type, sort_type, period_type, use_search_term, current_page, base_filter, search_term, timeOut, isNext) if gl.json_data == "timeout": HTML = '
The Civit-API has timed out, please try again.
The servers might be too busy or down if the issue persists.
' hasPrev = current_page not in [0, 1] diff --git a/scripts/civitai_gui.py b/scripts/civitai_gui.py index 710dc67..ad4cbbd 100644 --- a/scripts/civitai_gui.py +++ b/scripts/civitai_gui.py @@ -118,7 +118,7 @@ def on_ui_tabs(): period_type = gr.Dropdown(label='Time period:', choices=["All Time", "Year", "Month", "Week", "Day"], value="All Time", type="value", elem_id="centerText") sort_type = gr.Dropdown(label='Sort by:', choices=["Newest","Most Downloaded","Highest Rated","Most Liked"], value="Most Downloaded", type="value", elem_id="centerText") with gr.Row(): - base_filter = gr.Dropdown(label='Filter base model:', multiselect=True, choices=["SD 1.4","SD 1.5","SD 2.0","SD 2.1", "SDXL 0.9", "SDXL 1.0", "Other"], value=None, type="value", elem_id="centerText") + base_filter = gr.Dropdown(label='Filter base model:', multiselect=True, choices=["SD 1.4", "SD 1.5", "SD 2.0", "SD 2.0 768", "SD 2.1", "SD 2.1 768", "SD 2.1 Unclip", "SDXL 0.9", "SDXL 1.0", "Other"], value=None, type="value", elem_id="centerText") with gr.Row(elem_id=component_id): create_json = gr.Checkbox(label=f"Save tags after download", value=False, elem_id=toggle1, min_width=200) toggle_date = gr.Checkbox(label="Divide cards by date", value=False, elem_id=toggle2, min_width=200) @@ -201,8 +201,6 @@ def on_ui_tabs(): delete_finish = gr.Textbox(value=None, visible=False) current_model = gr.Textbox(value=None, visible=False) current_sha256 = gr.Textbox(value=None, visible=False) - true = gr.Checkbox(value=True, visible=False) - page_load = gr.Button(value="", elem_id="pageLoadBtn", visible=False) # Global variable to detect if content has changed. def save_tags_btn(tags, file): @@ -262,18 +260,6 @@ def on_ui_tabs(): inputs=[show_nsfw], _js="(hideAndBlur) => toggleNSFWContent(hideAndBlur)" ) - - list_html.change( - fn=None, - inputs=[base_filter], - _js="(baseModelValue) => filterByBaseModel(baseModelValue)" - ) - - base_filter.change( - fn=None, - inputs=[base_filter], - _js="(baseModelValue) => filterByBaseModel(baseModelValue)" - ) list_html.change( fn=None, @@ -288,7 +274,6 @@ def on_ui_tabs(): ) # Gradio components Logic # - trained_tags.input( fn=save_tags_btn, inputs=[trained_tags, model_filename], @@ -696,7 +681,8 @@ def on_ui_tabs(): period_type, use_search_term, search_term, - page_slider + page_slider, + base_filter ] # Define common page load outputs