Commit fea743e5 authored by novelailab's avatar novelailab

Prevent OOMing from multi gen

parent 5b242a97
......@@ -112,6 +112,17 @@ def sanitize_stable_diffusion(request, config):
if request.module not in config.model.premodules and request.module != "vanilla":
return False, "module should be one of: " + ", ".join(config.model.premodules)
max_gens = 1
num_gen_tiers = [(1024*512, 4), (640*640, 6), (704*512, 8), (512*512, 16), (384*640, 18)]
pixel_count = request.width * request.height
for tier in num_gen_tiers:
if pixel_count <= tier[0]:
max_gens = tier[1]
else:
break
if request.n_samples > max_gens:
return False, f"requested more ({request.n_samples}) images than possible at this resolution"
if request.image is not None:
#decode from base64
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment