mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-03-14 01:19:49 +00:00
forge 2.0.0
see also discussions
This commit is contained in:
@@ -8,7 +8,7 @@ dump_cache = modules.cache.dump_cache
|
||||
cache = modules.cache.cache
|
||||
|
||||
|
||||
def calculate_sha256(filename):
|
||||
def calculate_sha256_real(filename):
|
||||
hash_sha256 = hashlib.sha256()
|
||||
blksize = 1024 * 1024
|
||||
|
||||
@@ -19,6 +19,17 @@ def calculate_sha256(filename):
|
||||
return hash_sha256.hexdigest()
|
||||
|
||||
|
||||
def calculate_sha256(filename):
|
||||
return forge_fake_calculate_sha256(filename)
|
||||
|
||||
|
||||
def forge_fake_calculate_sha256(filename):
|
||||
basename = os.path.basename(filename)
|
||||
hash_sha256 = hashlib.sha256()
|
||||
hash_sha256.update(basename.encode('utf-8'))
|
||||
return hash_sha256.hexdigest()
|
||||
|
||||
|
||||
def sha256_from_cache(filename, title, use_addnet_hash=False):
|
||||
hashes = cache("hashes-addnet") if use_addnet_hash else cache("hashes")
|
||||
try:
|
||||
@@ -49,11 +60,7 @@ def sha256(filename, title, use_addnet_hash=False):
|
||||
return None
|
||||
|
||||
print(f"Calculating sha256 for {filename}: ", end='')
|
||||
if use_addnet_hash:
|
||||
with open(filename, "rb") as file:
|
||||
sha256_value = addnet_hash_safetensors(file)
|
||||
else:
|
||||
sha256_value = calculate_sha256(filename)
|
||||
sha256_value = forge_fake_calculate_sha256(filename)
|
||||
print(f"{sha256_value}")
|
||||
|
||||
hashes[title] = {
|
||||
|
||||
@@ -361,8 +361,8 @@ def requirements_met(requirements_file):
|
||||
|
||||
|
||||
def prepare_environment():
|
||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121")
|
||||
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url {torch_index_url}")
|
||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu124")
|
||||
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.4.0 torchvision==0.19.0 --extra-index-url {torch_index_url}")
|
||||
if args.use_ipex:
|
||||
if platform.system() == "Windows":
|
||||
# The "Nuullll/intel-extension-for-pytorch" wheels were built from IPEX source for Intel Arc GPU: https://github.com/intel/intel-extension-for-pytorch/tree/xpu-main
|
||||
@@ -386,7 +386,7 @@ def prepare_environment():
|
||||
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
|
||||
requirements_file_for_npu = os.environ.get('REQS_FILE_FOR_NPU', "requirements_npu.txt")
|
||||
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23.post1')
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.27.post2')
|
||||
clip_package = os.environ.get('CLIP_PACKAGE', "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip")
|
||||
openclip_package = os.environ.get('OPENCLIP_PACKAGE', "https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip")
|
||||
|
||||
|
||||
@@ -780,11 +780,12 @@ need_global_unload = False
|
||||
def process_images(p: StableDiffusionProcessing) -> Processed:
|
||||
global need_global_unload
|
||||
|
||||
if need_global_unload:
|
||||
need_global_unload = False
|
||||
p.sd_model, just_reloaded = forge_model_reload()
|
||||
|
||||
if need_global_unload and not just_reloaded:
|
||||
memory_management.unload_all_models()
|
||||
|
||||
p.sd_model = forge_model_reload()
|
||||
need_global_unload = False
|
||||
|
||||
if p.scripts is not None:
|
||||
p.scripts.before_process(p)
|
||||
|
||||
@@ -159,7 +159,7 @@ def setup_model():
|
||||
|
||||
|
||||
def checkpoint_tiles(use_short=False):
|
||||
return [x.short_title if use_short else x.title for x in checkpoints_list.values()]
|
||||
return [x.short_title if use_short else x.name for x in checkpoints_list.values()]
|
||||
|
||||
|
||||
def list_models():
|
||||
@@ -475,7 +475,7 @@ def forge_model_reload():
|
||||
current_hash = str(model_data.forge_loading_parameters)
|
||||
|
||||
if model_data.forge_hash == current_hash:
|
||||
return model_data.sd_model
|
||||
return model_data.sd_model, False
|
||||
|
||||
print('Loading Model: ' + str(model_data.forge_loading_parameters))
|
||||
|
||||
@@ -536,4 +536,4 @@ def forge_model_reload():
|
||||
|
||||
model_data.forge_hash = current_hash
|
||||
|
||||
return sd_model
|
||||
return sd_model, True
|
||||
|
||||
@@ -16,7 +16,7 @@ parser = shared_cmd_options.parser
|
||||
|
||||
batch_cond_uncond = True # old field, unused now in favor of shared.opts.batch_cond_uncond
|
||||
parallel_processing_allowed = True
|
||||
styles_filename = cmd_opts.styles_file = cmd_opts.styles_file if len(cmd_opts.styles_file) > 0 else [os.path.join(data_path, 'styles.csv')]
|
||||
styles_filename = cmd_opts.styles_file = cmd_opts.styles_file if len(cmd_opts.styles_file) > 0 else [os.path.join(data_path, 'styles.csv'), os.path.join(data_path, 'styles_integrated.csv')]
|
||||
config_filename = cmd_opts.ui_settings_file
|
||||
hide_dirs = {"visible": not cmd_opts.hide_ui_dir_config}
|
||||
|
||||
|
||||
@@ -307,8 +307,7 @@ def create_ui():
|
||||
|
||||
elif category == "cfg":
|
||||
with gr.Row():
|
||||
from backend.args import args
|
||||
distilled_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.5, label='Distilled CFG Scale', value=3.5, elem_id="txt2img_distilled_cfg_scale", visible=args.i_am_lllyasviel)
|
||||
distilled_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.5, label='Distilled CFG Scale', value=3.5, elem_id="txt2img_distilled_cfg_scale")
|
||||
with gr.Row():
|
||||
cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="txt2img_cfg_scale")
|
||||
cfg_scale.change(lambda x: gr.update(interactive=(x != 1)), inputs=[cfg_scale], outputs=[toprow.negative_prompt], queue=False, show_progress=False)
|
||||
@@ -649,8 +648,7 @@ def create_ui():
|
||||
|
||||
elif category == "cfg":
|
||||
with gr.Row():
|
||||
from backend.args import args as backend_args
|
||||
distilled_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.5, label='Distilled CFG Scale', value=3.5, elem_id="img2img_distilled_cfg_scale", visible=backend_args.i_am_lllyasviel)
|
||||
distilled_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.5, label='Distilled CFG Scale', value=3.5, elem_id="img2img_distilled_cfg_scale")
|
||||
with gr.Row():
|
||||
cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="img2img_cfg_scale")
|
||||
image_cfg_scale = gr.Slider(minimum=0, maximum=3.0, step=0.05, label='Image CFG Scale', value=1.5, elem_id="img2img_image_cfg_scale", visible=False)
|
||||
|
||||
Reference in New Issue
Block a user