nyanko7 commited on
Commit
e1fa56f
1 Parent(s): 6e5f09c

fix: syntax

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -60,7 +60,7 @@ samplers_k_diffusion = [
60
  # ]
61
 
62
  start_time = time.time()
63
- timeout = 60
64
 
65
  scheduler = DDIMScheduler.from_pretrained(
66
  base_model,
@@ -130,11 +130,12 @@ def setup_model(name, lora_state=None, lora_scale=1.0):
130
  te_cache[model] = text_encoder
131
  lora_cache[model] = LoRANetwork(text_encoder, unet)
132
 
133
- if current_model != model and current_model not in keep_vram:
134
- # offload current model
135
- unet_cache[current_model].to("cpu")
136
- te_cache[current_model].to("cpu")
137
- lora_cache[current_model].to("cpu")
 
138
  current_model = model
139
 
140
  local_te, local_unet, local_lora, = te_cache[model], unet_cache[model], lora_cache[model]
@@ -158,6 +159,10 @@ def setup_model(name, lora_state=None, lora_scale=1.0):
158
  pipe.setup_text_encoder(clip_skip, local_te)
159
  return pipe
160
 
 
 
 
 
161
  def error_str(error, title="Error"):
162
  return (
163
  f"""#### {title}
 
60
  # ]
61
 
62
  start_time = time.time()
63
+ timeout = 90
64
 
65
  scheduler = DDIMScheduler.from_pretrained(
66
  base_model,
 
130
  te_cache[model] = text_encoder
131
  lora_cache[model] = LoRANetwork(text_encoder, unet)
132
 
133
+ if current_model != model:
134
+ if current_model not in keep_vram:
135
+ # offload current model
136
+ unet_cache[current_model].to("cpu")
137
+ te_cache[current_model].to("cpu")
138
+ lora_cache[current_model].to("cpu")
139
  current_model = model
140
 
141
  local_te, local_unet, local_lora, = te_cache[model], unet_cache[model], lora_cache[model]
 
159
  pipe.setup_text_encoder(clip_skip, local_te)
160
  return pipe
161
 
162
+ # precache on huggingface
163
+ for model in models:
164
+ setup_model(model[0])
165
+
166
  def error_str(error, title="Error"):
167
  return (
168
  f"""#### {title}