Sophia Yang commited on
Commit
80ba4d1
1 Parent(s): a0019ba
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -17,9 +17,13 @@ pn.state.template.param.update(
17
  )
18
 
19
  model_id = "timbrooks/instruct-pix2pix"
20
- pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
21
- model_id, torch_dtype=torch.float16
22
- ).to("cuda")
 
 
 
 
23
 
24
  def normalize_image(value, width):
25
  """
 
17
  )
18
 
19
  model_id = "timbrooks/instruct-pix2pix"
20
+
21
+ if 'pipe' in pn.state.cache:
22
+ pipe = pn.state.cache['pipe']
23
+ else:
24
+ pipe = pn.state.cache['pipe'] = StableDiffusionInstructPix2PixPipeline.from_pretrained(
25
+ model_id, torch_dtype=torch.float16
26
+ ).to("cuda")
27
 
28
  def normalize_image(value, width):
29
  """