some fix (#560)
* download upscaler only when user use it * use better method
This commit is contained in:
parent
6faaac333b
commit
f170e1c08e
|
|
@ -1 +1 @@
|
|||
version = '2.1.0'
|
||||
version = '2.1.1'
|
||||
|
|
|
|||
|
|
@ -71,12 +71,6 @@ vae_approx_filenames = [
|
|||
]
|
||||
|
||||
|
||||
upscaler_filenames = [
|
||||
('fooocus_upscaler_s409985e5.bin',
|
||||
'https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_upscaler_s409985e5.bin')
|
||||
]
|
||||
|
||||
|
||||
def download_models():
|
||||
for file_name, url in model_filenames:
|
||||
load_file_from_url(url=url, model_dir=modelfile_path, file_name=file_name)
|
||||
|
|
@ -84,8 +78,6 @@ def download_models():
|
|||
load_file_from_url(url=url, model_dir=lorafile_path, file_name=file_name)
|
||||
for file_name, url in vae_approx_filenames:
|
||||
load_file_from_url(url=url, model_dir=vae_approx_path, file_name=file_name)
|
||||
for file_name, url in upscaler_filenames:
|
||||
load_file_from_url(url=url, model_dir=upscale_models_path, file_name=file_name)
|
||||
|
||||
load_file_from_url(
|
||||
url='https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_expansion.bin',
|
||||
|
|
|
|||
|
|
@ -163,6 +163,8 @@ def worker():
|
|||
else:
|
||||
steps = 36
|
||||
switch = 24
|
||||
progressbar(13, 'Downloading upscale models ...')
|
||||
modules.path.downloading_upscale_model()
|
||||
if (current_tab == 'inpaint' or (current_tab == 'ip' and advanced_parameters.mixing_image_prompt_and_inpaint))\
|
||||
and isinstance(inpaint_input_image, dict):
|
||||
inpaint_image = inpaint_input_image['image']
|
||||
|
|
@ -170,7 +172,7 @@ def worker():
|
|||
inpaint_image = HWC3(inpaint_image)
|
||||
if isinstance(inpaint_image, np.ndarray) and isinstance(inpaint_mask, np.ndarray) \
|
||||
and (np.any(inpaint_mask > 127) or len(outpaint_selections) > 0):
|
||||
progressbar(1, 'Downloading inpainter ...')
|
||||
progressbar(13, 'Downloading inpainter ...')
|
||||
inpaint_head_model_path, inpaint_patch_model_path = modules.path.downloading_inpaint_models()
|
||||
loras += [(inpaint_patch_model_path, 1.0)]
|
||||
goals.append('inpaint')
|
||||
|
|
@ -179,14 +181,14 @@ def worker():
|
|||
advanced_parameters.mixing_image_prompt_and_inpaint or \
|
||||
advanced_parameters.mixing_image_prompt_and_vary_upscale:
|
||||
goals.append('cn')
|
||||
progressbar(1, 'Downloading control models ...')
|
||||
progressbar(13, 'Downloading control models ...')
|
||||
if len(cn_tasks[flags.cn_canny]) > 0:
|
||||
controlnet_canny_path = modules.path.downloading_controlnet_canny()
|
||||
if len(cn_tasks[flags.cn_cpds]) > 0:
|
||||
controlnet_cpds_path = modules.path.downloading_controlnet_cpds()
|
||||
if len(cn_tasks[flags.cn_ip]) > 0:
|
||||
clip_vision_path, ip_negative_path, ip_adapter_path = modules.path.downloading_ip_adapters()
|
||||
progressbar(1, 'Loading control models ...')
|
||||
progressbar(13, 'Loading control models ...')
|
||||
|
||||
# Load or unload CNs
|
||||
pipeline.refresh_controlnets([controlnet_canny_path, controlnet_cpds_path])
|
||||
|
|
@ -436,7 +438,14 @@ def worker():
|
|||
for task in cn_tasks[flags.cn_ip]:
|
||||
cn_img, cn_stop, cn_weight = task
|
||||
cn_img = HWC3(cn_img)
|
||||
|
||||
# https://github.com/tencent-ailab/IP-Adapter/blob/d580c50a291566bbf9fc7ac0f760506607297e6d/README.md?plain=1#L75
|
||||
cn_img = resize_image(HWC3(cn_img), width=224, height=224, resize_mode=0)
|
||||
|
||||
task[0] = ip_adapter.preprocess(cn_img)
|
||||
if advanced_parameters.debugging_cn_preprocessor:
|
||||
outputs.append(['results', [cn_img]])
|
||||
return
|
||||
|
||||
if len(cn_tasks[flags.cn_ip]) > 0:
|
||||
pipeline.final_unet = ip_adapter.patch_model(pipeline.final_unet, cn_tasks[flags.cn_ip])
|
||||
|
|
|
|||
|
|
@ -136,4 +136,13 @@ def downloading_ip_adapters():
|
|||
return results
|
||||
|
||||
|
||||
def downloading_upscale_model():
|
||||
load_file_from_url(
|
||||
url='https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_upscaler_s409985e5.bin',
|
||||
model_dir=upscale_models_path,
|
||||
file_name='fooocus_upscaler_s409985e5.bin'
|
||||
)
|
||||
return os.path.join(upscale_models_path, 'fooocus_upscaler_s409985e5.bin')
|
||||
|
||||
|
||||
update_all_model_names()
|
||||
|
|
|
|||
Loading…
Reference in New Issue