Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,6 @@ def init_pool(q):
|
|
31 |
_dynamo.config.suppress_errors = True
|
32 |
|
33 |
mp.set_start_method("fork", force=True)
|
34 |
-
b=mp.Queue()
|
35 |
|
36 |
#pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, revision="refs/pr/1", token=os.getenv("hf_token")).to(device)
|
37 |
#pipe2 = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to(device)
|
@@ -139,16 +138,15 @@ def main(p1,p2):
|
|
139 |
p = {"a":p1_en,"b":p2_en}
|
140 |
ln = len(result)
|
141 |
rng = list(range(ln))
|
142 |
-
for _ in rng
|
143 |
-
|
144 |
-
|
145 |
-
out = pool.map(infer,rng)
|
146 |
pool.clear()
|
147 |
return list(out.get())
|
148 |
|
149 |
-
def infer(
|
150 |
-
p1 =
|
151 |
-
p2 =
|
152 |
name = generate_random_string(12)+".png"
|
153 |
_do = ['beautiful', 'playful', 'photographed', 'realistic', 'dynamic poze', 'deep field', 'reasonable coloring', 'rough texture', 'best quality', 'focused']
|
154 |
if p1 != "":
|
|
|
31 |
_dynamo.config.suppress_errors = True
|
32 |
|
33 |
mp.set_start_method("fork", force=True)
|
|
|
34 |
|
35 |
#pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, revision="refs/pr/1", token=os.getenv("hf_token")).to(device)
|
36 |
#pipe2 = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to(device)
|
|
|
138 |
p = {"a":p1_en,"b":p2_en}
|
139 |
ln = len(result)
|
140 |
rng = list(range(ln))
|
141 |
+
arr = [p for _ in rng]
|
142 |
+
with mp.Pool(ln, initializer=init_pool as pool:
|
143 |
+
out = pool.imap(infer,arr)
|
|
|
144 |
pool.clear()
|
145 |
return list(out.get())
|
146 |
|
147 |
+
def infer(p):
|
148 |
+
p1 = p["a"]
|
149 |
+
p2 = p["b"]
|
150 |
name = generate_random_string(12)+".png"
|
151 |
_do = ['beautiful', 'playful', 'photographed', 'realistic', 'dynamic poze', 'deep field', 'reasonable coloring', 'rough texture', 'best quality', 'focused']
|
152 |
if p1 != "":
|