Spaces:
Runtime error
Runtime error
fix: add timeout to prevent unexcepted tasl
Browse filesFiles changed (2)
59 unmodified lines606162636465191 unmodified lines25725825926026126259 unmodified lines# ]start_time = time.time()scheduler = DDIMScheduler.from_pretrained(base_model,191 unmodified lines"sampler_opt": sampler_opt,"pww_state": state,"pww_attn_weight": g_strength,}if img_input is not None:59 unmodified lines60616263646566191 unmodified lines25825926026126226326426559 unmodified lines# ]start_time = time.time()timeout = 120scheduler = DDIMScheduler.from_pretrained(base_model,191 unmodified lines"sampler_opt": sampler_opt,"pww_state": state,"pww_attn_weight": g_strength,"start_time": start_time,"timeout": timeout,}if img_input is not None:
5 unmodified lines67891011434 unmodified lines44644744844945045152 unmodified lines504505506507508509107 unmodified lines61761861962062162244 unmodified lines6676686696706716725 unmodified linesfrom collections import defaultdictfrom typing import List, Optional, Unionimport k_diffusionimport numpy as npimport PIL434 unmodified linespww_attn_weight=1.0,sampler_name="",sampler_opt={},scale_ratio=8.0,):sampler = self.get_scheduler(sampler_name)52 unmodified linesdef model_fn(x, sigma):latent_model_input = torch.cat([x] * 2)weight_func = lambda w, sigma, qk: w * math.log(1 + sigma) * qk.max()encoder_state = {107 unmodified linespww_attn_weight=1.0,sampler_name="",sampler_opt={},):sampler = self.get_scheduler(sampler_name)# 1. Check inputs. Raise error if not correct44 unmodified linesdef model_fn(x, sigma):latent_model_input = torch.cat([x] * 2)weight_func = lambda w, sigma, qk: w * math.log(1 + sigma) * qk.max()encoder_state = {5 unmodified lines6789101112434 unmodified lines44744844945045145245345452 unmodified lines507508509510511512513514515107 unmodified lines62362462562662762862963044 unmodified lines6756766776786796806816826835 unmodified linesfrom collections import defaultdictfrom typing import List, Optional, Unionimport timeimport k_diffusionimport numpy as npimport PIL434 unmodified linespww_attn_weight=1.0,sampler_name="",sampler_opt={},start_time=-1,timeout=180,scale_ratio=8.0,):sampler = self.get_scheduler(sampler_name)52 unmodified linesdef model_fn(x, sigma):if start_time > 0 and timeout > 0:assert (time.time() - start_time) < timeout, "inference process timed out"latent_model_input = torch.cat([x] * 2)weight_func = lambda w, sigma, qk: w * math.log(1 + sigma) * qk.max()encoder_state = {107 unmodified linespww_attn_weight=1.0,sampler_name="",sampler_opt={},start_time=-1,timeout=180,):sampler = self.get_scheduler(sampler_name)# 1. Check inputs. Raise error if not correct44 unmodified linesdef model_fn(x, sigma):if start_time > 0 and timeout > 0:assert (time.time() - start_time) < timeout, "inference process timed out"latent_model_input = torch.cat([x] * 2)weight_func = lambda w, sigma, qk: w * math.log(1 + sigma) * qk.max()encoder_state = {
app.py+3
modules/model.py+11