Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,13 +27,8 @@ from safetensors.torch import load_file, save_file
|
|
| 27 |
from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, DDIMScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
|
| 28 |
#import jax
|
| 29 |
#import jax.numpy as jnp
|
| 30 |
-
from numba import
|
| 31 |
-
from numba.cuda import
|
| 32 |
-
|
| 33 |
-
# optimization:
|
| 34 |
-
|
| 35 |
-
# @gpu(cache=True)
|
| 36 |
-
# @cpu(cache=True)
|
| 37 |
|
| 38 |
# logging
|
| 39 |
|
|
@@ -115,17 +110,10 @@ function custom(){
|
|
| 115 |
|
| 116 |
# functionality
|
| 117 |
|
| 118 |
-
@cpu(cache=True)
|
| 119 |
def run(cmd):
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
dx = cuda.blockDim.x
|
| 124 |
-
pos = tx + bx * dx
|
| 125 |
-
except:
|
| 126 |
-
pos = 0
|
| 127 |
-
|
| 128 |
-
cmd=cmd[pos]
|
| 129 |
|
| 130 |
result = subprocess.run(cmd, shell=True, capture_output=True, env=None)
|
| 131 |
if result.returncode != 0:
|
|
@@ -133,19 +121,14 @@ def run(cmd):
|
|
| 133 |
f"Command '{cmd}' failed with exit status code '{result.returncode}'. Exiting..."
|
| 134 |
)
|
| 135 |
sys.exit()
|
| 136 |
-
return result
|
| 137 |
|
| 138 |
-
@
|
| 139 |
-
def translate(
|
| 140 |
-
try:
|
| 141 |
-
tx = cuda.threadIdx.x
|
| 142 |
-
bx = cuda.blockIdx.x
|
| 143 |
-
dx = cuda.blockDim.x
|
| 144 |
-
pos = tx + bx * dx
|
| 145 |
-
except:
|
| 146 |
-
pos = 0
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
lang=lang[pos]
|
| 150 |
|
| 151 |
if text == None or lang == None:
|
|
|
|
| 27 |
from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, DDIMScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
|
| 28 |
#import jax
|
| 29 |
#import jax.numpy as jnp
|
| 30 |
+
from numba import cuda
|
| 31 |
+
from numba.cuda import autojit as gpu, grid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# logging
|
| 34 |
|
|
|
|
| 110 |
|
| 111 |
# functionality
|
| 112 |
|
|
|
|
| 113 |
def run(cmd):
|
| 114 |
+
#x = cuda.threadIdx.x + cuda.blockIdx.x * cuda.blockDim.x
|
| 115 |
+
#y = cuda.threadIdx.y + cuda.blockIdx.y * cuda.blockDim.y
|
| 116 |
+
#z = cuda.threadIdx.z + cuda.blockIdx.z * cuda.blockDim.z
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
result = subprocess.run(cmd, shell=True, capture_output=True, env=None)
|
| 119 |
if result.returncode != 0:
|
|
|
|
| 121 |
f"Command '{cmd}' failed with exit status code '{result.returncode}'. Exiting..."
|
| 122 |
)
|
| 123 |
sys.exit()
|
| 124 |
+
return str(result.stdout)
|
| 125 |
|
| 126 |
+
@gpu()
|
| 127 |
+
def translate(text,lang):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
text=text[]
|
| 132 |
lang=lang[pos]
|
| 133 |
|
| 134 |
if text == None or lang == None:
|