Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -136,19 +136,10 @@ pipe_flux = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_d
|
|
136 |
|
137 |
# Parallelism
|
138 |
|
139 |
-
def parallel(
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
pairs = pairs[0]
|
144 |
-
running_tasks = []
|
145 |
-
for pair in pairs:
|
146 |
-
task = pair.pop(0)
|
147 |
-
running_tasks.append(Process(target=task, args=(pair,)))
|
148 |
-
for running_task in running_tasks:
|
149 |
-
running_task.start()
|
150 |
-
for running_task in running_tasks:
|
151 |
-
running_task.join()
|
152 |
|
153 |
# functionality
|
154 |
|
@@ -241,11 +232,6 @@ def pipe_generate(img,p1,p2,motion):
|
|
241 |
|
242 |
def handle_generate(*inp):
|
243 |
|
244 |
-
calc_out = []
|
245 |
-
|
246 |
-
def calc(*args):
|
247 |
-
calc_out.append(pipe_generate(*args))
|
248 |
-
|
249 |
inp = list(inp)
|
250 |
|
251 |
inp[1] = translate(inp[1],"english")
|
@@ -263,14 +249,12 @@ def handle_generate(*inp):
|
|
263 |
|
264 |
ln = len(result)
|
265 |
|
266 |
-
|
267 |
-
parallel(parargs)
|
268 |
names = []
|
269 |
-
for i in
|
270 |
name = generate_random_string(12)+".png"
|
271 |
export_to_gif(i.frames[0],name,fps=fps)
|
272 |
names.append( name )
|
273 |
-
|
274 |
return names
|
275 |
|
276 |
def ui():
|
|
|
136 |
|
137 |
# Parallelism
|
138 |
|
139 |
+
def parallel(workers,func,*args):
|
140 |
+
with ProcessPoolExecutor(workers) as ex:
|
141 |
+
res = ex.map(func, args)
|
142 |
+
return list(res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
# functionality
|
145 |
|
|
|
232 |
|
233 |
def handle_generate(*inp):
|
234 |
|
|
|
|
|
|
|
|
|
|
|
235 |
inp = list(inp)
|
236 |
|
237 |
inp[1] = translate(inp[1],"english")
|
|
|
249 |
|
250 |
ln = len(result)
|
251 |
|
252 |
+
pipe_out = parallel(ln,pipe_generate,*inp)
|
|
|
253 |
names = []
|
254 |
+
for i in pipe_out:
|
255 |
name = generate_random_string(12)+".png"
|
256 |
export_to_gif(i.frames[0],name,fps=fps)
|
257 |
names.append( name )
|
|
|
258 |
return names
|
259 |
|
260 |
def ui():
|