nyanko7 commited on
Commit
8e33c4a
1 Parent(s): aee2f15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -136,7 +136,7 @@ def sign_message(message, key):
136
  signed_hash = base64.b64encode(hmac_digest).decode()
137
  return signed_hash
138
 
139
- def run(prompt, radio="model-v2", preset=PRESET_Q, h=1216, w=832, negative_prompt=NEGATIVE_PROMPT, guidance_scale=4.0, randomize_seed=True, seed=42, tpu_inference=False, do_img2img=False, init_image=None, image2image_resize=False, image2image_strength=0, progress=gr.Progress(track_tqdm=True)):
140
  if init_image is None:
141
  do_img2img = False
142
 
@@ -150,11 +150,11 @@ def run(prompt, radio="model-v2", preset=PRESET_Q, h=1216, w=832, negative_promp
150
  prompt = prompt.replace("!", " ").replace("\n", " ") # remote endpoint unsupported
151
  if do_img2img:
152
  init_image = codecs.encode(pickle.dumps(init_image, protocol=pickle.HIGHEST_PROTOCOL), "base64").decode('latin1')
153
- return tpu_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed, do_img2img, init_image, image2image_strength)
154
  else:
155
- return tpu_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed)
156
 
157
- return zero_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed, do_img2img, init_image, image2image_strength)
158
 
159
  @spaces.GPU
160
  def zero_inference_api(prompt, radio="model-v2", preset=PRESET_Q, h=1216, w=832, negative_prompt=NEGATIVE_PROMPT, guidance_scale=4.0, randomize_seed=True, seed=42, do_img2img=False, init_image=None, image2image_strength=0, inference_steps=25, progress=gr.Progress(track_tqdm=True)):
@@ -267,7 +267,7 @@ with gr.Blocks(theme=theme) as demo:
267
  image2image_resize = gr.Checkbox(label="Resize input image", value=False, visible=False)
268
  image2image_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Noising strength", value=0.7, visible=False)
269
 
270
- with gr.Column(scale=2.5):
271
  output = gr.Image(type="filepath", interactive=False)
272
 
273
  gr.Examples(fn=run, examples=["mayano_top_gun_\(umamusume\), 1girl, rurudo", "sho (sho lwlw),[[[ohisashiburi]]],fukuro daizi,tianliang duohe fangdongye,[daidai ookami],year_2023, (wariza), depth of field, official_art"], inputs=prompt, outputs=[output, seed], cache_examples="lazy")
 
136
  signed_hash = base64.b64encode(hmac_digest).decode()
137
  return signed_hash
138
 
139
+ def run(prompt, radio="model-v2", preset=PRESET_Q, h=1216, w=832, negative_prompt=NEGATIVE_PROMPT, guidance_scale=4.0, randomize_seed=True, seed=42, tpu_inference=False, do_img2img=False, init_image=None, image2image_resize=False, image2image_strength=0, inference_steps=25, progress=gr.Progress(track_tqdm=True)):
140
  if init_image is None:
141
  do_img2img = False
142
 
 
150
  prompt = prompt.replace("!", " ").replace("\n", " ") # remote endpoint unsupported
151
  if do_img2img:
152
  init_image = codecs.encode(pickle.dumps(init_image, protocol=pickle.HIGHEST_PROTOCOL), "base64").decode('latin1')
153
+ return tpu_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed, do_img2img, init_image, image2image_strength, inference_steps=inference_steps)
154
  else:
155
+ return tpu_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed, inference_steps=inference_steps)
156
 
157
+ return zero_inference_api(prompt, radio, preset, h, w, negative_prompt, guidance_scale, randomize_seed, seed, do_img2img, init_image, image2image_strength, inference_steps=inference_steps)
158
 
159
  @spaces.GPU
160
  def zero_inference_api(prompt, radio="model-v2", preset=PRESET_Q, h=1216, w=832, negative_prompt=NEGATIVE_PROMPT, guidance_scale=4.0, randomize_seed=True, seed=42, do_img2img=False, init_image=None, image2image_strength=0, inference_steps=25, progress=gr.Progress(track_tqdm=True)):
 
267
  image2image_resize = gr.Checkbox(label="Resize input image", value=False, visible=False)
268
  image2image_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Noising strength", value=0.7, visible=False)
269
 
270
+ with gr.Column():
271
  output = gr.Image(type="filepath", interactive=False)
272
 
273
  gr.Examples(fn=run, examples=["mayano_top_gun_\(umamusume\), 1girl, rurudo", "sho (sho lwlw),[[[ohisashiburi]]],fukuro daizi,tianliang duohe fangdongye,[daidai ookami],year_2023, (wariza), depth of field, official_art"], inputs=prompt, outputs=[output, seed], cache_examples="lazy")