Spaces:
Paused
Paused
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
import logging
|
|
@@ -7,7 +10,9 @@ import string
|
|
| 7 |
import requests
|
| 8 |
import sys
|
| 9 |
import warnings
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
import spaces
|
| 12 |
import torch
|
| 13 |
import gradio as gr
|
|
@@ -28,6 +33,8 @@ from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, Eul
|
|
| 28 |
#import jax.numpy as jnp
|
| 29 |
from numba import jit,njit
|
| 30 |
|
|
|
|
|
|
|
| 31 |
warnings.filterwarnings("ignore")
|
| 32 |
root = logging.getLogger()
|
| 33 |
root.setLevel(logging.DEBUG)
|
|
@@ -42,6 +49,12 @@ formatter = logging.Formatter('\n >>> [%(levelname)s] %(asctime)s %(name)s: %(me
|
|
| 42 |
handler2.setFormatter(formatter)
|
| 43 |
root.addHandler(handler2)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
last_motion=None
|
| 46 |
dtype = torch.float16
|
| 47 |
result=[]
|
|
@@ -95,7 +108,6 @@ footer {
|
|
| 95 |
display: flex;
|
| 96 |
}
|
| 97 |
"""
|
| 98 |
-
|
| 99 |
js="""
|
| 100 |
function custom(){
|
| 101 |
document.querySelector("div#prompt input").setAttribute("maxlength","38")
|
|
@@ -103,6 +115,8 @@ function custom(){
|
|
| 103 |
}
|
| 104 |
"""
|
| 105 |
|
|
|
|
|
|
|
| 106 |
@njit(cache=True,nopython=True,parallel=True)
|
| 107 |
def run(cmd, assert_success=False, capture_output=False, env=None, dry_run=False):
|
| 108 |
if dry_run:
|
|
@@ -117,7 +131,7 @@ def run(cmd, assert_success=False, capture_output=False, env=None, dry_run=False
|
|
| 117 |
sys.exit()
|
| 118 |
|
| 119 |
return result
|
| 120 |
-
|
| 121 |
@njit(cache=True,nopython=True,parallel=True)
|
| 122 |
def translate(text,lang):
|
| 123 |
if text == None or lang == None:
|
|
@@ -159,12 +173,12 @@ def translate(text,lang):
|
|
| 159 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
| 160 |
print(ret)
|
| 161 |
return ret
|
| 162 |
-
|
| 163 |
@njit(cache=True,nopython=True,parallel=True)
|
| 164 |
def generate_random_string(length):
|
| 165 |
characters = string.ascii_letters + string.digits
|
| 166 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 167 |
-
|
| 168 |
#@spaces.GPU(duration=65)
|
| 169 |
@njit(cache=True,nopython=True,parallel=True)
|
| 170 |
def Piper(image,positive,negative,motion):
|
|
@@ -312,7 +326,10 @@ def pre():
|
|
| 312 |
pipe.enable_vae_slicing()
|
| 313 |
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 314 |
|
| 315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
-
|
| 318 |
-
ui()
|
|
|
|
| 1 |
+
|
| 2 |
+
# built-in
|
| 3 |
+
|
| 4 |
import os
|
| 5 |
import subprocess
|
| 6 |
import logging
|
|
|
|
| 10 |
import requests
|
| 11 |
import sys
|
| 12 |
import warnings
|
| 13 |
+
|
| 14 |
+
# external
|
| 15 |
+
|
| 16 |
import spaces
|
| 17 |
import torch
|
| 18 |
import gradio as gr
|
|
|
|
| 33 |
#import jax.numpy as jnp
|
| 34 |
from numba import jit,njit
|
| 35 |
|
| 36 |
+
# logging
|
| 37 |
+
|
| 38 |
warnings.filterwarnings("ignore")
|
| 39 |
root = logging.getLogger()
|
| 40 |
root.setLevel(logging.DEBUG)
|
|
|
|
| 49 |
handler2.setFormatter(formatter)
|
| 50 |
root.addHandler(handler2)
|
| 51 |
|
| 52 |
+
# spawn
|
| 53 |
+
|
| 54 |
+
mp.set_start_method("spawn", force=True)
|
| 55 |
+
|
| 56 |
+
# data
|
| 57 |
+
|
| 58 |
last_motion=None
|
| 59 |
dtype = torch.float16
|
| 60 |
result=[]
|
|
|
|
| 108 |
display: flex;
|
| 109 |
}
|
| 110 |
"""
|
|
|
|
| 111 |
js="""
|
| 112 |
function custom(){
|
| 113 |
document.querySelector("div#prompt input").setAttribute("maxlength","38")
|
|
|
|
| 115 |
}
|
| 116 |
"""
|
| 117 |
|
| 118 |
+
# functionality
|
| 119 |
+
|
| 120 |
@njit(cache=True,nopython=True,parallel=True)
|
| 121 |
def run(cmd, assert_success=False, capture_output=False, env=None, dry_run=False):
|
| 122 |
if dry_run:
|
|
|
|
| 131 |
sys.exit()
|
| 132 |
|
| 133 |
return result
|
| 134 |
+
|
| 135 |
@njit(cache=True,nopython=True,parallel=True)
|
| 136 |
def translate(text,lang):
|
| 137 |
if text == None or lang == None:
|
|
|
|
| 173 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
| 174 |
print(ret)
|
| 175 |
return ret
|
| 176 |
+
|
| 177 |
@njit(cache=True,nopython=True,parallel=True)
|
| 178 |
def generate_random_string(length):
|
| 179 |
characters = string.ascii_letters + string.digits
|
| 180 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 181 |
+
|
| 182 |
#@spaces.GPU(duration=65)
|
| 183 |
@njit(cache=True,nopython=True,parallel=True)
|
| 184 |
def Piper(image,positive,negative,motion):
|
|
|
|
| 326 |
pipe.enable_vae_slicing()
|
| 327 |
pipe.enable_free_init(method="butterworth", use_fast_sampling=fast)
|
| 328 |
|
| 329 |
+
# entry
|
| 330 |
+
|
| 331 |
+
if __name__ == "__main__":
|
| 332 |
+
pre()
|
| 333 |
+
ui()
|
| 334 |
|
| 335 |
+
# end
|
|
|