Yaron Koresh commited on
Commit
9b445e6
·
verified ·
1 Parent(s): 10da314

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -22,6 +22,7 @@ from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, Eul
22
  import jax
23
  import jax.numpy as jnp
24
 
 
25
  last_motion=None
26
  fps=15
27
  time=5
@@ -146,6 +147,9 @@ def Piper(image,positive,negative,motion):
146
  negative = None
147
 
148
  if image == None:
 
 
 
149
  return pipe(
150
  positive,
151
  negative_prompt=negative,
@@ -156,6 +160,9 @@ def Piper(image,positive,negative,motion):
156
  num_frames=(fps*time)
157
  )
158
 
 
 
 
159
  return pipe(
160
  positive,
161
  negative_prompt=negative,
@@ -209,7 +216,6 @@ pipe.scheduler = EulerDiscreteScheduler(
209
  timestep_spacing="trailing",
210
  steps_offset=1
211
  )
212
- pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
213
  pipe.enable_vae_slicing()
214
  pipe.enable_free_init(method="butterworth", use_fast_sampling=False)
215
 
 
22
  import jax
23
  import jax.numpy as jnp
24
 
25
+ ip_loaded=False
26
  last_motion=None
27
  fps=15
28
  time=5
 
147
  negative = None
148
 
149
  if image == None:
150
+ if ip_loaded:
151
+ pipe.unload_ip_adapter()
152
+ ip_loaded=False
153
  return pipe(
154
  positive,
155
  negative_prompt=negative,
 
160
  num_frames=(fps*time)
161
  )
162
 
163
+ if not ip_loaded:
164
+ pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
165
+ ip_loaded=True
166
  return pipe(
167
  positive,
168
  negative_prompt=negative,
 
216
  timestep_spacing="trailing",
217
  steps_offset=1
218
  )
 
219
  pipe.enable_vae_slicing()
220
  pipe.enable_free_init(method="butterworth", use_fast_sampling=False)
221