Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
|
|
| 12 |
import requests
|
| 13 |
from lxml.html import fromstring
|
| 14 |
|
| 15 |
-
pool = ProcessPoolExecutor(
|
| 16 |
pool.__enter__()
|
| 17 |
|
| 18 |
#model_id = "runwayml/stable-diffusion-v1-5"
|
|
@@ -58,19 +58,22 @@ def generate_random_string(length):
|
|
| 58 |
characters = string.ascii_letters + string.digits
|
| 59 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
@spaces.GPU
|
| 62 |
def infer(prompt):
|
| 63 |
name = generate_random_string(12)+".png"
|
| 64 |
english_prompt = f'TRUE {translate(prompt,"english").upper()}:'
|
| 65 |
print(f'Final prompt: {english_prompt}')
|
| 66 |
-
image =
|
| 67 |
-
english_prompt,
|
| 68 |
-
height=256,
|
| 69 |
-
width=256,
|
| 70 |
-
negative_prompt="",
|
| 71 |
-
num_inference_steps=30,
|
| 72 |
-
guidance_scale=9
|
| 73 |
-
).images[0].save(name)
|
| 74 |
return name
|
| 75 |
|
| 76 |
css="""
|
|
|
|
| 12 |
import requests
|
| 13 |
from lxml.html import fromstring
|
| 14 |
|
| 15 |
+
pool = ProcessPoolExecutor(1000)
|
| 16 |
pool.__enter__()
|
| 17 |
|
| 18 |
#model_id = "runwayml/stable-diffusion-v1-5"
|
|
|
|
| 58 |
characters = string.ascii_letters + string.digits
|
| 59 |
return ''.join(random.choice(characters) for _ in range(length))
|
| 60 |
|
| 61 |
+
def Pipe(english_prompt, height, width):
|
| 62 |
+
return Pipe(
|
| 63 |
+
english_prompt,
|
| 64 |
+
height=192,
|
| 65 |
+
width=192,
|
| 66 |
+
negative_prompt="",
|
| 67 |
+
num_inference_steps=150,
|
| 68 |
+
guidance_scale=10
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
@spaces.GPU
|
| 72 |
def infer(prompt):
|
| 73 |
name = generate_random_string(12)+".png"
|
| 74 |
english_prompt = f'TRUE {translate(prompt,"english").upper()}:'
|
| 75 |
print(f'Final prompt: {english_prompt}')
|
| 76 |
+
image = Pipe(english_prompt, height, width).images[0].save(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
return name
|
| 78 |
|
| 79 |
css="""
|