mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8da1d3ff68 | ||
|
|
710a9fa2c5 | ||
|
|
251a130f06 | ||
|
|
0a87da7dc1 | ||
|
|
1d98d1c760 | ||
|
|
1068d3fde4 | ||
|
|
082a5262b0 | ||
|
|
14895ebb13 | ||
|
|
b0d16a3aa7 | ||
|
|
fd74b57f56 | ||
|
|
8bd9ea1dbf | ||
|
|
ee12d114c1 | ||
|
|
2c78cec01d | ||
|
|
ef0acca9f9 | ||
|
|
60af8d2d84 | ||
|
|
39d07bf0f3 | ||
|
|
f0dcf5a911 | ||
|
|
c4d5b160be | ||
|
|
2f08cb4360 | ||
|
|
da3d4d006f | ||
|
|
c2dc17e883 | ||
|
|
1a53e0676a | ||
|
|
a5040f6218 | ||
|
|
3f25b885a7 | ||
|
|
e36fa0b5f7 | ||
|
|
1be3c504ed |
+1
-1
@@ -1 +1 @@
|
||||
* @mashb1t
|
||||
* @lllyasviel
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -216,9 +216,9 @@ def is_url(url_or_filename):
|
||||
def load_checkpoint(model,url_or_filename):
|
||||
if is_url(url_or_filename):
|
||||
cached_file = download_cached_file(url_or_filename, check_hash=False, progress=True)
|
||||
checkpoint = torch.load(cached_file, map_location='cpu')
|
||||
checkpoint = torch.load(cached_file, map_location='cpu', weights_only=True)
|
||||
elif os.path.isfile(url_or_filename):
|
||||
checkpoint = torch.load(url_or_filename, map_location='cpu')
|
||||
checkpoint = torch.load(url_or_filename, map_location='cpu', weights_only=True)
|
||||
else:
|
||||
raise RuntimeError('checkpoint url or path is invalid')
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ def blip_nlvr(pretrained='',**kwargs):
|
||||
def load_checkpoint(model,url_or_filename):
|
||||
if is_url(url_or_filename):
|
||||
cached_file = download_cached_file(url_or_filename, check_hash=False, progress=True)
|
||||
checkpoint = torch.load(cached_file, map_location='cpu')
|
||||
checkpoint = torch.load(cached_file, map_location='cpu', weights_only=True)
|
||||
elif os.path.isfile(url_or_filename):
|
||||
checkpoint = torch.load(url_or_filename, map_location='cpu')
|
||||
checkpoint = torch.load(url_or_filename, map_location='cpu', weights_only=True)
|
||||
else:
|
||||
raise RuntimeError('checkpoint url or path is invalid')
|
||||
state_dict = checkpoint['model']
|
||||
|
||||
@@ -19,7 +19,7 @@ def init_detection_model(model_name, half=False, device='cuda', model_rootpath=N
|
||||
url=model_url, model_dir='facexlib/weights', progress=True, file_name=None, save_dir=model_rootpath)
|
||||
|
||||
# TODO: clean pretrained model
|
||||
load_net = torch.load(model_path, map_location=lambda storage, loc: storage)
|
||||
load_net = torch.load(model_path, map_location=lambda storage, loc: storage, weights_only=True)
|
||||
# remove unnecessary 'module.'
|
||||
for k, v in deepcopy(load_net).items():
|
||||
if k.startswith('module.'):
|
||||
|
||||
@@ -17,7 +17,7 @@ def init_parsing_model(model_name='bisenet', half=False, device='cuda', model_ro
|
||||
|
||||
model_path = load_file_from_url(
|
||||
url=model_url, model_dir='facexlib/weights', progress=True, file_name=None, save_dir=model_rootpath)
|
||||
load_net = torch.load(model_path, map_location=lambda storage, loc: storage)
|
||||
load_net = torch.load(model_path, map_location=lambda storage, loc: storage, weights_only=True)
|
||||
model.load_state_dict(load_net, strict=True)
|
||||
model.eval()
|
||||
model = model.to(device)
|
||||
|
||||
@@ -104,7 +104,7 @@ def load_ip_adapter(clip_vision_path, ip_negative_path, ip_adapter_path):
|
||||
offload_device = torch.device('cpu')
|
||||
|
||||
use_fp16 = model_management.should_use_fp16(device=load_device)
|
||||
ip_state_dict = torch.load(ip_adapter_path, map_location="cpu")
|
||||
ip_state_dict = torch.load(ip_adapter_path, map_location="cpu", weights_only=True)
|
||||
plus = "latents" in ip_state_dict["image_proj"]
|
||||
cross_attention_dim = ip_state_dict["ip_adapter"]["1.to_k_ip.weight"].shape[1]
|
||||
sdxl = cross_attention_dim == 2048
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
version = '2.5.1'
|
||||
version = '2.5.5'
|
||||
@@ -17,6 +17,7 @@
|
||||
"Content Type": "Content Type",
|
||||
"Photograph": "Photograph",
|
||||
"Art/Anime": "Art/Anime",
|
||||
"Apply Styles": "Apply Styles",
|
||||
"Describe this Image into Prompt": "Describe this Image into Prompt",
|
||||
"Image Size and Recommended Size": "Image Size and Recommended Size",
|
||||
"Upscale or Variation:": "Upscale or Variation:",
|
||||
|
||||
@@ -80,12 +80,13 @@ if args.gpu_device_id is not None:
|
||||
os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_device_id)
|
||||
print("Set device to:", args.gpu_device_id)
|
||||
|
||||
if args.hf_mirror is not None :
|
||||
if args.hf_mirror is not None:
|
||||
os.environ['HF_MIRROR'] = str(args.hf_mirror)
|
||||
print("Set hf_mirror to:", args.hf_mirror)
|
||||
|
||||
from modules import config
|
||||
from modules.hash_cache import init_cache
|
||||
|
||||
os.environ["U2NET_HOME"] = config.path_inpaint
|
||||
|
||||
os.environ['GRADIO_TEMP_DIR'] = config.temp_path
|
||||
@@ -100,6 +101,8 @@ if config.temp_path_cleanup_on_launch:
|
||||
|
||||
|
||||
def download_models(default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads, vae_downloads):
|
||||
from modules.util import get_file_from_folder_list
|
||||
|
||||
for file_name, url in vae_approx_filenames:
|
||||
load_file_from_url(url=url, model_dir=config.path_vae_approx, file_name=file_name)
|
||||
|
||||
@@ -114,9 +117,9 @@ def download_models(default_model, previous_default_models, checkpoint_downloads
|
||||
return default_model, checkpoint_downloads
|
||||
|
||||
if not args.always_download_new_model:
|
||||
if not os.path.exists(os.path.join(config.paths_checkpoints[0], default_model)):
|
||||
if not os.path.isfile(get_file_from_folder_list(default_model, config.paths_checkpoints)):
|
||||
for alternative_model_name in previous_default_models:
|
||||
if os.path.exists(os.path.join(config.paths_checkpoints[0], alternative_model_name)):
|
||||
if os.path.isfile(get_file_from_folder_list(alternative_model_name, config.paths_checkpoints)):
|
||||
print(f'You do not have [{default_model}] but you have [{alternative_model_name}].')
|
||||
print(f'Fooocus will use [{alternative_model_name}] to avoid downloading new models, '
|
||||
f'but you are not using the latest models.')
|
||||
@@ -126,11 +129,13 @@ def download_models(default_model, previous_default_models, checkpoint_downloads
|
||||
break
|
||||
|
||||
for file_name, url in checkpoint_downloads.items():
|
||||
load_file_from_url(url=url, model_dir=config.paths_checkpoints[0], file_name=file_name)
|
||||
model_dir = os.path.dirname(get_file_from_folder_list(file_name, config.paths_checkpoints))
|
||||
load_file_from_url(url=url, model_dir=model_dir, file_name=file_name)
|
||||
for file_name, url in embeddings_downloads.items():
|
||||
load_file_from_url(url=url, model_dir=config.path_embeddings, file_name=file_name)
|
||||
for file_name, url in lora_downloads.items():
|
||||
load_file_from_url(url=url, model_dir=config.paths_loras[0], file_name=file_name)
|
||||
model_dir = os.path.dirname(get_file_from_folder_list(file_name, config.paths_loras))
|
||||
load_file_from_url(url=url, model_dir=model_dir, file_name=file_name)
|
||||
for file_name, url in vae_downloads.items():
|
||||
load_file_from_url(url=url, model_dir=config.path_vae, file_name=file_name)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class CLIPEmbeddingNoiseAugmentation(ImageConcatWithNoiseAugmentation):
|
||||
if clip_stats_path is None:
|
||||
clip_mean, clip_std = torch.zeros(timestep_dim), torch.ones(timestep_dim)
|
||||
else:
|
||||
clip_mean, clip_std = torch.load(clip_stats_path, map_location="cpu")
|
||||
clip_mean, clip_std = torch.load(clip_stats_path, map_location="cpu", weights_only=True)
|
||||
self.register_buffer("data_mean", clip_mean[None, :], persistent=False)
|
||||
self.register_buffer("data_std", clip_std[None, :], persistent=False)
|
||||
self.time_embed = Timestep(timestep_dim)
|
||||
|
||||
@@ -326,7 +326,7 @@ def load_embed(embedding_name, embedding_directory, embedding_size, embed_key=No
|
||||
except:
|
||||
embed_out = safe_load_embed_zip(embed_path)
|
||||
else:
|
||||
embed = torch.load(embed_path, map_location="cpu")
|
||||
embed = torch.load(embed_path, map_location="cpu", weights_only=True)
|
||||
except Exception as e:
|
||||
print(traceback.format_exc())
|
||||
print()
|
||||
|
||||
@@ -377,15 +377,15 @@ class VQAutoEncoder(nn.Module):
|
||||
)
|
||||
|
||||
if model_path is not None:
|
||||
chkpt = torch.load(model_path, map_location="cpu")
|
||||
chkpt = torch.load(model_path, map_location="cpu", weights_only=True)
|
||||
if "params_ema" in chkpt:
|
||||
self.load_state_dict(
|
||||
torch.load(model_path, map_location="cpu")["params_ema"]
|
||||
torch.load(model_path, map_location="cpu", weights_only=True)["params_ema"]
|
||||
)
|
||||
logger.info(f"vqgan is loaded from: {model_path} [params_ema]")
|
||||
elif "params" in chkpt:
|
||||
self.load_state_dict(
|
||||
torch.load(model_path, map_location="cpu")["params"]
|
||||
torch.load(model_path, map_location="cpu", weights_only=True)["params"]
|
||||
)
|
||||
logger.info(f"vqgan is loaded from: {model_path} [params]")
|
||||
else:
|
||||
|
||||
@@ -273,8 +273,8 @@ class GFPGANBilinear(nn.Module):
|
||||
if decoder_load_path:
|
||||
self.stylegan_decoder.load_state_dict(
|
||||
torch.load(
|
||||
decoder_load_path, map_location=lambda storage, loc: storage
|
||||
)["params_ema"]
|
||||
decoder_load_path, map_location=lambda storage, loc: storage,
|
||||
weights_only=True)["params_ema"]
|
||||
)
|
||||
# fix decoder without updating params
|
||||
if fix_decoder:
|
||||
|
||||
@@ -373,8 +373,8 @@ class GFPGANv1(nn.Module):
|
||||
if decoder_load_path:
|
||||
self.stylegan_decoder.load_state_dict(
|
||||
torch.load(
|
||||
decoder_load_path, map_location=lambda storage, loc: storage
|
||||
)["params_ema"]
|
||||
decoder_load_path, map_location=lambda storage, loc: storage,
|
||||
weights_only=True)["params_ema"]
|
||||
)
|
||||
# fix decoder without updating params
|
||||
if fix_decoder:
|
||||
|
||||
@@ -284,8 +284,8 @@ class GFPGANv1Clean(nn.Module):
|
||||
if decoder_load_path:
|
||||
self.stylegan_decoder.load_state_dict(
|
||||
torch.load(
|
||||
decoder_load_path, map_location=lambda storage, loc: storage
|
||||
)["params_ema"]
|
||||
decoder_load_path, map_location=lambda storage, loc: storage,
|
||||
weights_only=True)["params_ema"]
|
||||
)
|
||||
# fix decoder without updating params
|
||||
if fix_decoder:
|
||||
|
||||
+12
-3
@@ -9,7 +9,7 @@ patch_all()
|
||||
|
||||
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
|
||||
@@ -101,7 +101,7 @@ class AsyncTask:
|
||||
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()
|
||||
@@ -689,13 +689,20 @@ def worker():
|
||||
|
||||
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)
|
||||
|
||||
@@ -1216,6 +1223,8 @@ def worker():
|
||||
height, width, _ = async_task.enhance_input_image.shape
|
||||
# input image already provided, processing is skipped
|
||||
steps = 0
|
||||
yield_result(async_task, async_task.enhance_input_image, current_progress, async_task.black_out_nsfw, False,
|
||||
async_task.disable_intermediate_results)
|
||||
|
||||
all_steps = steps * async_task.image_number
|
||||
|
||||
|
||||
+108
-7
@@ -403,12 +403,36 @@ default_performance = get_config_item_or_set_default(
|
||||
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,
|
||||
@@ -469,6 +493,69 @@ default_inpaint_engine_version = get_config_item_or_set_default(
|
||||
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 == 'None' or isinstance(x, str) and os.path.exists(x),
|
||||
expected_type=str
|
||||
)
|
||||
|
||||
if default_ip_images[image_count] == 'None':
|
||||
default_ip_images[image_count] = None
|
||||
|
||||
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,
|
||||
@@ -526,12 +613,6 @@ default_enhance_tabs = get_config_item_or_set_default(
|
||||
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,
|
||||
@@ -590,6 +671,13 @@ metadata_created_by = get_config_item_or_set_default(
|
||||
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',
|
||||
@@ -614,10 +702,23 @@ default_inpaint_mask_cloth_category = get_config_item_or_set_default(
|
||||
default_inpaint_mask_sam_model = get_config_item_or_set_default(
|
||||
key='default_inpaint_mask_sam_model',
|
||||
default_value='vit_b',
|
||||
validator=lambda x: x in [y[1] for y in modules.flags.inpaint_mask_sam_model if y[1] == x],
|
||||
validator=lambda x: x in modules.flags.inpaint_mask_sam_model,
|
||||
expected_type=str
|
||||
)
|
||||
|
||||
default_describe_apply_prompts_checkbox = get_config_item_or_set_default(
|
||||
key='default_describe_apply_prompts_checkbox',
|
||||
default_value=True,
|
||||
validator=lambda x: isinstance(x, bool),
|
||||
expected_type=bool
|
||||
)
|
||||
default_describe_content_type = get_config_item_or_set_default(
|
||||
key='default_describe_content_type',
|
||||
default_value=[modules.flags.describe_type_photo],
|
||||
validator=lambda x: all(k in modules.flags.describe_types for k in x),
|
||||
expected_type=list
|
||||
)
|
||||
|
||||
config_dict["default_loras"] = default_loras = default_loras[:default_max_lora_number] + [[True, 'None', 1.0] for _ in range(default_max_lora_number - len(default_loras))]
|
||||
|
||||
# mapping config to meta parameter
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ def get_previewer(model):
|
||||
if vae_approx_filename in VAE_approx_models:
|
||||
VAE_approx_model = VAE_approx_models[vae_approx_filename]
|
||||
else:
|
||||
sd = torch.load(vae_approx_filename, map_location='cpu')
|
||||
sd = torch.load(vae_approx_filename, map_location='cpu', weights_only=True)
|
||||
VAE_approx_model = VAEApprox()
|
||||
VAE_approx_model.load_state_dict(sd)
|
||||
del sd
|
||||
|
||||
+6
-4
@@ -67,6 +67,9 @@ default_vae = 'Default (model)'
|
||||
|
||||
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"
|
||||
@@ -91,8 +94,9 @@ inpaint_option_detail = 'Improve Detail (face, hand, eyes, etc.)'
|
||||
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'
|
||||
describe_types = [describe_type_photo, describe_type_anime]
|
||||
|
||||
sdxl_aspect_ratios = [
|
||||
'704*1408', '704*1344', '768*1344', '768*1280', '832*1216', '832*1152',
|
||||
@@ -113,8 +117,6 @@ metadata_scheme = [
|
||||
(f'{MetadataScheme.A1111.value} (plain text)', MetadataScheme.A1111.value),
|
||||
]
|
||||
|
||||
controlnet_image_count = 4
|
||||
|
||||
|
||||
class OutputFormat(Enum):
|
||||
PNG = 'png'
|
||||
|
||||
@@ -196,7 +196,7 @@ class InpaintWorker:
|
||||
|
||||
if inpaint_head_model is None:
|
||||
inpaint_head_model = InpaintHead()
|
||||
sd = torch.load(inpaint_head_model_path, map_location='cpu')
|
||||
sd = torch.load(inpaint_head_model_path, map_location='cpu', weights_only=True)
|
||||
inpaint_head_model.load_state_dict(sd)
|
||||
|
||||
feed = torch.cat([
|
||||
|
||||
@@ -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):
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ def perform_upscale(img):
|
||||
|
||||
if model is None:
|
||||
model_filename = downloading_upscale_model()
|
||||
sd = torch.load(model_filename)
|
||||
sd = torch.load(model_filename, weights_only=True)
|
||||
sdo = OrderedDict()
|
||||
for k, v in sd.items():
|
||||
sdo[k.replace('residual_block_', 'RDB')] = v
|
||||
|
||||
@@ -119,7 +119,7 @@ See also the common problems and troubleshoots [here](troubleshoot.md).
|
||||
|
||||
### Colab
|
||||
|
||||
(Last tested - 2024 Mar 18 by [mashb1t](https://github.com/mashb1t))
|
||||
(Last tested - 2024 Aug 12 by [mashb1t](https://github.com/mashb1t))
|
||||
|
||||
| Colab | Info
|
||||
| --- | --- |
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
# [2.5.5](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.5)
|
||||
|
||||
* Fix colab inpaint issue by moving an import statement
|
||||
|
||||
# [2.5.4](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.4)
|
||||
|
||||
* Fix validation for default_ip_image_* and default_inpaint_mask_sam_model
|
||||
* Fix enhance mask debugging in combination with image sorting
|
||||
* Fix loading of checkpoints and LoRAs when using multiple directories in config and then switching presets
|
||||
|
||||
# [2.5.3](https://github.com/lllyasviel/Fooocus/releases/tag/v2.5.3)
|
||||
|
||||
* Only load weights from non-safetensors files, preventing harmful code injection
|
||||
* Add checkbox for applying/resetting styles when describing images, also allowing multiple describe content types
|
||||
|
||||
# [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
|
||||
|
||||
@@ -200,19 +200,19 @@ with shared.gradio_root:
|
||||
stop_button.click(stop_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False, _js='cancelGenerateForever')
|
||||
skip_button.click(skip_clicked, inputs=currentTask, outputs=currentTask, queue=False, show_progress=False)
|
||||
with gr.Row(elem_classes='advanced_check_row'):
|
||||
input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check')
|
||||
input_image_checkbox = gr.Checkbox(label='Input Image', value=modules.config.default_image_prompt_checkbox, container=False, elem_classes='min_check')
|
||||
enhance_checkbox = gr.Checkbox(label='Enhance', value=modules.config.default_enhance_checkbox, container=False, elem_classes='min_check')
|
||||
advanced_checkbox = gr.Checkbox(label='Advanced', value=modules.config.default_advanced_checkbox, container=False, elem_classes='min_check')
|
||||
with gr.Row(visible=False) as image_input_panel:
|
||||
with gr.Tabs():
|
||||
with gr.TabItem(label='Upscale or Variation') as uov_tab:
|
||||
with gr.Row(visible=modules.config.default_image_prompt_checkbox) as image_input_panel:
|
||||
with gr.Tabs(selected=modules.config.default_selected_image_input_tab_id):
|
||||
with gr.Tab(label='Upscale or Variation', id='uov_tab') as uov_tab:
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
uov_input_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False)
|
||||
with gr.Column():
|
||||
uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
|
||||
uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=modules.config.default_uov_method)
|
||||
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
with gr.TabItem(label='Image Prompt') as ip_tab:
|
||||
with gr.Tab(label='Image Prompt', id='ip_tab') as ip_tab:
|
||||
with gr.Row():
|
||||
ip_images = []
|
||||
ip_types = []
|
||||
@@ -220,30 +220,29 @@ with shared.gradio_root:
|
||||
ip_weights = []
|
||||
ip_ctrls = []
|
||||
ip_ad_cols = []
|
||||
for _ in range(flags.controlnet_image_count):
|
||||
for image_count in range(modules.config.default_controlnet_image_count):
|
||||
image_count += 1
|
||||
with gr.Column():
|
||||
ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300)
|
||||
ip_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False, height=300, value=modules.config.default_ip_images[image_count])
|
||||
ip_images.append(ip_image)
|
||||
ip_ctrls.append(ip_image)
|
||||
with gr.Column(visible=False) as ad_col:
|
||||
with gr.Column(visible=modules.config.default_image_prompt_advanced_checkbox) as ad_col:
|
||||
with gr.Row():
|
||||
default_end, default_weight = flags.default_parameters[flags.default_ip]
|
||||
|
||||
ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=default_end)
|
||||
ip_stop = gr.Slider(label='Stop At', minimum=0.0, maximum=1.0, step=0.001, value=modules.config.default_ip_stop_ats[image_count])
|
||||
ip_stops.append(ip_stop)
|
||||
ip_ctrls.append(ip_stop)
|
||||
|
||||
ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=default_weight)
|
||||
ip_weight = gr.Slider(label='Weight', minimum=0.0, maximum=2.0, step=0.001, value=modules.config.default_ip_weights[image_count])
|
||||
ip_weights.append(ip_weight)
|
||||
ip_ctrls.append(ip_weight)
|
||||
|
||||
ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=flags.default_ip, container=False)
|
||||
ip_type = gr.Radio(label='Type', choices=flags.ip_list, value=modules.config.default_ip_types[image_count], container=False)
|
||||
ip_types.append(ip_type)
|
||||
ip_ctrls.append(ip_type)
|
||||
|
||||
ip_type.change(lambda x: flags.default_parameters[x], inputs=[ip_type], outputs=[ip_stop, ip_weight], queue=False, show_progress=False)
|
||||
ip_ad_cols.append(ad_col)
|
||||
ip_advanced = gr.Checkbox(label='Advanced', value=False, container=False)
|
||||
ip_advanced = gr.Checkbox(label='Advanced', value=modules.config.default_image_prompt_advanced_checkbox, container=False)
|
||||
gr.HTML('* \"Image Prompt\" is powered by Fooocus Image Mixture Engine (v1.0.1). <a href="https://github.com/lllyasviel/Fooocus/discussions/557" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
|
||||
def ip_advance_checked(x):
|
||||
@@ -256,11 +255,11 @@ with shared.gradio_root:
|
||||
outputs=ip_ad_cols + ip_types + ip_stops + ip_weights,
|
||||
queue=False, show_progress=False)
|
||||
|
||||
with gr.TabItem(label='Inpaint or Outpaint') as inpaint_tab:
|
||||
with gr.Tab(label='Inpaint or Outpaint', id='inpaint_tab') as inpaint_tab:
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
inpaint_input_image = grh.Image(label='Image', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", elem_id='inpaint_canvas', show_label=False)
|
||||
inpaint_advanced_masking_checkbox = gr.Checkbox(label='Enable Advanced Masking Features', value=False)
|
||||
inpaint_advanced_masking_checkbox = gr.Checkbox(label='Enable Advanced Masking Features', value=modules.config.default_inpaint_advanced_masking_checkbox)
|
||||
inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.config.default_inpaint_method, label='Method')
|
||||
inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
|
||||
outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
|
||||
@@ -271,9 +270,9 @@ with shared.gradio_root:
|
||||
gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
|
||||
|
||||
with gr.Column(visible=False) as inpaint_mask_generation_col:
|
||||
with gr.Column(visible=modules.config.default_inpaint_advanced_masking_checkbox) as inpaint_mask_generation_col:
|
||||
inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", mask_opacity=1, elem_id='inpaint_mask_canvas')
|
||||
invert_mask_checkbox = gr.Checkbox(label='Invert Mask When Generating', value=False)
|
||||
invert_mask_checkbox = gr.Checkbox(label='Invert Mask When Generating', value=modules.config.default_invert_mask_checkbox)
|
||||
inpaint_mask_model = gr.Dropdown(label='Mask generation model',
|
||||
choices=flags.inpaint_mask_models,
|
||||
value=modules.config.default_inpaint_mask_model)
|
||||
@@ -333,33 +332,34 @@ with shared.gradio_root:
|
||||
example_inpaint_mask_dino_prompt_text],
|
||||
queue=False, show_progress=False)
|
||||
|
||||
with gr.TabItem(label='Describe') as desc_tab:
|
||||
with gr.Tab(label='Describe', id='describe_tab') as describe_tab:
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
desc_input_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False)
|
||||
describe_input_image = grh.Image(label='Image', source='upload', type='numpy', show_label=False)
|
||||
with gr.Column():
|
||||
desc_method = gr.Radio(
|
||||
describe_methods = gr.CheckboxGroup(
|
||||
label='Content Type',
|
||||
choices=[flags.desc_type_photo, flags.desc_type_anime],
|
||||
value=flags.desc_type_photo)
|
||||
desc_btn = gr.Button(value='Describe this Image into Prompt')
|
||||
desc_image_size = gr.Textbox(label='Image Size and Recommended Size', elem_id='desc_image_size', visible=False)
|
||||
choices=flags.describe_types,
|
||||
value=modules.config.default_describe_content_type)
|
||||
describe_apply_styles = gr.Checkbox(label='Apply Styles', value=modules.config.default_describe_apply_prompts_checkbox)
|
||||
describe_btn = gr.Button(value='Describe this Image into Prompt')
|
||||
describe_image_size = gr.Textbox(label='Image Size and Recommended Size', elem_id='describe_image_size', visible=False)
|
||||
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/1363" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
|
||||
def trigger_show_image_properties(image):
|
||||
value = modules.util.get_image_size_info(image, modules.flags.sdxl_aspect_ratios)
|
||||
return gr.update(value=value, visible=True)
|
||||
|
||||
desc_input_image.upload(trigger_show_image_properties, inputs=desc_input_image,
|
||||
outputs=desc_image_size, show_progress=False, queue=False)
|
||||
describe_input_image.upload(trigger_show_image_properties, inputs=describe_input_image,
|
||||
outputs=describe_image_size, show_progress=False, queue=False)
|
||||
|
||||
with gr.TabItem(label='Enhance') as enhance_tab:
|
||||
with gr.Tab(label='Enhance', id='enhance_tab') as enhance_tab:
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
enhance_input_image = grh.Image(label='Use with Enhance, skips image generation', source='upload', type='numpy')
|
||||
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/3281" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
|
||||
with gr.TabItem(label='Metadata') as metadata_tab:
|
||||
with gr.Tab(label='Metadata', id='metadata_tab') as metadata_tab:
|
||||
with gr.Column():
|
||||
metadata_input_image = grh.Image(label='For images created by Fooocus', source='upload', type='pil')
|
||||
metadata_json = gr.JSON(label='Metadata')
|
||||
@@ -382,7 +382,7 @@ with shared.gradio_root:
|
||||
|
||||
with gr.Row(visible=modules.config.default_enhance_checkbox) as enhance_input_panel:
|
||||
with gr.Tabs():
|
||||
with gr.TabItem(label='Upscale or Variation'):
|
||||
with gr.Tab(label='Upscale or Variation'):
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
enhance_uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list,
|
||||
@@ -407,7 +407,7 @@ with shared.gradio_root:
|
||||
enhance_inpaint_engine_ctrls = []
|
||||
enhance_inpaint_update_ctrls = []
|
||||
for index in range(modules.config.default_enhance_tabs):
|
||||
with gr.TabItem(label=f'#{index + 1}') as enhance_tab_item:
|
||||
with gr.Tab(label=f'#{index + 1}') as enhance_tab_item:
|
||||
enhance_enabled = gr.Checkbox(label='Enable', value=False, elem_classes='min_check',
|
||||
container=False)
|
||||
|
||||
@@ -549,7 +549,7 @@ with shared.gradio_root:
|
||||
uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
describe_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
enhance_tab.select(lambda: 'enhance', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
metadata_tab.select(lambda: 'metadata', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
|
||||
enhance_checkbox.change(lambda x: gr.update(visible=x), inputs=enhance_checkbox,
|
||||
@@ -693,9 +693,9 @@ with shared.gradio_root:
|
||||
value=modules.config.default_sample_sharpness,
|
||||
info='Higher value means image and texture are sharper.')
|
||||
gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117" target="_blank">\U0001F4D4 Documentation</a>')
|
||||
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=False, container=False)
|
||||
dev_mode = gr.Checkbox(label='Developer Debug Mode', value=modules.config.default_developer_debug_mode_checkbox, container=False)
|
||||
|
||||
with gr.Column(visible=False) as dev_tools:
|
||||
with gr.Column(visible=modules.config.default_developer_debug_mode_checkbox) as dev_tools:
|
||||
with gr.Tab(label='Debug Tools'):
|
||||
adm_scaler_positive = gr.Slider(label='Positive ADM Guidance Scaler', minimum=0.1, maximum=3.0,
|
||||
step=0.001, value=1.5, info='The scaler multiplied to positive ADM (use 1.0 to disable). ')
|
||||
@@ -1061,30 +1061,54 @@ with shared.gradio_root:
|
||||
gr.Audio(interactive=False, value=notification_file, elem_id='audio_notification', visible=False)
|
||||
break
|
||||
|
||||
def trigger_describe(mode, img):
|
||||
if mode == flags.desc_type_photo:
|
||||
from extras.interrogate import default_interrogator as default_interrogator_photo
|
||||
return default_interrogator_photo(img), ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"]
|
||||
if mode == flags.desc_type_anime:
|
||||
from extras.wd14tagger import default_interrogator as default_interrogator_anime
|
||||
return default_interrogator_anime(img), ["Fooocus V2", "Fooocus Masterpiece"]
|
||||
return mode, ["Fooocus V2"]
|
||||
def trigger_describe(modes, img, apply_styles):
|
||||
describe_prompts = []
|
||||
styles = set()
|
||||
|
||||
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
|
||||
outputs=[prompt, style_selections], show_progress=True, queue=True)
|
||||
if flags.describe_type_photo in modes:
|
||||
from extras.interrogate import default_interrogator as default_interrogator_photo
|
||||
describe_prompts.append(default_interrogator_photo(img))
|
||||
styles.update(["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"])
|
||||
|
||||
if flags.describe_type_anime in modes:
|
||||
from extras.wd14tagger import default_interrogator as default_interrogator_anime
|
||||
describe_prompts.append(default_interrogator_anime(img))
|
||||
styles.update(["Fooocus V2", "Fooocus Masterpiece"])
|
||||
|
||||
if len(styles) == 0 or not apply_styles:
|
||||
styles = gr.update()
|
||||
else:
|
||||
styles = list(styles)
|
||||
|
||||
if len(describe_prompts) == 0:
|
||||
describe_prompt = gr.update()
|
||||
else:
|
||||
describe_prompt = ', '.join(describe_prompts)
|
||||
|
||||
return describe_prompt, styles
|
||||
|
||||
describe_btn.click(trigger_describe, inputs=[describe_methods, describe_input_image, describe_apply_styles],
|
||||
outputs=[prompt, style_selections], show_progress=True, queue=True) \
|
||||
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \
|
||||
.then(lambda: None, _js='()=>{refresh_style_localization();}')
|
||||
|
||||
if args_manager.args.enable_auto_describe_image:
|
||||
def trigger_auto_describe(mode, img, prompt):
|
||||
def trigger_auto_describe(mode, img, prompt, apply_styles):
|
||||
# keep prompt if not empty
|
||||
if prompt == '':
|
||||
return trigger_describe(mode, img)
|
||||
return trigger_describe(mode, img, apply_styles)
|
||||
return gr.update(), gr.update()
|
||||
|
||||
uov_input_image.upload(trigger_auto_describe, inputs=[desc_method, uov_input_image, prompt],
|
||||
outputs=[prompt, style_selections], show_progress=True, queue=True)
|
||||
uov_input_image.upload(trigger_auto_describe, inputs=[describe_methods, uov_input_image, prompt, describe_apply_styles],
|
||||
outputs=[prompt, style_selections], show_progress=True, queue=True) \
|
||||
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \
|
||||
.then(lambda: None, _js='()=>{refresh_style_localization();}')
|
||||
|
||||
enhance_input_image.upload(lambda: gr.update(value=True), outputs=enhance_checkbox, queue=False, show_progress=False) \
|
||||
.then(trigger_auto_describe, inputs=[desc_method, enhance_input_image, prompt], outputs=[prompt, style_selections], show_progress=True, queue=True)
|
||||
.then(trigger_auto_describe, inputs=[describe_methods, enhance_input_image, prompt, describe_apply_styles],
|
||||
outputs=[prompt, style_selections], show_progress=True, queue=True) \
|
||||
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \
|
||||
.then(lambda: None, _js='()=>{refresh_style_localization();}')
|
||||
|
||||
def dump_default_english_config():
|
||||
from modules.localization import dump_english_config
|
||||
|
||||
Reference in New Issue
Block a user