Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -83,26 +83,24 @@ def generate_random_string(length):
|
|
83 |
characters = string.ascii_letters + string.digits
|
84 |
return ''.join(random.choice(characters) for _ in range(length))
|
85 |
|
86 |
-
@spaces.GPU(duration=
|
87 |
def Piper(_do,_dont):
|
88 |
return pipe(
|
89 |
_do,
|
90 |
height=320,
|
91 |
width=480,
|
92 |
negative_prompt=_dont,
|
93 |
-
num_inference_steps=
|
94 |
-
guidance_scale=
|
95 |
)
|
96 |
|
97 |
-
def infer(
|
98 |
name = generate_random_string(12)+".png"
|
99 |
-
prompt_en
|
100 |
-
|
101 |
-
if prompt == None or prompt.strip() == "":
|
102 |
-
_do = 'realistic natural sharp light vivid vintage amazing yet reasonable scene coloring'
|
103 |
else:
|
104 |
-
_do = f'
|
105 |
-
if
|
106 |
_dont = 'smooth texture, fictional proportions, blurred content, distorted items, deformed palms, logos and signs, texts and prints'
|
107 |
else:
|
108 |
_dont = f'{prompt2_en} where in {prompt_en}, smooth texture, fictional proportions, blurred content, distorted items, deformed palms, logos and signs, texts and prints'
|
@@ -176,6 +174,8 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
176 |
with gr.Row():
|
177 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
178 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
|
|
|
|
179 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
180 |
|
181 |
def _ret(idx,p1,p2):
|
@@ -184,10 +184,12 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
|
184 |
print(f'Finished {idx}: {v}')
|
185 |
return v
|
186 |
def _rets(p1,p2):
|
|
|
|
|
187 |
ln = len(result)
|
188 |
idxs = list(range(ln))
|
189 |
-
p1s = [
|
190 |
-
p2s = [
|
191 |
return list(Pool(ln).imap( _ret, idxs, p1s, p2s ))
|
192 |
run_button.click(fn=_rets,inputs=[prompt,prompt2],outputs=result)
|
193 |
|
|
|
83 |
characters = string.ascii_letters + string.digits
|
84 |
return ''.join(random.choice(characters) for _ in range(length))
|
85 |
|
86 |
+
@spaces.GPU(duration=35)
|
87 |
def Piper(_do,_dont):
|
88 |
return pipe(
|
89 |
_do,
|
90 |
height=320,
|
91 |
width=480,
|
92 |
negative_prompt=_dont,
|
93 |
+
num_inference_steps=100,
|
94 |
+
guidance_scale=4
|
95 |
)
|
96 |
|
97 |
+
def infer(prompt_en,prompt2_en):
|
98 |
name = generate_random_string(12)+".png"
|
99 |
+
if prompt_en == "":
|
100 |
+
_do = 'natural sharp light vivid vintage coloring, amazing while also reasonable and realistic scene'
|
|
|
|
|
101 |
else:
|
102 |
+
_do = f'natural sharp light vivid vintage coloring, amazing while also reasonable and realistic { prompt_en } scene'
|
103 |
+
if prompt2_en == "":
|
104 |
_dont = 'smooth texture, fictional proportions, blurred content, distorted items, deformed palms, logos and signs, texts and prints'
|
105 |
else:
|
106 |
_dont = f'{prompt2_en} where in {prompt_en}, smooth texture, fictional proportions, blurred content, distorted items, deformed palms, logos and signs, texts and prints'
|
|
|
174 |
with gr.Row():
|
175 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
176 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
177 |
+
with gr.Row():
|
178 |
+
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
179 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
180 |
|
181 |
def _ret(idx,p1,p2):
|
|
|
184 |
print(f'Finished {idx}: {v}')
|
185 |
return v
|
186 |
def _rets(p1,p2):
|
187 |
+
p1_en = translate(p1,"english")
|
188 |
+
p2_en = translate(p2,"english")
|
189 |
ln = len(result)
|
190 |
idxs = list(range(ln))
|
191 |
+
p1s = [p1_en for _ in idxs]
|
192 |
+
p2s = [p2_en for _ in idxs]
|
193 |
return list(Pool(ln).imap( _ret, idxs, p1s, p2s ))
|
194 |
run_button.click(fn=_rets,inputs=[prompt,prompt2],outputs=result)
|
195 |
|