Skip to content

Commit

Permalink
Mask (#1)
Browse files Browse the repository at this point in the history
* 合并-预设切换-2.1.861 (lllyasviel#14)

* 原请求作者-预设切换-2.1.860

* 解决冲突

* 合并通配符顺序读取2.1.861 (lllyasviel#15)

* 通配符增强,切换顺序读取

通配符增强,通过勾选切换通配符读取方法,默认不勾选为随机读取一行,勾选后为按顺序读取,并使用相同的种子。

* 代码来自刁璐璐

* update

* Update async_worker.py

* 合并样式标签对齐css (lllyasviel#16)

* ui_wildcards_enhance

通配符界面文件

* Wildcards Artist

Wildcards Artist 捏人数据通配符文件

* Update webui.py

增加两句代码,插入通配符增强选项卡界面

* 中文翻译文档,包括了通配符的翻译

* Update xhox_bangs.txt

* Update xhox_hanfu.txt

* Wildcards Artist v 0.92

增加一些小功能

* Add files via upload

* Add files via upload

* 更新通配符数据翻译

* Wildcards Artist - 通配符艺术角色大师

确定名称

* Update ui_wildcards_enhance.py

* 为随机预设增加随机艺术家部分

* 将几个元素的默认值设定为其列表中的第一个

设定几个元素的默认值为其列表中的第一个,方便用户通过修改通配符文件内容的顺序来修改默认值

* 更新通配符数据能符合设定的默认值

* Add files via upload

* 功能基础完成,剩下的就是更新通配符数据和翻译了

功能基础完成,除了一个刷新选项按钮

* Add files via upload

* v0.93

* Add files via upload

* Add files via upload

* Add files via upload

* Update webui.py

* 通配符增强,切换顺序读取

通配符增强,通过勾选切换通配符读取方法,默认不勾选为随机读取一行,勾选后为按顺序读取,并使用相同的种子。

* 代码来自刁璐璐

* update

* 复刻Fooocus-feature-add-preset-selection

* 自用,合并更新

* Update async_worker.py

* 还原2.1.861

* 样式标签对齐css

* 最大宽度调整为50%-5px,从-15

* 尝试解决冲突

* Fooocus wildcards enhance (lllyasviel#17)

* ui_wildcards_enhance

通配符界面文件

* Wildcards Artist

Wildcards Artist 捏人数据通配符文件

* Update webui.py

增加两句代码,插入通配符增强选项卡界面

* 中文翻译文档,包括了通配符的翻译

* Update xhox_bangs.txt

* Update xhox_hanfu.txt

* Wildcards Artist v 0.92

增加一些小功能

* Add files via upload

* Add files via upload

* 更新通配符数据翻译

* Wildcards Artist - 通配符艺术角色大师

确定名称

* Update ui_wildcards_enhance.py

* 为随机预设增加随机艺术家部分

* 将几个元素的默认值设定为其列表中的第一个

设定几个元素的默认值为其列表中的第一个,方便用户通过修改通配符文件内容的顺序来修改默认值

* 更新通配符数据能符合设定的默认值

* Add files via upload

* 功能基础完成,剩下的就是更新通配符数据和翻译了

功能基础完成,除了一个刷新选项按钮

* Add files via upload

* v0.93

* 合并更新到2.1.861的通配符增强捏人

* 尝试解决冲突

---------

Co-authored-by: xhoxye <129571231+xhoxye@users.noreply.github.com>
  • Loading branch information
xizzat and xhoxye committed Jan 20, 2024
1 parent e0acacf commit ac63ebd
Show file tree
Hide file tree
Showing 45 changed files with 5,106 additions and 14 deletions.
32 changes: 31 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,36 @@
transition: transform 0.1s ease, opacity 0.3s ease;
}

/* scrollable box for style selections */
.contain .tabs {
height: 100%;
}

.contain .tabs .tabitem.style_selections_tab {
height: 100%;
}

.contain .tabs .tabitem.style_selections_tab > div:first-child {
height: 100%;
}

.contain .tabs .tabitem.style_selections_tab .style_selections{
min-height:200px;
height: 100%;
}

.contain .tabs .tabitem.style_selections_tab .style_selections .wrap[data-testid="checkbox-group"] label {
max-width: calc(50% - 5px) !important;
flex: calc(50% - 5px) !important;
padding:2px 5px;
}

.contain .tabs .tabitem.style_selections_tab .style_selections .wrap[data-testid="checkbox-group"] label span {
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}

#stylePreviewOverlay.lower-half {
transform: translate(-140px, -140px);
}
}
1,754 changes: 1,754 additions & 0 deletions language/cn.json

Large diffs are not rendered by default.

1,754 changes: 1,754 additions & 0 deletions language/cnxhox.json

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions modules/async_worker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import threading
import re


class AsyncTask:
Expand Down Expand Up @@ -140,6 +141,7 @@ def handler(async_task):
image_number = args.pop()
output_format = args.pop()
image_seed = args.pop()
read_wildcard_in_order_checkbox = args.pop()
sharpness = args.pop()
guidance_scale = args.pop()
base_model_name = args.pop()
Expand Down Expand Up @@ -413,13 +415,21 @@ def handler(async_task):
tasks = []

for i in range(image_number):
task_seed = (seed + i) % (constants.MAX_SEED + 1) # randint is inclusive, % is not
task_rng = random.Random(task_seed) # may bind to inpaint noise in the future

# determines that if prompt includes wildcard, this seed will not be increased automatically
placeholders = re.findall(r'__([\w-]+)__', prompt)
random_seed = (seed + i) % (constants.MAX_SEED + 1) # randint is inclusive, % is not
# Determine whether there is a wildcard and the value of the checkbox is True
if len(placeholders) > 0 and read_wildcard_in_order_checkbox:
task_seed = seed % (constants.MAX_SEED + 1) # If there are wildcard characters in the prompt and the value of the check box is True, the seed will not increase automatically.
else:
task_seed = random_seed
task_rng = random.Random(random_seed) # may bind to inpaint noise in the future
task_prompt = apply_wildcards(prompt, task_rng,i,read_wildcard_in_order_checkbox)
task_negative_prompt = apply_wildcards(negative_prompt, task_rng,i,read_wildcard_in_order_checkbox)
task_extra_positive_prompts = [apply_wildcards(pmt, task_rng,i,read_wildcard_in_order_checkbox) for pmt in extra_positive_prompts]
task_extra_negative_prompts = [apply_wildcards(pmt, task_rng,i,read_wildcard_in_order_checkbox) for pmt in extra_negative_prompts]

task_prompt = apply_wildcards(prompt, task_rng)
task_negative_prompt = apply_wildcards(negative_prompt, task_rng)
task_extra_positive_prompts = [apply_wildcards(pmt, task_rng) for pmt in extra_positive_prompts]
task_extra_negative_prompts = [apply_wildcards(pmt, task_rng) for pmt in extra_negative_prompts]

positive_basic_workloads = []
negative_basic_workloads = []
Expand Down
3 changes: 1 addition & 2 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,14 @@ def get_config_item_or_set_default(key, default_value, validator, disable_empty_
"default_sample_sharpness": "Sharpness",
"default_sampler": "Sampler",
"default_scheduler": "Scheduler",
"default_overwrite_step": "Sampling Steps Override",
"default_performance": "Performance",
"default_prompt": "Prompt",
"default_prompt_negative": "Negative Prompt",
"default_styles": "Styles",
"default_aspect_ratio": "Resolution",
"checkpoint_downloads": "checkpoint_downloads",
"embeddings_downloads": "embeddings_downloads",
"lora_downloads": "lora_downloads"
"lora_downloads": "lora_downloads",
}

REWRITE_PRESET = False
Expand Down
12 changes: 10 additions & 2 deletions modules/sdxl_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def apply_style(style, positive):
return p.replace('{prompt}', positive).splitlines(), n.splitlines()


def apply_wildcards(wildcard_text, rng, directory=wildcards_path):
def apply_wildcards(wildcard_text, rng, i, read_wildcard_in_order_checkbox, directory=wildcards_path):
for _ in range(wildcards_max_bfs_depth):
placeholders = re.findall(r'__([\w-]+)__', wildcard_text)
if len(placeholders) == 0:
Expand All @@ -71,7 +71,15 @@ def apply_wildcards(wildcard_text, rng, directory=wildcards_path):
words = open(os.path.join(directory, f'{placeholder}.txt'), encoding='utf-8').read().splitlines()
words = [x for x in words if x != '']
assert len(words) > 0
wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1)
#wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1)
# if checked, read in order, if not checked, read randomly
if len(words) > i and read_wildcard_in_order_checkbox:
wildcard_text = wildcard_text.replace(f'__{placeholder}__', words[i % len(words)], 1)
elif len(words) <= i and read_wildcard_in_order_checkbox:
wildcard_text = wildcard_text.replace(f'__{placeholder}__', words[i % len(words)], 1)
else:
wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1)

except:
print(f'[Wildcards] Warning: {placeholder}.txt missing or empty. '
f'Using "{placeholder}" as a normal word.')
Expand Down
Loading

0 comments on commit ac63ebd

Please sign in to comment.