Unload clip on demand and workaround memory leak (#1283)

This commit is contained in:
jinchen62
2023-04-10 16:59:03 -07:00
committed by GitHub
parent d25ef5529f
commit 3002793301
8 changed files with 24 additions and 8 deletions

View File

@@ -170,7 +170,8 @@ def img2img_inf(
use_stencil=use_stencil,
)
if (
not global_obj.get_sd_obj()
args.ondemand
or not global_obj.get_sd_obj()
or global_obj.get_cfg_obj() != new_config_obj
):
global_obj.clear_cache()
@@ -239,6 +240,7 @@ def img2img_inf(
)
global_obj.set_sd_scheduler(args.scheduler)
global_obj.set_sd_ondemand(args.ondemand)
start_time = time.time()
global_obj.get_sd_obj().log = ""

View File

@@ -103,7 +103,8 @@ def inpaint_inf(
use_stencil=None,
)
if (
not global_obj.get_sd_obj()
args.ondemand
or not global_obj.get_sd_obj()
or global_obj.get_cfg_obj() != new_config_obj
):
global_obj.clear_cache()
@@ -148,6 +149,7 @@ def inpaint_inf(
)
global_obj.set_sd_scheduler(scheduler)
global_obj.set_sd_ondemand(args.ondemand)
start_time = time.time()
global_obj.get_sd_obj().log = ""

View File

@@ -65,6 +65,9 @@ def outpaint_inf(
args.steps = steps
args.scheduler = scheduler
args.img_path = "not none"
if ondemand:
print("Outpainting is not supporting ondemand yet.")
ondemand = False
args.ondemand = ondemand
# set ckpt_loc and hf_model_id.

View File

@@ -103,7 +103,8 @@ def upscaler_inf(
use_stencil=None,
)
if (
not global_obj.get_sd_obj()
args.ondemand
or not global_obj.get_sd_obj()
or global_obj.get_cfg_obj() != new_config_obj
):
global_obj.clear_cache()
@@ -146,6 +147,7 @@ def upscaler_inf(
global_obj.get_sd_obj().low_res_scheduler = global_obj.get_scheduler(
"DDPM"
)
global_obj.set_sd_ondemand(args.ondemand)
start_time = time.time()
global_obj.get_sd_obj().log = ""