Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask #1

Merged
merged 6 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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