Skip to content

Commit ee1fb94

Browse files
committed
更新版本V0.0.59
更新版本V0.0.59
1 parent f7a5246 commit ee1fb94

File tree

17 files changed

+515
-119
lines changed

17 files changed

+515
-119
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,24 @@
2828

2929
# 版本更新介绍
3030

31-
> 最新更新:2025-05-07
31+
> 最新更新:2025-05-08
3232
33-
> 0.0.58 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
33+
> 0.0.59 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
34+
>
35+
> 1. 修复了已知BUG
36+
>
37+
> 2. 新增功能(测试):Lora可以以Tag形式加载(仅全能提示词编辑器生效)在编辑器下方的Lora管理器点击添加Tag即可我们插件识别的方式为```<wlr:Lora名称:模型权重:文本权重>```
38+
>
39+
> 3. 修复了Lora管理器二级目录加载的问题
40+
>
41+
> 4. 修复了Tag管理器Tag点击排序的bug问题
42+
>
43+
44+
<details>
45+
<summary>点击查看往期更多更新内容</summary>
46+
47+
48+
> 0.0.58 公测版本介绍 2025-05-07
3449
>
3550
> 1. 修复了已知BUG
3651
>
@@ -57,9 +72,6 @@
5772
> 12. 修改了Lora管理器,新增了二级目录显示全部的功能,修改了目录栏的高度问题
5873
>
5974
60-
<details>
61-
<summary>点击查看往期更多更新内容</summary>
62-
6375
> 0.0.53 公测版本介绍 2025-04-30
6476
>
6577
> 1. 功能优化:修复了在日间模式下的Lora详细内容的按钮样式看不到问题

README_EN.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@ Due to limited personal time, the frequency of updating plug-ins will not be ver
2424

2525
# Version update introduction
2626

27-
> Last updated: 2025-05-07
27+
> Last updated: 2025-05-08
2828
29-
> 0.0.58 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
29+
> 0.0.59 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
30+
>
31+
> 1. Fixed known bugs
32+
>
33+
> 2. New function (test) :Lora can be loaded in the form of Tag (only the omnipotent prompt word editor is effective) Click on the Lora manager below the editor to add the Tag. The way that our plugin can identify is' ' '<wlr:Lora name: model weight: text weight >' ' '
34+
>
35+
> 3. Fixed issues with Lora manager subdirectory loading
36+
>
37+
> 4. Fixed a bug with Tag click sorting in Tag manager
38+
>
39+
40+
<details>
41+
<summary>Click here for more updates from the past</summary>
42+
43+
> 0.0.58 Public Beta Version 2025-05-07
3044
>
3145
> 1. Fixed known bugs
3246
>
@@ -53,9 +67,6 @@ Due to limited personal time, the frequency of updating plug-ins will not be ver
5367
> 12. Modified the Lora manager, added the function of displaying all secondary directories, and changed the height problem of the directory bar
5468
>
5569
56-
<details>
57-
<summary>Click here for more updates from the past</summary>
58-
5970
> 0.0.53 Public Beta Version 2025-04-30
6071
>
6172
> 1. Feature optimization: Fixed the issue that Lora details button style could not be seen in daytime mode

__init__.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import locale
66
import json
77
import shutil
8+
import re
89

910
# Server Init
1011
from .install_request import *
@@ -121,7 +122,10 @@ def INPUT_TYPES(self):
121122
CATEGORY = node_name_text
122123

123124
# 加载Lora
124-
def load_lora_ing(self, positive="", auto_random=False, lora_str="", temp_str="", temp_lora_str="",random_template="", opt_text="", opt_clip=None, opt_model=None):
125+
def load_lora_ing(self, positive="", auto_random=False, lora_str="",
126+
temp_str="", temp_lora_str="", random_template="", opt_text="",
127+
opt_clip=None, opt_model=None):
128+
125129
model_lora_secondA = opt_model
126130
clip_lora_secondA = opt_clip
127131

