Spaces:
Running
Running
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"
|
@@ -78,14 +78,20 @@ def Piper(_do,_dont):
|
|
78 |
height=512,
|
79 |
width=768,
|
80 |
negative_prompt=_dont,
|
81 |
-
num_inference_steps=
|
82 |
guidance_scale=10
|
83 |
)
|
84 |
|
85 |
def infer(prompt,prompt2):
|
86 |
name = generate_random_string(12)+".png"
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
image = Piper(_do,_dont).images[0].save(name)
|
90 |
return name
|
91 |
|
@@ -128,6 +134,7 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
128 |
rtl=True,
|
129 |
max_lines=1
|
130 |
)
|
|
|
131 |
prompt2 = gr.Textbox(
|
132 |
elem_id="prompt2",
|
133 |
placeholder="Forbidden Content",
|
@@ -138,6 +145,16 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
138 |
with gr.Row():
|
139 |
run_button = gr.Button("Run")
|
140 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
run_button.click(
|
142 |
fn = infer,
|
143 |
inputs = [prompt,prompt2],
|
|
|
12 |
import requests
|
13 |
from lxml.html import fromstring
|
14 |
|
15 |
+
pool = ProcessPoolExecutor(16)
|
16 |
pool.__enter__()
|
17 |
|
18 |
#model_id = "runwayml/stable-diffusion-v1-5"
|
|
|
78 |
height=512,
|
79 |
width=768,
|
80 |
negative_prompt=_dont,
|
81 |
+
num_inference_steps=100,
|
82 |
guidance_scale=10
|
83 |
)
|
84 |
|
85 |
def infer(prompt,prompt2):
|
86 |
name = generate_random_string(12)+".png"
|
87 |
+
if prompt == None or prompt.strip() == "":
|
88 |
+
_do = 'hot colors palette, muted colors, dynamic poze, realistic, accurate, matched, realistic details, award winning photograph, soft natural lighting, deep field, high definition, highly detailed, 8k'
|
89 |
+
else:
|
90 |
+
_do = f'{ translate(prompt,"english") }, hot colors palette, muted colors, dynamic poze, realistic, accurate, matched, realistic details, award winning photograph, soft natural lighting, deep field, high definition, highly detailed, 8k'
|
91 |
+
if prompt2 == None or prompt2.strip() == "":
|
92 |
+
_dont = 'ugly, deformed, disfigured, poor details, bad anatomy, including labels, including text, including logo'
|
93 |
+
else:
|
94 |
+
_dont = f'including {translate(prompt2,"english")}, ugly, deformed, disfigured, poor details, bad anatomy, including labels, including text, including logo'
|
95 |
image = Piper(_do,_dont).images[0].save(name)
|
96 |
return name
|
97 |
|
|
|
134 |
rtl=True,
|
135 |
max_lines=1
|
136 |
)
|
137 |
+
with gr.Row():
|
138 |
prompt2 = gr.Textbox(
|
139 |
elem_id="prompt2",
|
140 |
placeholder="Forbidden Content",
|
|
|
145 |
with gr.Row():
|
146 |
run_button = gr.Button("Run")
|
147 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
148 |
+
prompt.submit(
|
149 |
+
fn = infer,
|
150 |
+
inputs = [prompt,prompt2],
|
151 |
+
outputs = [result]
|
152 |
+
)
|
153 |
+
prompt2.submit(
|
154 |
+
fn = infer,
|
155 |
+
inputs = [prompt,prompt2],
|
156 |
+
outputs = [result]
|
157 |
+
)
|
158 |
run_button.click(
|
159 |
fn = infer,
|
160 |
inputs = [prompt,prompt2],
|