Skip to content

Commit

Permalink
Merge branch 'lllyasviel:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
metercai authored Jul 28, 2024
2 parents 3faf05d + c2dc17e commit 6eead9e
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ body:
description: |
Please perform basic debugging to see if your configuration is the cause of the issue.
Basic debug procedure
 2. Update Fooocus - sometimes things just need to be updated
 3. Backup and remove your config.txt - check if the issue is caused by bad configuration
 5. Try a fresh installation of Fooocus in a different directory - see if a clean installation solves the issue
 1. Update Fooocus - sometimes things just need to be updated
 2. Backup and remove your config.txt - check if the issue is caused by bad configuration
 3. Try a fresh installation of Fooocus in a different directory - see if a clean installation solves the issue
Before making a issue report please, check that the issue hasn't been reported recently.
options:
- label: The issue has not been resolved by following the [troubleshooting guide](https://github.com/lllyasviel/Fooocus/blob/main/troubleshoot.md)
Expand Down
2 changes: 1 addition & 1 deletion fooocus_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '2.5.1'
version = '2.5.2'
13 changes: 10 additions & 3 deletions modules/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class AsyncTask:
def __init__(self, args):
from modules.flags import Performance, MetadataScheme, ip_list, controlnet_image_count, disabled
from modules.flags import Performance, MetadataScheme, ip_list, disabled
from modules.util import get_enabled_loras
from modules.config import default_max_lora_number
import args_manager
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(self, args):
args.pop()) if not args_manager.args.disable_metadata else MetadataScheme.FOOOCUS

self.cn_tasks = {x: [] for x in ip_list}
for _ in range(controlnet_image_count):
for _ in range(modules.config.default_controlnet_image_count):
cn_img = args.pop()
cn_stop = args.pop()
cn_weight = args.pop()
Expand Down Expand Up @@ -689,13 +689,20 @@ def process_prompt(async_task, prompt, negative_prompt, base_model_additional_lo

task_styles = async_task.style_selections.copy()
if use_style:
placeholder_replaced = False

for j, s in enumerate(task_styles):
if s == random_style_name:
s = get_random_style(task_rng)
task_styles[j] = s
p, n = apply_style(s, positive=task_prompt)
p, n, style_has_placeholder = apply_style(s, positive=task_prompt)
if style_has_placeholder:
placeholder_replaced = True
positive_basic_workloads = positive_basic_workloads + p
negative_basic_workloads = negative_basic_workloads + n

if not placeholder_replaced:
positive_basic_workloads = [task_prompt] + positive_basic_workloads
else:
positive_basic_workloads.append(task_prompt)

Expand Down
96 changes: 90 additions & 6 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,36 @@ def init_temp_path(path: str | None, default_path: str) -> str:
validator=lambda x: x in Performance.values(),
expected_type=str
)
default_image_prompt_checkbox = get_config_item_or_set_default(
key='default_image_prompt_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_enhance_checkbox = get_config_item_or_set_default(
key='default_enhance_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_advanced_checkbox = get_config_item_or_set_default(
key='default_advanced_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_developer_debug_mode_checkbox = get_config_item_or_set_default(
key='default_developer_debug_mode_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_image_prompt_advanced_checkbox = get_config_item_or_set_default(
key='default_image_prompt_advanced_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_max_image_number = get_config_item_or_set_default(
key='default_max_image_number',
default_value=32,
Expand Down Expand Up @@ -469,6 +493,65 @@ def init_temp_path(path: str | None, default_path: str) -> str:
validator=lambda x: x in modules.flags.inpaint_engine_versions,
expected_type=str
)
default_selected_image_input_tab_id = get_config_item_or_set_default(
key='default_selected_image_input_tab_id',
default_value=modules.flags.default_input_image_tab,
validator=lambda x: x in modules.flags.input_image_tab_ids,
expected_type=str
)
default_uov_method = get_config_item_or_set_default(
key='default_uov_method',
default_value=modules.flags.disabled,
validator=lambda x: x in modules.flags.uov_list,
expected_type=str
)
default_controlnet_image_count = get_config_item_or_set_default(
key='default_controlnet_image_count',
default_value=4,
validator=lambda x: isinstance(x, int) and x > 0,
expected_type=int
)
default_ip_images = {}
default_ip_stop_ats = {}
default_ip_weights = {}
default_ip_types = {}

