This commit is contained in:
lllyasviel
2024-01-29 23:28:13 -08:00
parent 8ee804a159
commit a1d2a31233
4 changed files with 16 additions and 8 deletions

View File

@@ -6,6 +6,8 @@ import random
import string
import cv2
from ldm_patched.modules import model_management
def HWC3(x):
assert x.dtype == np.uint8
@@ -124,3 +126,9 @@ def resize_image_with_pad(img, resolution):
return safer_memory(x[:H_target, :W_target])
return safer_memory(img_padded), remove_pad
def lazy_memory_management(model):
required_memory = model_management.module_size(model) + model_management.minimum_inference_memory()
model_management.free_memory(required_memory, device=model_management.get_torch_device())
return