Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, Eul
|
|
| 28 |
#import jax
|
| 29 |
#import jax.numpy as jnp
|
| 30 |
from numba import cuda, njit as cpu, void, int64 as int, float64 as float, boolean as bool, uint8 as rgb
|
| 31 |
-
from numba.cuda import jit as gpu, grid
|
| 32 |
from numba.types import unicode_type as string
|
| 33 |
from PIL.Image import fromarray as array2image
|
| 34 |
import numpy as np
|
|
@@ -119,6 +119,23 @@ function custom(){
|
|
| 119 |
}
|
| 120 |
"""
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
# functionality
|
| 123 |
|
| 124 |
def run(cmd):
|
|
@@ -174,6 +191,7 @@ def generate_random_string(length):
|
|
| 174 |
def calc(img,p1,p2,motion):
|
| 175 |
global out_pipe
|
| 176 |
global last_motion
|
|
|
|
| 177 |
|
| 178 |
x = grid(1)
|
| 179 |
|
|
@@ -295,23 +313,6 @@ def ui():
|
|
| 295 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
| 296 |
demo.queue().launch()
|
| 297 |
|
| 298 |
-
@gpu(void())
|
| 299 |
-
def pre():
|
| 300 |
-
global pipe
|
| 301 |
-
pipe = AnimateDiffPipeline.from_pretrained(base, vae=vae, motion_adapter=adapter, torch_dtype=dtype).to(device)
|
| 302 |
-
pipe.scheduler = DDIMScheduler(
|
| 303 |
-
clip_sample=False,
|
| 304 |
-
beta_start=0.00085,
|
| 305 |
-
beta_end=0.012,
|
| 306 |
-
beta_schedule="linear",
|
| 307 |
-
timestep_spacing="trailing",
|
| 308 |
-
steps_offset=1
|
| 309 |
-
)
|
| 310 |
-
pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device), strict=False)
|
| 311 |
-
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
|
| 312 |
-
pipe.enable_vae_slicing()
|
| 313 |
-
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 314 |
-
|
| 315 |
@gpu(void())
|
| 316 |
def events():
|
| 317 |
gr.on(
|
|
@@ -327,7 +328,7 @@ def events():
|
|
| 327 |
|
| 328 |
def entry():
|
| 329 |
os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
| 330 |
-
|
| 331 |
ui()
|
| 332 |
events[1,32]()
|
| 333 |
|
|
|
|
| 28 |
#import jax
|
| 29 |
#import jax.numpy as jnp
|
| 30 |
from numba import cuda, njit as cpu, void, int64 as int, float64 as float, boolean as bool, uint8 as rgb
|
| 31 |
+
from numba.cuda import jit as gpu, grid, as_cuda_array as tensor2array
|
| 32 |
from numba.types import unicode_type as string
|
| 33 |
from PIL.Image import fromarray as array2image
|
| 34 |
import numpy as np
|
|
|
|
| 119 |
}
|
| 120 |
"""
|
| 121 |
|
| 122 |
+
# torch pipe
|
| 123 |
+
|
| 124 |
+
pipe = AnimateDiffPipeline.from_pretrained(base, vae=vae, motion_adapter=adapter, torch_dtype=dtype).to(device)
|
| 125 |
+
pipe.scheduler = DDIMScheduler(
|
| 126 |
+
clip_sample=False,
|
| 127 |
+
beta_start=0.00085,
|
| 128 |
+
beta_end=0.012,
|
| 129 |
+
beta_schedule="linear",
|
| 130 |
+
timestep_spacing="trailing",
|
| 131 |
+
steps_offset=1
|
| 132 |
+
)
|
| 133 |
+
pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device), strict=False)
|
| 134 |
+
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
|
| 135 |
+
pipe.enable_vae_slicing()
|
| 136 |
+
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 137 |
+
|
| 138 |
+
|
| 139 |
# functionality
|
| 140 |
|
| 141 |
def run(cmd):
|
|
|
|
| 191 |
def calc(img,p1,p2,motion):
|
| 192 |
global out_pipe
|
| 193 |
global last_motion
|
| 194 |
+
global pipe
|
| 195 |
|
| 196 |
x = grid(1)
|
| 197 |
|
|
|
|
| 313 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
| 314 |
demo.queue().launch()
|
| 315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
@gpu(void())
|
| 317 |
def events():
|
| 318 |
gr.on(
|
|
|
|
| 328 |
|
| 329 |
def entry():
|
| 330 |
os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
| 331 |
+
|
| 332 |
ui()
|
| 333 |
events[1,32]()
|
| 334 |
|