for image_count in range(default_controlnet_image_count):
image_count += 1
default_ip_images[image_count] = get_config_item_or_set_default(
key=f'default_ip_image_{image_count}',
default_value=None,
validator=lambda x: x is None or isinstance(x, str) and os.path.exists(x),
expected_type=str
)
default_ip_types[image_count] = get_config_item_or_set_default(
key=f'default_ip_type_{image_count}',
default_value=modules.flags.default_ip,
validator=lambda x: x in modules.flags.ip_list,
expected_type=str
)

default_end, default_weight = modules.flags.default_parameters[default_ip_types[image_count]]

default_ip_stop_ats[image_count] = get_config_item_or_set_default(
key=f'default_ip_stop_at_{image_count}',
default_value=default_end,
validator=lambda x: isinstance(x, float) and 0 <= x <= 1,
expected_type=float
)
default_ip_weights[image_count] = get_config_item_or_set_default(
key=f'default_ip_weight_{image_count}',
default_value=default_weight,
validator=lambda x: isinstance(x, float) and 0 <= x <= 2,
expected_type=float
)

default_inpaint_advanced_masking_checkbox = get_config_item_or_set_default(
key='default_inpaint_advanced_masking_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_inpaint_method = get_config_item_or_set_default(
key='default_inpaint_method',
default_value=modules.flags.inpaint_option_default,
Expand Down Expand Up @@ -526,12 +609,6 @@ def init_temp_path(path: str | None, default_path: str) -> str:
validator=lambda x: isinstance(x, int) and 1 <= x <= 5,
expected_type=int
)
default_enhance_checkbox = get_config_item_or_set_default(
key='default_enhance_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)
default_enhance_uov_method = get_config_item_or_set_default(
key='default_enhance_uov_method',
default_value=modules.flags.disabled,
Expand Down Expand Up @@ -590,6 +667,13 @@ def init_temp_path(path: str | None, default_path: str) -> str:
example_inpaint_prompts = [[x] for x in example_inpaint_prompts]
example_enhance_detection_prompts = [[x] for x in example_enhance_detection_prompts]

default_invert_mask_checkbox = get_config_item_or_set_default(
key='default_invert_mask_checkbox',
default_value=False,
validator=lambda x: isinstance(x, bool),
expected_type=bool
)

default_inpaint_mask_model = get_config_item_or_set_default(
key='default_inpaint_mask_model',
default_value='isnet-general-use',
Expand Down
9 changes: 5 additions & 4 deletions modules/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@

refiner_swap_method = 'joint'

default_input_image_tab = 'uov_tab'
input_image_tab_ids = ['uov_tab', 'ip_tab', 'inpaint_tab', 'describe_tab', 'enhance_tab', 'metadata_tab']

cn_ip = "ImagePrompt"
cn_ip_face = "FaceSwap"
cn_canny = "PyraCanny"
Expand All @@ -91,8 +94,8 @@
inpaint_option_modify = 'Modify Content (add objects, change background, etc.)'
inpaint_options = [inpaint_option_default, inpaint_option_detail, inpaint_option_modify]

desc_type_photo = 'Photograph'
desc_type_anime = 'Art/Anime'
describe_type_photo = 'Photograph'
describe_type_anime = 'Art/Anime'

sdxl_aspect_ratios = [
'704*1408', '704*1344', '768*1344', '768*1280', '832*1216', '832*1152',
Expand All @@ -113,8 +116,6 @@ class MetadataScheme(Enum):
(f'{MetadataScheme.A1111.value} (plain text)', MetadataScheme.A1111.value),
]

controlnet_image_count = 4


class OutputFormat(Enum):
PNG = 'png'
Expand Down
2 changes: 1 addition & 1 deletion modules/sdxl_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_random_style(rng: Random) -> str:

def apply_style(style, positive):
p, n = styles[style]
return p.replace('{prompt}', positive).splitlines(), n.splitlines()
return p.replace('{prompt}', positive).splitlines(), n.splitlines(), '{prompt}' in p


def get_words(arrays, total_mult, index):
Expand Down
5 changes: 5 additions & 0 deletions update_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# [2.5.2](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.2)

* Fix not adding positive prompt when styles didn't have a {prompt} placeholder in the positive prompt
* Extend config settings for input image, see list in [PR](https://github.com/lllyasviel/Fooocus/pull/3382)

# [2.5.1](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.1)

* Update download URL in readme
Expand Down
Loading

0 comments on commit 6eead9e

Please sign in to comment.