catch up with latest sd webui

pull/266/head
butaixianran 2023-09-27 04:14:00 +08:00
parent 920ca3267f
commit 1bb4820f18
10 changed files with 138 additions and 389 deletions

View File

@ -1,6 +1,5 @@
## 关于Civitai Helper2: Model Info Helper ## 关于Civitai Helper2: Model Info Helper
Civitai助手2将改名为**Model Info助手**。目前还在缓慢开发中。你可以查看它的UI演示视频了解它会是什么样子: 近况请参考:[about_version2](about_version2.md)
[https://youtu.be/mPcKwQDDH8s](https://youtu.be/mPcKwQDDH8s)
# Civitai Helper # Civitai Helper
@ -9,9 +8,7 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
[Civitai Url](https://civitai.com/models/16768/civitai-helper-sd-webui-civitai-extension) [Civitai Url](https://civitai.com/models/16768/civitai-helper-sd-webui-civitai-extension)
# 注意 # 注意
**本插件现在非常稳定,很多人用得很好,如果碰到问题,先看[常见问题](#常见问题),并检查命令行窗口的详情。** **本插件需要最新版SD webui使用前请更新你的SD webui版本。安装本插件后需要重启SD webui而不光是重新加载UI如果碰到问题先看[常见问题](#常见问题),并检查命令行窗口的详情。**
开issue前请先看文档。找茬行为的用户将会被拉黑参考[找茬行为会被拉黑](https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper/issues/96#issuecomment-1500310981)
# 功能 # 功能
[中文介绍视频(非官方)](https://youtu.be/x4tPWPmeAgM?t=373) [中文介绍视频(非官方)](https://youtu.be/x4tPWPmeAgM?t=373)
@ -23,12 +20,9 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
* 批量检查本地模型在civitai上的新版本 * 批量检查本地模型在civitai上的新版本
* 直接下载新版本模型到SD模型目录内(含信息和预览图) * 直接下载新版本模型到SD模型目录内(含信息和预览图)
* 修改了内置的"Extra Network"模型卡片,每个卡片增加了如下功能按钮: * 修改了内置的"Extra Network"模型卡片,每个卡片增加了如下功能按钮:
- 🖼: 修改文字"replace preview"为这个图标
- 🌐: 在新标签页打开这个模型的Civitai页面 - 🌐: 在新标签页打开这个模型的Civitai页面
- 💡: 一键添加这个模型的触发词到关键词输入框 - 💡: 一键添加这个模型的触发词到关键词输入框
- 🏷: 一键使用这个模型预览图所使用的关键词 - 🏷: 一键使用这个模型预览图所使用的关键词
* 以上额外功能按钮支持thumbnail模式
* 增加一直显示按钮的选项,以供触屏用户使用
# 安装 # 安装
@ -42,10 +36,7 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
# 使用方法 # 使用方法
## 更新你的SD webui ## 更新你的SD webui
本扩展需要取到 Extra Network的卡片列表id。**这个是2023-02-06才添加到SD webui里面的。** 请更新SD webui到最新版
所以如果你用的版本比这个早你就需要先更新你的SD Webui
## 扫描模型 ## 扫描模型
前往扩展页面"Civitai Helper",有个按钮叫:"Scan Model" 前往扩展页面"Civitai Helper",有个按钮叫:"Scan Model"
@ -70,8 +61,7 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
![](img/extra_network.jpg) ![](img/extra_network.jpg)
移动鼠标到模型卡片底部就会显示4个按钮 移动鼠标到模型卡片顶部就会显示3个额外的按钮
- 🖼: 修改文字"replace preview"为这个图标
- 🌐: 在新标签页打开这个模型的Civitai页面 - 🌐: 在新标签页打开这个模型的Civitai页面
- 💡: 一键添加这个模型的触发词到关键词输入框 - 💡: 一键添加这个模型的触发词到关键词输入框
- 🏷: 一键使用这个模型预览图所使用的关键词 - 🏷: 一键使用这个模型预览图所使用的关键词
@ -84,11 +74,6 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
每次当Extra Network刷新他都会删除掉额外的修改我们的按钮就会消失。这时你就需要点击`Refresh Civitai Helper`把这些功能添加回去。 每次当Extra Network刷新他都会删除掉额外的修改我们的按钮就会消失。这时你就需要点击`Refresh Civitai Helper`把这些功能添加回去。
### 小图模式
以上功能按钮支持小图模式但受制于SD Webui的CSS问题目前只能要么一直显示要么一直不显示不能鼠标滑过才显示。
![](img/thumb_mode.jpg)
## 下载 ## 下载
**(单任务,下载完一个再下另一个)** **(单任务,下载完一个再下另一个)**
通过Civitai模型页面Url下载模型要3个步骤 通过Civitai模型页面Url下载模型要3个步骤
@ -127,24 +112,11 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
![](img/get_one_model_info.jpg) ![](img/get_one_model_info.jpg)
## 代理 ## 设置
**如果你是刚更新新版本你需要重启SD webui再来使用** 现在所有设置被移动到 Setting 页面->Civitai Helper区域中。
代理输入框在插件页面最下方。
**每次填入或清除代理后都要保存并用SDwebui设置页面的Reload UI按钮刷新UI**
然后所有发到civitai的请求就会用代理。
代理输入框也在其中。
有些sock5代理, 需要使用socks5h开头的形式"socks5h://xxxxx"才能生效。 有些sock5代理, 需要使用socks5h开头的形式"socks5h://xxxxx"才能生效。
## 其他设置
**保存设置按钮, 会保存扫描模型区域,以及其他设置 这两个区域的选项**
* "一直显示按钮" 是为了方便触屏。
* "小图模式显示功能按钮" 会开关功能按钮在小图模式的显示
![](img/other_setting.jpg) ![](img/other_setting.jpg)
## 预览图 ## 预览图
@ -184,9 +156,6 @@ Enjoy!
## 常见问题 ## 常见问题
### 4个卡片按钮不显示 ### 4个卡片按钮不显示
#### 汉化原因
下载新版,最新版已经处理汉化导致的问题。**双语汉化插件需要v1.6.1.1之后的版本才开始支持。**
#### 使用了云端汉化功能 #### 使用了云端汉化功能
如果是秋叶启动器,就关闭启动器“云端汉化”功能。如果是专门的云端汉化插件,就换用普通汉化插件。 如果是秋叶启动器,就关闭启动器“云端汉化”功能。如果是专门的云端汉化插件,就换用普通汉化插件。
@ -203,7 +172,6 @@ git在很多时候会拒绝升级并告诉你有些冲突需要你手动
### Request model info from civitai ### Request model info from civitai
意思就是正在连接civitai如果没有后面的信息就是连不上请挂代理。 意思就是正在连接civitai如果没有后面的信息就是连不上请挂代理。
### 扫描或获取模型信息失败 ### 扫描或获取模型信息失败
这个插件现在很稳定所以这个问题的原因基本是是因为Civitai拒绝了你的连接请求。 这个插件现在很稳定所以这个问题的原因基本是是因为Civitai拒绝了你的连接请求。

View File

@ -17,7 +17,6 @@ Stable Diffusion Webui는 Civitai 모델을 더 쉽게 관리하고 사용하기
* 로컬 모델에서 Civitai에 새 버전이 있는지 일괄 확인 * 로컬 모델에서 Civitai에 새 버전이 있는지 일괄 확인
* 새 버전 모델을 SD 모델 디렉토리에 직접 다운로드(정보 및 미리보기 이미지 포함) * 새 버전 모델을 SD 모델 디렉토리에 직접 다운로드(정보 및 미리보기 이미지 포함)
* "Extra Network" 모델 카드 내부를 수정하여 다음과 같은 기능 버튼을 추가: * "Extra Network" 모델 카드 내부를 수정하여 다음과 같은 기능 버튼을 추가:
- 🖼: "replace preview" 텍스트를 이 아이콘으로 변경
- 🌐: 해당 모델의 Civitai 페이지를 새 탭에서 열기 - 🌐: 해당 모델의 Civitai 페이지를 새 탭에서 열기
- 💡: 이 모델의 트리거 단어를 키워드 입력란에 일괄 추가 - 💡: 이 모델의 트리거 단어를 키워드 입력란에 일괄 추가
- 🏷: 이 모델 미리보기 이미지에 사용된 키워드 사용 - 🏷: 이 모델 미리보기 이미지에 사용된 키워드 사용

View File

@ -4,14 +4,11 @@
[한국어(ChatGPT)](README.kr.md) [한국어(ChatGPT)](README.kr.md)
## About Civitai Helper2: Model Info Helper ## About Civitai Helper2: Model Info Helper
Civitai Helper 2 will be renamed to **ModelInfo Helper**. It is under development, you can watch its UI demo video to see how it gonna look like: check here for Civitai Helper 2's update:
[YouTube](https://youtu.be/mPcKwQDDH8s) [about_version2](about_version2.md)
# Notice # Notice
**This extension now is very stable and works well for many people. If you have an issue, check console log window's detail and read [common issue](#common-issue) part** **This extension request latest SD webui, update it before using this extension. And also re-lanuch SD webui after installing this extension(not just reload UI). If you have an issue, check console log window's detail and read [common issue](#common-issue) part**
If you want to claim it doesn't work, check this first: [Claim Wall](claim_wall.md)
# Civitai Helper # Civitai Helper
Stable Diffusion Webui Extension for Civitai, to handle your models much more easily. Stable Diffusion Webui Extension for Civitai, to handle your models much more easily.
@ -26,13 +23,9 @@ Civitai: [Civitai Url](https://civitai.com/models/16768/civitai-helper-sd-webui-
* Checking all your local model's new version from Civitai * Checking all your local model's new version from Civitai
* Download a new version directly into SD model folder (with info+preview) * Download a new version directly into SD model folder (with info+preview)
* Modified Built-in "Extra Network" cards, to add the following buttons on each card: * Modified Built-in "Extra Network" cards, to add the following buttons on each card:
- 🖼️: Modified "replace preview" text into this icon
- 🌐: Open this model's Civitai url in a new tab - 🌐: Open this model's Civitai url in a new tab
- 💡: Add this model's trigger words to prompt - 💡: Add this model's trigger words to prompt
- 🏷️: Use this model's preview image's prompt - 🏷: Use this model's preview image's prompt
* Above buttons support thumbnail mode of Extra Network
* Option to always show additional buttons, to work with touchscreen.
# Install # Install
Go to SD webui's extension tab, go to `Install from url` sub-tab. Go to SD webui's extension tab, go to `Install from url` sub-tab.
@ -47,8 +40,7 @@ Done.
# How to Use # How to Use
## Update Your SD Webui ## Update Your SD Webui
This extension need to get extra network's cards id. Which is added since **2023-02-06**. **Update SD webui before using this extension!**
**If your SD webui is an earlier version, you need to update it!**
## Scanning Models ## Scanning Models
Go to extension tab "Civitai Helper". There is a button called "Scan model". Go to extension tab "Civitai Helper". There is a button called "Scan model".
@ -70,13 +62,9 @@ When you have some new models, just click scan button again, to get new model's
## Model Card ## Model Card
**(Use this only after scanning finished)** **(Use this only after scanning finished)**
Open SD webui's build-in "Extra Network" tab, to show model cards. Go to a Model's tab to show model cards.
![](img/extra_network.jpg) Move your mouse on to the **Top** of a model card. It will show 3 additional icon buttons:
Move your mouse on to the bottom of a model card. It will show 4 icon buttons:
- 🖼: Replace preview (a build-in button, modified from text to icon)
- 🌐: Open this model's Civitai url in a new tab - 🌐: Open this model's Civitai url in a new tab
- 💡: Add this model's trigger words to prompt - 💡: Add this model's trigger words to prompt
- 🏷: Use this model's preview image's prompt - 🏷: Use this model's preview image's prompt
@ -88,11 +76,6 @@ Move your mouse on to the bottom of a model card. It will show 4 icon buttons:
![](img/refresh_ch.jpg) ![](img/refresh_ch.jpg)
Everytime after Extra Network tab refreshed, it will remove all these additional buttons. So, you need to click `Refresh Civitai Helper` button to bring them back. Everytime after Extra Network tab refreshed, it will remove all these additional buttons. So, you need to click `Refresh Civitai Helper` button to bring them back.
### Thumbnail Mode
Additional buttons work on thumbnail too, but due to SD webui's CSS issue, for now, they must be always displayed on thumbnail or don't display at all.
![](img/thumb_mode.jpg)
## Download ## Download
To download a model by Civitai Model Page's Url, you need 3 steps: To download a model by Civitai Model Page's Url, you need 3 steps:
* Fill url, click button to get model info * Fill url, click button to get model info
@ -133,30 +116,14 @@ After clicking button, extension will download that civitai model's info and pre
![](img/get_one_model_info.jpg) ![](img/get_one_model_info.jpg)
## Proxy ## Settings
**If you are updating to new version, you need to re-lanuch SD webui before using it.** Now all settings are moved into Setting tab->civitai helper section.
Proxy textbox is at the bottom of extension tab. For some sock5 proxy, need to be used as "socks5h://127.0.0.1:port".
**Each time you fill or clear a proxy value, you need to save setting, and Re-load UI with setting tab's reload button.**
Then all requests to civitai will use the proxy.
For some sock5 proxy, need to be used as "socks5h://xxxxx".
## Other Setting
**The Save Setting button, will save both "Scan Model"'s setting and other setting.**
* "Always Display Button" is good for touch screen.
* "Show Buttons on Thumb Mode" will turn on/off additional Buttons on thumbnail.
![](img/other_setting.jpg) ![](img/other_setting.jpg)
## Preview Image ## Preview Image
Extra network uses both `model_file.png` and `model_file.preview.png` as preview image. But `model_file.png` has higher priority, because it is created by yourself. Extra network uses both `model_file.png` and `model_file.preview.png` as preview image. But `model_file.png` has higher priority, because it is created by yourself.
@ -192,9 +159,6 @@ Enjoy!
## Common Issue ## Common Issue
### 4 Buttons on card didn't show ### 4 Buttons on card didn't show
#### Localization
There was a Localization issue if you are not using English version of SD webui. This is fixed in the latest version of this extension. **Bilingual localization extension is supported by PR since v1.6.1.1.**
##### Using cloud based localization extension ##### Using cloud based localization extension
Turn off cloud based localization extension, use normal localization extension. Turn off cloud based localization extension, use normal localization extension.
@ -230,8 +194,6 @@ Also, you can report those models with wrong sha256 to civitai at following page
Please report that model to civitai, so they can fix it. Please report that model to civitai, so they can fix it.
### Scanning fail when using colab ### Scanning fail when using colab
First of, search your error message with google. Most likely, it will be a colab issue. First of, search your error message with google. Most likely, it will be a colab issue.
@ -243,9 +205,11 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl
# Change Log # Change Log
## v1.7.0
* Fix all issues for latest sd webui
* Move all settings to Setting tab
## v1.6.4 ## v1.6.4
* Add "Download All files" checkbox for downloading model section. Uncheck means only download 1 file. * Add "Download All files" checkbox for downloading model section. Uncheck means only download 1 file.

29
about_version2.md Normal file
View File

@ -0,0 +1,29 @@
## About Civitai Helper2: Model Info Helper
The first version of "Civitai Helper2" is already finished and I have used it for a while on my local machine. It works exactly as in the demo video I have released before.
[https://www.youtube.com/watch?v=mPcKwQDDH8s](https://www.youtube.com/watch?v=mPcKwQDDH8s)
But the developing process is extremely painful. Its maintenance will also be difficult and hard to hand it over to other developers. If I release it, with all those requests and issues from users, my life gonna be in hell.
The reason for this is, the whole client side is based on javascript, almost no gradio code at all.
Gradio is not suitable for a professional level's management system. But under gradio's framework and SD webui's design, a lot of javascript stuff won't work well.
So, it is too painful that I don't want to do any further maintenance and development. And I realize SD webui itself is not that good since it uses gradio.
In the meantime, a lot of alternatives become popular. For example, the latest InvokeAI, powerful, easy to use and has build-in node system. It is so good that in most cases we have no reason to use SD webui any more.
If you are not familiar with InvokeAI, you can check this video:
[https://www.youtube.com/watch?v=8cVnooYgpDc](https://www.youtube.com/watch?v=8cVnooYgpDc)
For Model Info Helper, I'm re-designing it into a stand alone model management system, not an extension of SD webui.
Since it won't be released as estimated, I have updated the old civitai helper 1.x to work with latest SD webui.

View File

@ -1,91 +0,0 @@
# Claim Wall
Since this extension got a little hot, some users come to **claim many other issues to this extension**.
Following is a wall, to show a few examples how they claim this extension doesn't work, because they don't read document or forget what they did before.
If you are looking for guideline, go to section [What you should do](#what-you-should-do)
# Wall
### Didn't even update SD Webui and claim "tried everything"
![](img/user_claim_wall/have_not_update_sdwebui.jpg)
### Havn't even scanned model
After 4 replies, find that out, and modified his comment.
![](img/user_claim_wall/have_not_scan_model.jpg)
### Claim "pretty sure" this extension breaks his UI, takes 2days to find out it is not
Then removed his comment from civitai, but his post on reddit is still there, so you can know what's really going on there.
1. Claim "pretty sure" this extension breaks his UI
![](img/user_claim_wall/css_issue_part1.jpg)
![](img/user_claim_wall/css_issue_part2.jpg)
2. Find out it is not, after 2 days
![](img/user_claim_wall/css_issue_part3.jpg)
3. Still don't remember what he did with other extensions, until another user tells him, about 4 days later.
![](img/user_claim_wall/css_issue_part4.jpg)
### **Blame SD Webui's modification to this extension**
Latest SD webui removed a button from UI, they claim this extension did that, and want it back by this extension
![](img/user_claim_wall/blame_sdweui_update_to_this_ext.jpg)
### Claim other extension's error to this extension
Just because both extensions have "Civitai" in extension's name
![](img/user_claim_wall/do_not_even_use_this_ext.jpg)
### **Didn't even use this extension and request a feature it already has**
![](img/user_claim_wall/request_a_feature_it_already_has.jpg)
### **Renamed model folder's name carelessly and forgot that**
Takes about 8 hours to find out why this extension doesn't work on his SDwebui and ready to re-install SD webui from beginning.
1. claim this extension can not open civitai url on checkpoint models
![](img/user_claim_wall/changed_model_folder_name_then_forget_part1.jpg)
2. I reply that model he mentioned works well in my SDwebui
![](img/user_claim_wall/changed_model_folder_name_then_forget_part2.jpg)
3. After 6 hours' trying, find out his model folder's name is modified.
![](img/user_claim_wall/changed_model_folder_name_then_forget_part3.jpg)
![](img/user_claim_wall/changed_model_folder_name_then_forget_part4.jpg)
# What you should do
Above are just a very small piece of this kind of claims. Those claims won't help you. If you have an issue, following is the guidline:
* If you want to make your extension work, read the document.
* If your SD webui is broken, before you claim it is caused by this extension, you can disable it and try again.
* If you followed document, but it still doesn't work well, you can check console log's msg to find out the reason. If you can not understand those msg, you can come and ask for help, with console log's msg or screenshot.
* If you are using colab, and get an error from colab, then search that error msg in google. Because it's a colab's issue or limitation.
* If you checked console log window's msg and understand what it means, you are welcome to submit your issue.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -388,33 +388,15 @@ onUiLoaded(() => {
} }
// get component
let ch_always_display_ckb = gradioApp().querySelector("#ch_always_display_ckb input");
let ch_show_btn_on_thumb_ckb = gradioApp().querySelector("#ch_show_btn_on_thumb_ckb input");
let ch_always_display = false;
let ch_show_btn_on_thumb = false;
if (ch_always_display_ckb) {
ch_always_display = ch_always_display_ckb.checked;
}
if (ch_show_btn_on_thumb_ckb) {
ch_show_btn_on_thumb = ch_show_btn_on_thumb_ckb.checked;
}
//change all "replace preview" into an icon //change all "replace preview" into an icon
let extra_network_id = ""; let extra_network_id = "";
let extra_network_node = null; let extra_network_node = null;
let metadata_button = null; let button_row = null;
let additional_node = null;
let replace_preview_btn = null;
let ul_node = null;
let search_term_node = null; let search_term_node = null;
let search_term = ""; let search_term = "";
let model_type = ""; let model_type = "";
let cards = null; let cards = null;
let need_to_add_buttons = false; let need_to_add_buttons = false;
let is_thumb_mode = false;
//get current tab //get current tab
let active_tab_type = getActiveTabType(); let active_tab_type = getActiveTabType();
@ -487,111 +469,30 @@ onUiLoaded(() => {
extra_network_id = tab_prefix+"_"+js_model_type+"_"+cardid_suffix; extra_network_id = tab_prefix+"_"+js_model_type+"_"+cardid_suffix;
// console.log("searching extra_network_node: " + extra_network_id); // console.log("searching extra_network_node: " + extra_network_id);
extra_network_node = gradioApp().getElementById(extra_network_id); extra_network_node = gradioApp().getElementById(extra_network_id);
// check if extr network is under thumbnail mode
is_thumb_mode = false
if (extra_network_node) {
if (extra_network_node.className == "extra-network-thumbs") {
console.log(extra_network_id + " is in thumbnail mode");
is_thumb_mode = true;
// if (!ch_show_btn_on_thumb) {continue;}
}
} else {
console.log("can not find extra_network_node: " + extra_network_id);
continue;
}
// console.log("find extra_network_node: " + extra_network_id); // console.log("find extra_network_node: " + extra_network_id);
// get all card nodes // get all card nodes
cards = extra_network_node.querySelectorAll(".card"); cards = extra_network_node.querySelectorAll(".card");
for (let card of cards) { for (let card of cards) {
//metadata_buttoncard //get button row
metadata_button = card.querySelector(".metadata-button"); button_row = card.querySelector(".button-row");
//additional node
additional_node = card.querySelector(".actions .additional");
//get ul node, which is the parent of all buttons
ul_node = card.querySelector(".actions .additional ul");
// replace preview text button
replace_preview_btn = card.querySelector(".actions .additional a");
// check thumb mode
if (is_thumb_mode) {
additional_node.style.display = null;
if (ch_show_btn_on_thumb) {
ul_node.style.background = btn_thumb_background;
} else {
//reset
ul_node.style.background = null;
// console.log("remove existed buttons");
// remove existed buttons
if (ul_node) {
// find all .a child nodes
let atags = ul_node.querySelectorAll("a");
for (let atag of atags) {
//reset display
atag.style.display = null;
//remove extension's button
if (ch_btn_txts.indexOf(atag.innerHTML)>=0) {
//need to remove
ul_node.removeChild(atag);
} else {
//do not remove, just reset
atag.innerHTML = replace_preview_text;
atag.style.display = null;
atag.style.fontSize = null;
atag.style.position = null;
atag.style.backgroundImage = null;
}
}
//also remove br tag in ul
let brtag = ul_node.querySelector("br");
if (brtag) {
ul_node.removeChild(brtag);
}
}
//just reset and remove nodes, do nothing else
continue;
}
} else {
// full preview mode
if (ch_always_display) {
additional_node.style.display = "block";
} else {
additional_node.style.display = null;
}
// remove br tag
let brtag = ul_node.querySelector("br");
if (brtag) {
ul_node.removeChild(brtag);
}
if (!button_row){
console.log("can not find button_row");
continue;
} }
// change replace preview text button into icon let atags = button_row.querySelectorAll("a");
if (replace_preview_btn) { if (atags && atags.length) {
if (replace_preview_btn.innerHTML !== "🖼️") { console.log("find atags: " + atags.length);
need_to_add_buttons = true; } else {
replace_preview_btn.innerHTML = "🖼️"; console.log("no atags");
if (!is_thumb_mode) { need_to_add_buttons = true;
replace_preview_btn.style.fontSize = btn_fontSize;
replace_preview_btn.style.margin = btn_margin;
} else {
replace_preview_btn.style.display = btn_thumb_display;
replace_preview_btn.style.fontSize = btn_thumb_fontSize;
replace_preview_btn.style.position = btn_thumb_pos;
replace_preview_btn.style.backgroundImage = btn_thumb_backgroundImage;
}
}
} }
if (!need_to_add_buttons) { if (!need_to_add_buttons) {
console.log("do not need to add buttons");
continue; continue;
} }
@ -605,46 +506,26 @@ onUiLoaded(() => {
} }
// get search_term // get search_term
search_term = search_term_node.innerHTML; search_term = search_term_node.innerHTML.trim();
if (!search_term) { if (!search_term) {
console.log("search_term is empty for cards in " + extra_network_id); console.log("search_term is empty for cards in " + extra_network_id);
continue; continue;
} }
console.log("adding buttons");
// if (is_thumb_mode) {
// ul_node.style.background = btn_thumb_background;
// }
// then we need to add 3 buttons to each ul node: // then we need to add 3 buttons to each ul node:
let open_url_node = document.createElement("a"); let open_url_node = document.createElement("a");
open_url_node.href = "#"; open_url_node.href = "#";
open_url_node.innerHTML = "🌐"; open_url_node.innerHTML = "🌐";
if (!is_thumb_mode) { open_url_node.className = "card-button";
open_url_node.style.fontSize = btn_fontSize;
open_url_node.style.margin = btn_margin;
} else {
open_url_node.style.display = btn_thumb_display;
open_url_node.style.fontSize = btn_thumb_fontSize;
open_url_node.style.position = btn_thumb_pos;
open_url_node.style.backgroundImage = btn_thumb_backgroundImage;
}
open_url_node.title = "Open this model's civitai url"; open_url_node.title = "Open this model's civitai url";
open_url_node.setAttribute("onclick","open_model_url(event, '"+model_type+"', '"+search_term+"')"); open_url_node.setAttribute("onclick","open_model_url(event, '"+model_type+"', '"+search_term+"')");
let add_trigger_words_node = document.createElement("a"); let add_trigger_words_node = document.createElement("a");
add_trigger_words_node.href = "#"; add_trigger_words_node.href = "#";
add_trigger_words_node.innerHTML = "💡"; add_trigger_words_node.innerHTML = "💡";
if (!is_thumb_mode) { add_trigger_words_node.className = "card-button";
add_trigger_words_node.style.fontSize = btn_fontSize;
add_trigger_words_node.style.margin = btn_margin;
} else {
add_trigger_words_node.style.display = btn_thumb_display;
add_trigger_words_node.style.fontSize = btn_thumb_fontSize;
add_trigger_words_node.style.position = btn_thumb_pos;
add_trigger_words_node.style.backgroundImage = btn_thumb_backgroundImage;
}
add_trigger_words_node.title = "Add trigger words to prompt"; add_trigger_words_node.title = "Add trigger words to prompt";
add_trigger_words_node.setAttribute("onclick","add_trigger_words(event, '"+model_type+"', '"+search_term+"')"); add_trigger_words_node.setAttribute("onclick","add_trigger_words(event, '"+model_type+"', '"+search_term+"')");
@ -652,26 +533,15 @@ onUiLoaded(() => {
let use_preview_prompt_node = document.createElement("a"); let use_preview_prompt_node = document.createElement("a");
use_preview_prompt_node.href = "#"; use_preview_prompt_node.href = "#";
use_preview_prompt_node.innerHTML = "🏷️"; use_preview_prompt_node.innerHTML = "🏷️";
if (!is_thumb_mode) { use_preview_prompt_node.className = "card-button";
use_preview_prompt_node.style.fontSize = btn_fontSize;
use_preview_prompt_node.style.margin = btn_margin;
} else {
use_preview_prompt_node.style.display = btn_thumb_display;
use_preview_prompt_node.style.fontSize = btn_thumb_fontSize;
use_preview_prompt_node.style.position = btn_thumb_pos;
use_preview_prompt_node.style.backgroundImage = btn_thumb_backgroundImage;
}
use_preview_prompt_node.title = "Use prompt from preview image"; use_preview_prompt_node.title = "Use prompt from preview image";
use_preview_prompt_node.setAttribute("onclick","use_preview_prompt(event, '"+model_type+"', '"+search_term+"')"); use_preview_prompt_node.setAttribute("onclick","use_preview_prompt(event, '"+model_type+"', '"+search_term+"')");
//add to card //add to card
ul_node.appendChild(open_url_node); button_row.appendChild(open_url_node);
//add br if metadata_button exists button_row.appendChild(add_trigger_words_node);
if (is_thumb_mode && metadata_button) { button_row.appendChild(use_preview_prompt_node);
ul_node.appendChild(document.createElement("br"));
}
ul_node.appendChild(add_trigger_words_node);
ul_node.appendChild(use_preview_prompt_node);

View File

@ -16,8 +16,6 @@ data = {
}, },
"general":{ "general":{
"open_url_with_js": True, "open_url_with_js": True,
"always_display": False,
"show_btn_on_thumb": True,
"proxy": "", "proxy": "",
}, },
"tool":{ "tool":{
@ -74,12 +72,6 @@ def load():
data = json_data data = json_data
# check for new key # check for new key
if "always_display" not in data["general"].keys():
data["general"]["always_display"] = False
if "show_btn_on_thumb" not in data["general"].keys():
data["general"]["show_btn_on_thumb"] = True
if "proxy" not in data["general"].keys(): if "proxy" not in data["general"].keys():
data["general"]["proxy"] = "" data["general"]["proxy"] = ""
@ -87,7 +79,7 @@ def load():
return return
# save setting from parameter # save setting from parameter
def save_from_input(max_size_preview, skip_nsfw_preview, open_url_with_js, always_display, show_btn_on_thumb, proxy): def save_from_input(max_size_preview, skip_nsfw_preview, open_url_with_js, proxy):
global data global data
data = { data = {
"model":{ "model":{
@ -96,8 +88,6 @@ def save_from_input(max_size_preview, skip_nsfw_preview, open_url_with_js, alway
}, },
"general":{ "general":{
"open_url_with_js": open_url_with_js, "open_url_with_js": open_url_with_js,
"always_display": always_display,
"show_btn_on_thumb": show_btn_on_thumb,
"proxy": proxy, "proxy": proxy,
}, },
"tool":{ "tool":{

View File

@ -20,7 +20,6 @@ from modules import shared
from scripts.ch_lib import model from scripts.ch_lib import model
from scripts.ch_lib import js_action_civitai from scripts.ch_lib import js_action_civitai
from scripts.ch_lib import model_action_civitai from scripts.ch_lib import model_action_civitai
from scripts.ch_lib import setting
from scripts.ch_lib import civitai from scripts.ch_lib import civitai
from scripts.ch_lib import util from scripts.ch_lib import util
@ -34,18 +33,17 @@ root_path = os.getcwd()
extension_path = scripts.basedir() extension_path = scripts.basedir()
model.get_custom_model_folder() model.get_custom_model_folder()
setting.load()
# set proxy
if setting.data["general"]["proxy"]:
util.printD("Set Proxy: "+setting.data["general"]["proxy"])
util.proxies = {
"http": setting.data["general"]["proxy"],
"https": setting.data["general"]["proxy"],
}
# Setting now can not be saved from extension tab
# All settings now must be saved from setting page.
def on_ui_settings():
ch_section = ("civitai_helper", "Civitai Helper")
# settings
shared.opts.add_option("ch_max_size_preview", shared.OptionInfo(True, "Download Max Size Preview", gr.Checkbox, {"interactive": True}, section=ch_section))
shared.opts.add_option("ch_skip_nsfw_preview", shared.OptionInfo(False, "Skip NSFW Preview Images", gr.Checkbox, {"interactive": True}, section=ch_section))
shared.opts.add_option("ch_open_url_with_js", shared.OptionInfo(True, "Open Url At Client Side", gr.Checkbox, {"interactive": True}, section=ch_section))
shared.opts.add_option("ch_proxy", shared.OptionInfo("", "Civitai Helper Proxy", gr.Textbox, {"interactive": True, "lines":1, "info":"format: socks5h://127.0.0.1:port"}, section=ch_section))
def on_ui_tabs(): def on_ui_tabs():
# init # init
@ -64,12 +62,50 @@ def on_ui_tabs():
img2img_prompt = modules.ui.img2img_paste_fields[0][0] img2img_prompt = modules.ui.img2img_paste_fields[0][0]
img2img_neg_prompt = modules.ui.img2img_paste_fields[1][0] img2img_neg_prompt = modules.ui.img2img_paste_fields[1][0]
# get settings
max_size_preview = shared.opts.data.get("ch_max_size_preview", True)
skip_nsfw_preview = shared.opts.data.get("ch_skip_nsfw_preview", False)
open_url_with_js = shared.opts.data.get("ch_open_url_with_js", True)
proxy = shared.opts.data.get("ch_proxy", "")
util.printD("Settings:")
util.printD("max_size_preview: " + str(max_size_preview))
util.printD("skip_nsfw_preview: " + str(skip_nsfw_preview))
util.printD("open_url_with_js: " + str(open_url_with_js))
util.printD("proxy: " + str(proxy))
# set proxy
if proxy:
util.proxies = {
"http": proxy,
"https": proxy,
}
# ====Event's function==== # ====Event's function====
def scan_model(scan_model_types):
return model_action_civitai.scan_model(scan_model_types, max_size_preview, skip_nsfw_preview)
def get_model_info_by_input(model_type_drop, model_name_drop, model_url_or_id_txtbox):
return model_action_civitai.get_model_info_by_input(model_type_drop, model_name_drop, model_url_or_id_txtbox, max_size_preview, skip_nsfw_preview)
def dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb):
return model_action_civitai.dl_model_by_input(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview, skip_nsfw_preview)
def check_models_new_version_to_md(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb):
return model_action_civitai.check_models_new_version_to_md(dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview, skip_nsfw_preview)
def open_model_url(js_msg_txtbox):
return js_action_civitai.open_model_url(js_msg_txtbox, open_url_with_js)
def dl_model_new_version(js_msg_txtbox, max_size_preview):
return js_action_civitai.dl_model_new_version(js_msg_txtbox, max_size_preview, skip_nsfw_preview)
def get_model_names_by_input(model_type, empty_info_only): def get_model_names_by_input(model_type, empty_info_only):
names = civitai.get_model_names_by_input(model_type, empty_info_only) names = civitai.get_model_names_by_input(model_type, empty_info_only)
return model_name_drop.update(choices=names) return model_name_drop.update(choices=names)
def get_model_info_by_url(url): def get_model_info_by_url(url):
r = model_action_civitai.get_model_info_by_url(url) r = model_action_civitai.get_model_info_by_url(url)
@ -85,15 +121,6 @@ def on_ui_tabs():
# ====UI==== # ====UI====
with gr.Blocks(analytics_enabled=False) as civitai_helper: with gr.Blocks(analytics_enabled=False) as civitai_helper:
# with gr.Blocks(css=".block.padded {padding: 10px !important}") as civitai_helper:
# init
max_size_preview = setting.data["model"]["max_size_preview"]
skip_nsfw_preview = setting.data["model"]["skip_nsfw_preview"]
open_url_with_js = setting.data["general"]["open_url_with_js"]
always_display = setting.data["general"]["always_display"]
show_btn_on_thumb = setting.data["general"]["show_btn_on_thumb"]
proxy = setting.data["general"]["proxy"]
model_types = list(model.folders.keys()) model_types = list(model.folders.keys())
no_info_model_names = civitai.get_model_names_by_input("ckp", False) no_info_model_names = civitai.get_model_names_by_input("ckp", False)
@ -107,8 +134,6 @@ def on_ui_tabs():
with gr.Column(): with gr.Column():
gr.Markdown("### Scan Models for Civitai") gr.Markdown("### Scan Models for Civitai")
with gr.Row(): with gr.Row():
max_size_preview_ckb = gr.Checkbox(label="Download Max Size Preview", value=max_size_preview, elem_id="ch_max_size_preview_ckb")
skip_nsfw_preview_ckb = gr.Checkbox(label="Skip NSFW Preview Images", value=skip_nsfw_preview, elem_id="ch_skip_nsfw_preview_ckb")
scan_model_types_ckbg = gr.CheckboxGroup(choices=model_types, label="Model Types", value=model_types) scan_model_types_ckbg = gr.CheckboxGroup(choices=model_types, label="Model Types", value=model_types)
# with gr.Row(): # with gr.Row():
@ -159,16 +184,9 @@ def on_ui_tabs():
with gr.Box(elem_classes="ch_box"): with gr.Box(elem_classes="ch_box"):
with gr.Column(): with gr.Column():
gr.Markdown("### Other Setting") gr.Markdown("### Other")
with gr.Row(): # save_setting_btn = gr.Button(value="Save Setting")
open_url_with_js_ckb = gr.Checkbox(label="Open Url At Client Side", value=open_url_with_js, elem_id="ch_open_url_with_js_ckb") gr.Markdown(value="Settings are moved into Settings Tab->Civitai Helper section")
always_display_ckb = gr.Checkbox(label="Always Display Buttons", value=always_display, elem_id="ch_always_display_ckb")
show_btn_on_thumb_ckb = gr.Checkbox(label="Show Button On Thumb Mode", value=show_btn_on_thumb, elem_id="ch_show_btn_on_thumb_ckb")
proxy_txtbox = gr.Textbox(label="Proxy", interactive=True, lines=1, value=proxy, info="format: http://127.0.0.1:port")
save_setting_btn = gr.Button(value="Save Setting")
general_log_md = gr.Markdown(value="")
# ====Footer==== # ====Footer====
@ -185,33 +203,35 @@ def on_ui_tabs():
# ====events==== # ====events====
# Scan Models for Civitai # Scan Models for Civitai
scan_model_civitai_btn.click(model_action_civitai.scan_model, inputs=[scan_model_types_ckbg, max_size_preview_ckb, skip_nsfw_preview_ckb], outputs=scan_model_log_md) scan_model_civitai_btn.click(scan_model, inputs=[scan_model_types_ckbg], outputs=scan_model_log_md)
# Get Civitai Model Info by Model Page URL # Get Civitai Model Info by Model Page URL
model_type_drop.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop) model_type_drop.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop)
empty_info_only_ckb.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop) empty_info_only_ckb.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop)
get_civitai_model_info_by_id_btn.click(model_action_civitai.get_model_info_by_input, inputs=[model_type_drop, model_name_drop, model_url_or_id_txtbox, max_size_preview_ckb, skip_nsfw_preview_ckb], outputs=get_model_by_id_log_md) get_civitai_model_info_by_id_btn.click(get_model_info_by_input, inputs=[model_type_drop, model_name_drop, model_url_or_id_txtbox], outputs=get_model_by_id_log_md)
# Download Model # Download Model
dl_model_info_btn.click(get_model_info_by_url, inputs=dl_model_url_or_id_txtbox, outputs=[dl_model_info, dl_model_name_txtbox, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop]) dl_model_info_btn.click(get_model_info_by_url, inputs=dl_model_url_or_id_txtbox, outputs=[dl_model_info, dl_model_name_txtbox, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop])
dl_civitai_model_by_id_btn.click(model_action_civitai.dl_model_by_input, inputs=[dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb, max_size_preview_ckb, skip_nsfw_preview_ckb], outputs=dl_log_md) dl_civitai_model_by_id_btn.click(dl_model_by_input, inputs=[dl_model_info, dl_model_type_txtbox, dl_subfolder_drop, dl_version_drop, dl_all_ckb], outputs=dl_log_md)
# Check models' new version # Check models' new version
check_models_new_version_btn.click(model_action_civitai.check_models_new_version_to_md, inputs=model_types_ckbg, outputs=check_models_new_version_log_md) check_models_new_version_btn.click(model_action_civitai.check_models_new_version_to_md, inputs=model_types_ckbg, outputs=check_models_new_version_log_md)
# Other Setting
save_setting_btn.click(setting.save_from_input, inputs=[max_size_preview_ckb, skip_nsfw_preview_ckb, open_url_with_js_ckb, always_display_ckb, show_btn_on_thumb_ckb, proxy_txtbox], outputs=general_log_md)
# js action # js action
js_open_url_btn.click(js_action_civitai.open_model_url, inputs=[js_msg_txtbox, open_url_with_js_ckb], outputs=py_msg_txtbox) js_open_url_btn.click(open_model_url, inputs=[js_msg_txtbox], outputs=py_msg_txtbox)
js_add_trigger_words_btn.click(js_action_civitai.add_trigger_words, inputs=[js_msg_txtbox], outputs=[txt2img_prompt, img2img_prompt]) js_add_trigger_words_btn.click(js_action_civitai.add_trigger_words, inputs=[js_msg_txtbox], outputs=[txt2img_prompt, img2img_prompt])
js_use_preview_prompt_btn.click(js_action_civitai.use_preview_image_prompt, inputs=[js_msg_txtbox], outputs=[txt2img_prompt, txt2img_neg_prompt, img2img_prompt, img2img_neg_prompt]) js_use_preview_prompt_btn.click(js_action_civitai.use_preview_image_prompt, inputs=[js_msg_txtbox], outputs=[txt2img_prompt, txt2img_neg_prompt, img2img_prompt, img2img_neg_prompt])
js_dl_model_new_version_btn.click(js_action_civitai.dl_model_new_version, inputs=[js_msg_txtbox, max_size_preview_ckb, skip_nsfw_preview_ckb], outputs=dl_log_md) js_dl_model_new_version_btn.click(dl_model_new_version, inputs=[js_msg_txtbox], outputs=dl_log_md)
# the third parameter is the element id on html, with a "tab_" as prefix # the third parameter is the element id on html, with a "tab_" as prefix
return (civitai_helper , "Civitai Helper", "civitai_helper"), return (civitai_helper , "Civitai Helper", "civitai_helper"),
script_callbacks.on_ui_settings(on_ui_settings)
script_callbacks.on_ui_tabs(on_ui_tabs) script_callbacks.on_ui_tabs(on_ui_tabs)