@@ -155,6 +159,36 @@ def load_lora_ing(self, positive="", auto_random=False, lora_str="", temp_str=""
155159
text_dec = opt_text +", "+positive
156160
else:
157161
text_dec = positive
162+
163+
164+
wlr_pattern = r'<wlr:([^:]+):([^:]+):([^>]+)>'
165+
wlr_matches = re.findall(wlr_pattern, text_dec)
166+
167+
# print(wlr_matches)
168+
# 如果找到了wlr标签,创建lora列表
169+
if wlr_matches:
170+
extracted_loras = []
171+
for lora_path, model_weight, text_weight in wlr_matches:
172+
extracted_loras.append({
173+
"lora": lora_path.strip()+".safetensors",
174+
"weight": float(model_weight.strip()),
175+
"text_encoder_weight": float(text_weight.strip())
176+
})
177+
178+
# print(extracted_loras)
179+
# 如果已经有lora_list,合并它们
180+
if lora_list is not None:
181+
lora_list.extend(extracted_loras)
182+
else:
183+
lora_list = extracted_loras
184+
185+
# 从text_dec中移除这些标签
186+
clean_text_dec = re.sub(wlr_pattern, '', text_dec)
187+
# 清理连续的逗号
188+
clean_text_dec = re.sub(r',\s*,', ',', clean_text_dec)
189+
# 清理开头和结尾的逗号
190+
clean_text_dec = clean_text_dec.strip().strip(',').strip()
191+
text_dec = clean_text_dec
158192

159193

160194
# 当模型不为空时
@@ -183,6 +217,7 @@ def load_lora_ing(self, positive="", auto_random=False, lora_str="", temp_str=""
183217
self.loaded_loraA = (lora_path, lora)
184218

185219
model_lora_secondA, clip_lora_secondA = load_lora_for_models(model_lora_secondA, clip_lora_secondA, lora, strength_model, strength_clip)
220+
186221
if opt_clip != None:
187222
tokensA = clip_lora_secondA.tokenize(text_dec)
188223
outputA = clip_lora_secondA.encode_from_tokens(tokensA, return_pooled=True, return_dict=True)

app/server/prompt_api/lora_networks.py

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import asyncio
88
import concurrent.futures
99
from tqdm import tqdm
10+
import zlib
11+
import base64
1012

1113
from .lora_info import get_model_info
1214

@@ -25,6 +27,51 @@
2527
'metadata',
2628
]
2729

30+
def path_to_shortcode(path):
31+
"""
32+
将路径转换为短码,可直接反向解析
33+
34+
参数:
35+
path: 文件路径
36+
37+
返回:
38+
生成的短码
39+
"""
40+
# 压缩路径字符串
41+
compressed = zlib.compress(path.encode('utf-8'))
42+
43+
# 使用Base64编码,并替换一些特殊字符以便于URL使用
44+
# 替换 + 为 - 和 / 为 _
45+
shortcode = base64.b64encode(compressed).decode('utf-8').replace('+', '-').replace('/', '_').replace('=', '')
46+
47+
return shortcode
48+
49+
def shortcode_to_path(shortcode):
50+
"""
51+
从短码反向解析出原始路径
52+
53+
参数:
54+
shortcode: 短码
55+
56+
返回:
57+
原始文件路径
58+
"""
59+
# 还原Base64编码中被替换的字符
60+
base64_str = shortcode.replace('-', '+').replace('_', '/')
61+
62+
# 添加回可能被移除的填充字符
63+
padding = 4 - (len(base64_str) % 4)
64+
if padding < 4:
65+
base64_str += '=' * padding
66+
67+
# 解码Base64
68+
compressed = base64.b64decode(base64_str)
69+
70+
# 解压缩
71+
path = zlib.decompress(compressed).decode('utf-8')
72+
73+
return path
74+
2875

2976
def prepare_lora_item_data(item_path, auto_fetch=False):
3077
lora_path = folder_paths.get_full_path("loras", item_path)
@@ -47,6 +94,8 @@ def prepare_lora_item_data(item_path, auto_fetch=False):
4794
# url = next(filter(lambda x: x['type'] == 'image', info_data['images']), {}).get('url')
4895
# download_image(url=url, filename=file_name, directory=os.path.dirname(lora_path))
4996

97+
# 为item_path生成短码
98+
# shortcode = path_to_shortcode(item_path)
5099
item = {
51100
"basename": item_path,
52101
"name": item_path,
@@ -55,6 +104,7 @@ def prepare_lora_item_data(item_path, auto_fetch=False):
55104
"preview":preview_file(lora_path),
56105
"model_name": model_name,
57106
"model_filename": file_name,
107+
# "shortcode": shortcode, # 添加短码到返回数据中
58108
}
59109
item["local_info"] = info_data
60110
# item["search_terms"] = ["Lora\\"+item_path]
@@ -113,14 +163,10 @@ def get_lora_folder():
113163

114164
# 确保子目录在一级目录下
115165
if subdir not in result[level1_dir]:
116-
result[level1_dir][subdir] = {
117-
"all": [], # 子目录下所有文件
118-
"/": {} # 子目录下的文件
119-
}
166+
result[level1_dir][subdir] = {}
120167

121168
# 添加文件到子目录,使用完整路径
122169
result[level1_dir][subdir][parts[-1]] = file_path
123-
result[level1_dir][subdir]["all"].append(file_path)
124170
result[level1_dir]["all"].append(file_path)
125171

126172
return result

dist/javascript/main.entry.js

Lines changed: 49 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/javascript/main.entry.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lora_stack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ function initLoraStack() {
181181
// Render all Lora items
182182
function renderAllLoras(seed) {
183183
const loraListContainer = document.getElementById('loraListContainer_' + seed);
184+
if (!loraListContainer) {
185+
return;
186+
}
184187
loraListContainer.innerHTML = '';
185188
window.weilinGlobalSelectedLoras[seed].forEach((lora, index) => {
186189
renderLoraItem(seed, index, lora);
@@ -189,6 +192,7 @@ function renderAllLoras(seed) {
189192

190193
// Update Lora stack info to windows
191194
function updateLoraStackInfoToWindows(seed) {
195+
192196
let putJson = {
193197
lora: "",
194198
temp_lora: window.weilinGlobalSelectedLoras[seed]

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "weilin-comfyui-tools"
33
description = "让你在 ComfyUI 中快捷的使用提示词工具 Quickly use the prompt word tool in ComfyUI"
4-
version = "0.0.58"
4+
version = "0.0.59"
55
license = {file = "LICENSE"}
66
dependencies = []
77

src/src/i18n/locales/en_US.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default {
1919
oneClickRandomTag: 'one Click Random Tag',
2020
randomTagSettings: 'setting Random Tag',
2121
oneClickTranslate: "one Click Translate Tag",
22+
modelWeight: "Model Weight",
23+
textWeight: "Text Weight",
2224
settings: {
2325
title: 'Settings',
2426
cancel: 'Cancel',

0 commit comments

Comments
 (0)