Yaron Koresh commited on
Commit
83b0d34
·
verified ·
1 Parent(s): 2202700

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
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
- #from torch.multiprocessing import Pool
14
  #from pathos.multiprocessing import ProcessPool as Pool
15
- from pathos.threading import ThreadPool as Pool
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
- print("Starting pool!")
194
- pool = Pool(nodes=ln*2)
195
- out1 = list(pool.imap(infer1,arr1))
 
 
 
196
  arr2 = [{"a":p1_en,"b":p2_en,"c":out1[_]} for _ in rng]
197
- out2 = list(pool.imap(infer2,arr2))
198
- pool.close()
199
- pool.join()
200
- pool.clear()
 
 
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():