Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,9 @@ import numpy as np
|
|
10 |
from lxml.html import fromstring
|
11 |
#from transformers import pipeline
|
12 |
from torch import multiprocessing as mp
|
13 |
-
|
14 |
#from pathos.multiprocessing import ProcessPool as Pool
|
15 |
-
from pathos.threading import ThreadPool as
|
16 |
#from diffusers.pipelines.flux import FluxPipeline
|
17 |
#from diffusers.utils import export_to_gif
|
18 |
#from huggingface_hub import hf_hub_download
|
@@ -189,15 +189,21 @@ def run(p1,p2,*result):
|
|
189 |
ln = len(result)
|
190 |
print("images: "+str(ln))
|
191 |
rng = list(range(ln))
|
|
|
192 |
arr1 = [p for _ in rng]
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
196 |
arr2 = [{"a":p1_en,"b":p2_en,"c":out1[_]} for _ in rng]
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
201 |
return out2
|
202 |
|
203 |
def ui():
|
|
|
10 |
from lxml.html import fromstring
|
11 |
#from transformers import pipeline
|
12 |
from torch import multiprocessing as mp
|
13 |
+
from torch.multiprocessing import Pool2
|
14 |
#from pathos.multiprocessing import ProcessPool as Pool
|
15 |
+
from pathos.threading import ThreadPool as Pool1
|
16 |
#from diffusers.pipelines.flux import FluxPipeline
|
17 |
#from diffusers.utils import export_to_gif
|
18 |
#from huggingface_hub import hf_hub_download
|
|
|
189 |
ln = len(result)
|
190 |
print("images: "+str(ln))
|
191 |
rng = list(range(ln))
|
192 |
+
|
193 |
arr1 = [p for _ in rng]
|
194 |
+
pool1 = Pool1(ln)
|
195 |
+
out1 = list(pool1.imap(infer1,arr1))
|
196 |
+
pool1.close()
|
197 |
+
pool1.join()
|
198 |
+
pool1.clear()
|
199 |
+
|
200 |
arr2 = [{"a":p1_en,"b":p2_en,"c":out1[_]} for _ in rng]
|
201 |
+
pool2 = Pool2(ln)
|
202 |
+
out2 = list(pool2.imap(infer2,arr2))
|
203 |
+
pool2.close()
|
204 |
+
pool2.join()
|
205 |
+
pool2.clear()
|
206 |
+
|
207 |
return out2
|
208 |
|
209 |
def ui():
|