From a3b2a8b9c842b849fa0556189f718ac8fb216f26 Mon Sep 17 00:00:00 2001 From: Superag Date: Thu, 15 Aug 2024 16:01:08 +0800 Subject: [PATCH] v 1.9 update --- README.md | 28 +++++++++++++++++++--------- README_CN.md | 12 +++++++++++- configs/settings.json | 5 +++-- install.py | 2 +- scripts/assistant/miaoshou.py | 17 ++++++++++++++--- scripts/runtime/msai_prelude.py | 6 +++--- scripts/runtime/msai_runtime.py | 25 +++++++++++++++++++++---- 7 files changed, 72 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2829b75..0845c78 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,25 @@ MiaoshouAI Assistant for [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) -1.81 Added MiaoshouAI as a model download source for people who can't access civitai; added a few sdxl controlnet and official downloads. -1.80 Fixed download problem in webui 1.60; Added support for model sorting; Model version, sub-folder support for download; Other bug fixes and improvements
-1.70 Improved search capability for Civitai to include keyword search in model names; Now supports SDXL model search (Data source update and full of restart webui update required) and filter model by tags. Fixed model loading error.
-1.60 Add VRAM garbage collection for image generation so that VRAM is freed up after every run; if your run into out of memory, just go to Boot Assistant and click "VRAM Release" to free up the memory.
-1.50 Rewrote how assets are loaded to largely reduce the size and installation time for the extension. (extension reinstall is needed for this version and up). Added download covers for all models.
-1.40 Add new feature for using GPT to generate prompts. Fixed sub folder support for model management
-1.30 Add support for LyCoris(just put them in the lora folder, LyCoris extension is needed.); Cleanup work for git to reduce project size
-1.20 Add support for model search. Allow model to load directly from model management. Now you can update model source directly under update tab.
-1.10 Add support for Lora, embedding and hypernetwork models under model manangement. bug fixes. + +#### Some Notice for this version +If you want to use MiaoshouAI Assistant in [Forge WebUI](https://github.com/lllyasviel/stable-diffusion-webui-forge), you can install [MiaoshouAI Assistant Forge Version](https://github.com/miaoshouai/miaoshouai-assistant-forge) + +If you had download failures for when downloading models, it is likely because model auther has restricted a login requirement for the model. +You need to go to civitai, under your [Account Settings](https://civitai.com/user/account) to apply for a civitai api key and save it through the ```Setting & Update``` tab. + +### Version History + +-1.90 Add support for civitai key and updated base model types.
+-1.81 Added MiaoshouAI as a model download source for people who can't access civitai; added a few sdxl controlnet and official downloads. +-1.80 Fixed download problem in webui 1.60; Added support for model sorting; Model version, sub-folder support for download; Other bug fixes and improvements
+-1.70 Improved search capability for Civitai to include keyword search in model names; Now supports SDXL model search (Data source update and full of restart webui update required) and filter model by tags. Fixed model loading error.
+-1.60 Add VRAM garbage collection for image generation so that VRAM is freed up after every run; if your run into out of memory, just go to Boot Assistant and click "VRAM Release" to free up the memory.
+-1.50 Rewrote how assets are loaded to largely reduce the size and installation time for the extension. (extension reinstall is needed for this version and up). Added download covers for all models.
+-1.40 Add new feature for using GPT to generate prompts. Fixed sub folder support for model management
+-1.30 Add support for LyCoris(just put them in the lora folder, LyCoris extension is needed.); Cleanup work for git to reduce project size
+-1.20 Add support for model search. Allow model to load directly from model management. Now you can update model source directly under update tab.
+-1.10 Add support for Lora, embedding and hypernetwork models under model manangement. bug fixes. ### Installation In Automatic1111 WebUI, go to `Extensions Tab`->`Install from URL`, copy the following address in "**URL for extension's git repository**". diff --git a/README_CN.md b/README_CN.md index 08a34c4..afc13cf 100644 --- a/README_CN.md +++ b/README_CN.md @@ -3,7 +3,17 @@ 喵手助理 [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) -1.81 增加了喵手AI作为模型源,让不能访问C站的人可以通过喵手AI源作为下载站点;增加了部分controlnet模型和官方模型的下载源 + +#### 此版本的注意事项 +如果你想在[Forge WebUI](https://github.com/lllyasviel/stable-diffusion-webui-forge)中使用喵手助理, 你可以安装[MiaoshouAI Assistant Forge](https://github.com/miaoshouai/miaoshouai-assistant-forge) 版本 + +如果下载模型时出现失败,可能是因为模型作者对该模型设置了登录要求。 +您需要前往 civitai 的[账户设置](https://civitai.com/user/account)页面,申请一个 Civitai API 密钥,并通过 ```Setting & Update``` 选项卡保存该密钥。 + +### 版本历史 + +1.90 一个支持 Forge WebUI 的新版本。新增对 Civitai 密钥的支持,并更新了基础模型类型。
+1.81 增加了喵手AI作为模型源,让不能访问C站的人可以通过喵手AI源作为下载站点;增加了部分controlnet模型和官方模型的下载源。
1.80 修复了webui 1.60中的下载问题;增加了对模型排序,子文件夹下载,模型版本等功能的支持。
1.70 优化了Civitai的模型文件名关键词搜索,SDXL模型搜索(需要更新数据源),支持tag筛选。修复了在1.6下的模型加载问题。
1.60 增加了显存自动清理功能。在启动助手中启用后可以在每次生图后自动清理显存。
diff --git a/configs/settings.json b/configs/settings.json index d578c65..6b43cd2 100644 --- a/configs/settings.json +++ b/configs/settings.json @@ -13,8 +13,9 @@ "txt_args_more": "", "auto_vram": true, "disable_log_console_output": true, - "model_source": "liandange.com", + "model_source": "miaoshouai.com", "my_model_source": "civitai.com", - "openai_api": "" + "openai_api": "", + "civitai_api": "" } } \ No newline at end of file diff --git a/install.py b/install.py index 9ad5b63..c793f53 100644 --- a/install.py +++ b/install.py @@ -17,7 +17,7 @@ def install_preset_models_if_needed(): with gzip.open(gzip_file, "rb") as compressed_file: with io.TextIOWrapper(compressed_file, encoding="utf-8") as decoder: content = decoder.read() - with open(target_file, "w") as model_file: + with open(target_file, "w", encoding="utf-8") as model_file: model_file.write(content) except Exception as e: print(f"failed to find out {model_filename} under assets directory: {e}") diff --git a/scripts/assistant/miaoshou.py b/scripts/assistant/miaoshou.py index 89ac844..a2511bb 100644 --- a/scripts/assistant/miaoshou.py +++ b/scripts/assistant/miaoshou.py @@ -163,7 +163,6 @@ def create_subtab_model_management(self) -> None: with gr.Row(): ms, my_model_source = self.runtime.get_default_model_source() - print(my_model_source) my_model_source_dropdown = widget.Dropdown( choices=["civitai.com", "miaoshouai.com"], value=my_model_source, @@ -303,7 +302,6 @@ def create_subtab_model_download(self) -> None: interactive=True, elem_classes="full") with widget.Row(equal_height=True): - nsfw_checker = gr.Checkbox(label='NSFW', value=False, elem_id="chk_nsfw", interactive=True) with gr.Accordion(label="Base Model", open=False): rad_all_none = gr.Radio(label='', choices=['All', 'None'], default='All', value='All', interactive=True) ckg_base_model = gr.CheckboxGroup(label='', choices=self.prelude.base_model_group, @@ -311,6 +309,9 @@ def create_subtab_model_download(self) -> None: value=self.prelude.base_model_group, elem_id="ckg_base_model", interactive=True) btn_bm_apply = gr.Button(value="Apply fiter") + + with widget.Row(equal_height=True): + nsfw_checker = gr.Checkbox(label='NSFW', value=False, elem_id="chk_nsfw", interactive=True) with gr.Accordion(label="Model Type", open=False): model_type = gr.Radio(choices=["All"] + list(self.prelude.model_type.keys()), show_label=False, value='All', elem_id="rad_model_type", @@ -420,7 +421,15 @@ def create_subtab_update(self) -> None: display_text = self.prelude.boot_settings['openai_api'] txt_gptapi = gr.Textbox(label='OpenAI API Key', value=display_text) with gr.Row(): - btn_update_gptapi = gr.Button(value="Update API Key") + btn_update_gptapi = gr.Button(value="Update API Key") + with gr.Row(): + if self.prelude.boot_settings['civitai_api'] == '': + display_text = 'Enter you Civitai API Key here, you can get it from https://civitai.com/user/account' + else: + display_text = self.prelude.boot_settings['civitai_api'] + txt_civitai_api = gr.Textbox(label='Civitai API Key', value=display_text) + with gr.Row(): + btn_civitai_api= gr.Button(value="Save Civitai API Key") with gr.Row(): txt_update_result = gr.Markdown(visible=False) with gr.Row(): @@ -449,6 +458,8 @@ def create_subtab_update(self) -> None: btn_check_update.click(self.runtime.check_update, inputs=[], outputs=[txt_update_result, chk_dont_update_ms, btn_update]) btn_update_gptapi.click(self.runtime.update_gptapi, inputs=[txt_gptapi], outputs=[md_api_res, self.txt_main_prompt]) + btn_civitai_api.click(self.runtime.update_civitai_api, inputs=[txt_civitai_api], + outputs=[md_api_res, txt_civitai_api]) btn_update.click(self.runtime.update_program, inputs=[chk_dont_update_ms], outputs=[txt_update_result]) def save_cmdline_args(self, drp_gpu, drp_theme, txt_listen_port, chk_group_args, additional_args): diff --git a/scripts/runtime/msai_prelude.py b/scripts/runtime/msai_prelude.py index 22f512b..06b50d8 100644 --- a/scripts/runtime/msai_prelude.py +++ b/scripts/runtime/msai_prelude.py @@ -84,9 +84,9 @@ def _init_constants(self) -> None: "VAE": f'{os.path.join(shared.models_path, "VAE")}', } - self._gpt_type = ['gpt-3.5-turbo', 'text-davinci-003'] - self._model_tags = ['Character', 'Style', 'Anime', 'Photorealistic', 'Concept', 'Clothing', 'Base Model', 'Poses', 'Background', 'Tool', 'Buildings'] - self._base_model_group = ['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'] + self._gpt_type = ['gpt-3.5-turbo', 'gpt-4o-mini'] + self._model_tags = ['Character', 'Style', 'Anime', 'Celebrity', 'Photorealistic', 'Concept', 'Clothing', 'Base Model', 'Poses', 'Background', 'Tool', 'Buildings', 'Vehicle', 'Objects', 'Animal', 'Action'] + self._base_model_group = ['SD 1.4', 'SD 1.5', 'SD 1.5 LCM', 'SD 1.5 Hyper', 'SD 2.0', 'SD 2.0 768', 'SD 2.1', 'Stable Cascade', 'SDXL 1.0', 'SDXL 1.0 LCM', 'SDXL Turbo', 'SDXL Lightning', 'SDXL Hyper', 'Pony', 'SD 3', 'Playground v2', 'Aura Flow', 'PixArt a', 'PixArt E', 'Hunyuan 1', 'Lumina', 'Kolors', 'Flux.1 D', 'Other'] @property def ext_folder(self) -> str: diff --git a/scripts/runtime/msai_runtime.py b/scripts/runtime/msai_runtime.py index e0b81bf..7d8c856 100644 --- a/scripts/runtime/msai_runtime.py +++ b/scripts/runtime/msai_runtime.py @@ -316,9 +316,8 @@ def force_mem_release(self): except Exception as e: msg = f'Memory Release Failed! ({str(e)})' - return gr.Markdown.update(visible=True, value=msg) + return gr.Markdown(visible=True, value=msg) - return gr.Markdown.update(visible=True, value=msg) def get_all_models(self, site: str) -> t.Any: return toolkit.read_json(self.prelude.model_json[site]) @@ -538,9 +537,9 @@ def set_nsfw(self, search='', nsfw_checker=False, base_model=None, model_type='A def set_basemodel(self, sel_base='All'): if sel_base == 'All': - return gr.Radio.update(value=self.prelude.base_model_group) + return gr.CheckboxGroup.update(value=self.prelude.base_model_group) else: - return gr.update(value=[False] * len(self.prelude.base_model_group)) + return gr.CheckboxGroup.update(value=[]) def search_model(self, search='', chk_nsfw=False, base_model=None, model_type='All', model_tag='All') -> t.Dict: if self._ds_models is None: @@ -898,12 +897,17 @@ def download_model(self, filename: str, des_folder: str): urls.append((cover_link, f['url'], f['size'], cover_fname, model_fname)) break + c_token = self.prelude.boot_settings['civitai_api'] for (cover_url, model_url, total_size, local_cover_name, local_model_name) in urls: self.downloader_manager.download( source_url=cover_url, target_file=local_cover_name, estimated_total_size=None, ) + + if len(c_token) > 0: + model_url += f"?token={c_token}" + self.downloader_manager.download( source_url=model_url, target_file=local_model_name, @@ -1216,6 +1220,19 @@ def update_gptapi(self, apikey): return gr.Markdown.update(value=res, visible=True), gr.Textbox.update(placeholder=gpt_hint_text, value=value_text) + def update_civitai_api(self, apikey): + if apikey == '': + res = 'Please enter a valid API Key' + gpt_hint_text = 'Enter you Civitai API Key here, you can get it from https://civitai.com/user/account' + value_text = gpt_hint_text + else: + self.update_boot_setting('civitai_api', apikey) + res = 'Civitai API Key updated' + value_text = apikey + + return gr.Markdown(value=res, visible=True), gr.Textbox(value=value_text) + + def update_program(self, dont_update_ms=False): result = "Update successful, restart to take effective." try: