Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import subprocess
|
|
6 |
import logging
|
7 |
import re
|
8 |
import random
|
9 |
-
import
|
10 |
import requests
|
11 |
import sys
|
12 |
import warnings
|
@@ -16,7 +16,7 @@ import warnings
|
|
16 |
#import spaces
|
17 |
import torch
|
18 |
import gradio as gr
|
19 |
-
|
20 |
from lxml.html import fromstring
|
21 |
#from transformers import pipeline
|
22 |
#from diffusers.pipelines.flux import FluxPipeline
|
@@ -48,7 +48,7 @@ root.addHandler(handler2)
|
|
48 |
|
49 |
# data
|
50 |
|
51 |
-
last_motion=
|
52 |
dtype = torch.float16
|
53 |
device = "cuda"
|
54 |
#repo = "ByteDance/AnimateDiff-Lightning"
|
@@ -156,25 +156,21 @@ def translate(text,lang):
|
|
156 |
return ret
|
157 |
|
158 |
def generate_random_string(length):
|
159 |
-
characters = str(
|
160 |
return ''.join(random.choice(characters) for _ in range(length))
|
161 |
|
162 |
-
@gpu(void()
|
163 |
def calc():
|
164 |
-
nonlocal inp
|
165 |
-
nonlocal last_motion
|
166 |
-
nonlocal ip_loaded
|
167 |
-
nonlocal out
|
168 |
|
169 |
x = grid(1)
|
170 |
|
171 |
-
if last_motion != inp[3]:
|
172 |
pipe.unload_lora_weights()
|
173 |
if inp[3] != "":
|
174 |
pipe.load_lora_weights(inp[3], adapter_name="motion")
|
175 |
pipe.fuse_lora()
|
176 |
pipe.set_adapters([3], [0.7])
|
177 |
-
last_motion = inp[3]
|
178 |
|
179 |
pipe.to(device,dtype)
|
180 |
|
@@ -202,14 +198,11 @@ def calc():
|
|
202 |
|
203 |
def handle(*args):
|
204 |
global inp
|
205 |
-
global last_motion
|
206 |
-
global ip_loaded
|
207 |
global out
|
208 |
|
209 |
-
inp = args
|
210 |
|
211 |
-
out = [
|
212 |
-
out.remove("")
|
213 |
|
214 |
inp[1] = translate(inp[1],"english")
|
215 |
inp[2] = translate(inp[2],"english")
|
|
|
6 |
import logging
|
7 |
import re
|
8 |
import random
|
9 |
+
from string import ascii_letters, digits
|
10 |
import requests
|
11 |
import sys
|
12 |
import warnings
|
|
|
16 |
#import spaces
|
17 |
import torch
|
18 |
import gradio as gr
|
19 |
+
from numpy import array
|
20 |
from lxml.html import fromstring
|
21 |
#from transformers import pipeline
|
22 |
#from diffusers.pipelines.flux import FluxPipeline
|
|
|
48 |
|
49 |
# data
|
50 |
|
51 |
+
last_motion=array([""],dtype=string)
|
52 |
dtype = torch.float16
|
53 |
device = "cuda"
|
54 |
#repo = "ByteDance/AnimateDiff-Lightning"
|
|
|
156 |
return ret
|
157 |
|
158 |
def generate_random_string(length):
|
159 |
+
characters = str(ascii_letters + digits)
|
160 |
return ''.join(random.choice(characters) for _ in range(length))
|
161 |
|
162 |
+
@gpu(void())
|
163 |
def calc():
|
|
|
|
|
|
|
|
|
164 |
|
165 |
x = grid(1)
|
166 |
|
167 |
+
if last_motion[0] != inp[3]:
|
168 |
pipe.unload_lora_weights()
|
169 |
if inp[3] != "":
|
170 |
pipe.load_lora_weights(inp[3], adapter_name="motion")
|
171 |
pipe.fuse_lora()
|
172 |
pipe.set_adapters([3], [0.7])
|
173 |
+
last_motion[0] = inp[3]
|
174 |
|
175 |
pipe.to(device,dtype)
|
176 |
|
|
|
198 |
|
199 |
def handle(*args):
|
200 |
global inp
|
|
|
|
|
201 |
global out
|
202 |
|
203 |
+
inp = array(args, dtype=)
|
204 |
|
205 |
+
out = array([],dtype=string)
|
|
|
206 |
|
207 |
inp[1] = translate(inp[1],"english")
|
208 |
inp[2] = translate(inp[2],"english")
|