From 1b44ae22e3996b8af048f268bd076702b296b469 Mon Sep 17 00:00:00 2001 From: layerdiffusion <19834515+lllyasviel@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:08:04 -0700 Subject: [PATCH] revise space --- extensions-builtin/forge_space_iclight/forge_app.py | 12 ++++++++++++ modules/launch_utils.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions-builtin/forge_space_iclight/forge_app.py b/extensions-builtin/forge_space_iclight/forge_app.py index 11b35b7e..abf0dae0 100644 --- a/extensions-builtin/forge_space_iclight/forge_app.py +++ b/extensions-builtin/forge_space_iclight/forge_app.py @@ -1,5 +1,6 @@ import spaces import math +import os import gradio as gr import numpy as np import torch @@ -132,6 +133,11 @@ i2i_pipe = StableDiffusionImg2ImgPipeline( spaces.automatically_move_pipeline_components(t2i_pipe) +def overwrite_components(components): + global tokenizer, text_encoder, vae, unet, t2i_pipe, i2i_pipe + tokenizer, text_encoder, vae, unet, t2i_pipe, i2i_pipe = components + + @torch.inference_mode() def encode_prompt_inner(txt: str): max_length = tokenizer.model_max_length @@ -234,8 +240,14 @@ def run_rmbg(img, sigma=0.0): return result.clip(0, 255).astype(np.uint8), alpha +external_processor = None + + @torch.inference_mode() def process(input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source): + if external_processor is not None: + return external_processor(input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source) + bg_source = BGSource(bg_source) input_bg = None diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 343ef228..3c89d18f 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -403,7 +403,7 @@ def prepare_environment(): # stable_diffusion_xl_commit_hash = os.environ.get('STABLE_DIFFUSION_XL_COMMIT_HASH', "45c443b316737a4ab6e40413d7794a7f5657c19f") # k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "ab527a9a6d347f364e3d185ba6d714e22d80cb3c") huggingface_guess_commit_hash = os.environ.get('HUGGINGFACE_GUESS_HASH', "84826248b49bb7ca754c73293299c4d4e23a548d") - google_blockly_commit_hash = os.environ.get('GOOGLE_BLOCKLY_COMMIT_HASH', "bf36e6fd3750a081f44209ba4f645adb598f7e37") + google_blockly_commit_hash = os.environ.get('GOOGLE_BLOCKLY_COMMIT_HASH', "1e98997c7fedaf5106af9849b6f50ebe5c4408f1") blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9") try: