Yaron Koresh commited on
Commit
4a68766
·
verified ·
1 Parent(s): ff24105

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
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=25)
87
  def Piper(_do,_dont):
88
  return pipe(
89
  _do,
90
  height=320,
91
  width=480,
92
  negative_prompt=_dont,
93
- num_inference_steps=50,
94
- guidance_scale=2
95
  )
96
 
97
- def infer(prompt,prompt2):
98
  name = generate_random_string(12)+".png"
99
- prompt_en = translate(prompt,"english")
100
- prompt2_en = translate(prompt2,"english")
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'realistic natural sharp light vivid vintage { prompt_en } amazing yet reasonable scene coloring'
105
- if prompt2 == None or prompt2.strip() == "":
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 = [p1 for _ in idxs]
190
- p2s = [p2 for _ in idxs]
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