dreamdrop-art commited on
Commit
f867354
1 Parent(s): d17adde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -12,6 +12,13 @@ import html
12
  import PIL
13
  from PIL import Image
14
  import re
 
 
 
 
 
 
 
15
 
16
  def send_prompt(prompt):
17
  return prompt
@@ -342,6 +349,7 @@ with gr.Blocks(css=css) as demo:
342
  i2i_cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
343
  i2i_denoising = gr.Slider(label="Denoising Strength", minimum=0, maximum=1, value=0.7, step=0.1)
344
  i2i_seed = gr.Number(label="Seed", value=-1)
 
345
 
346
  with gr.Column(scale=2):
347
  i2i_image_output = gr.Gallery(show_label=False, rows=2)
@@ -468,6 +476,21 @@ with gr.Blocks(css=css) as demo:
468
  send_to_img2img_prompt.click(send_prompt, inputs=prompt_full, outputs=i2i_prompt)
469
  idea.submit(prompt_gen, inputs=idea, outputs=prompt_full)
470
  prompt_button.click(prompt_gen, inputs=idea, outputs=prompt_full)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
 
472
  with gr.Tab("BLIP"):
473
  with gr.Tab("Base"):
 
12
  import PIL
13
  from PIL import Image
14
  import re
15
+ import cv2
16
+ import numpy as np
17
+
18
+ def upscale_image(input_image, radio_input):
19
+ upscale_factor = radio_input
20
+ output_image = cv2.resize(input_image, None, fx = upscale_factor, fy = upscale_factor, interpolation = cv2.INTER_CUBIC)
21
+ return [output_image], output_image
22
 
23
  def send_prompt(prompt):
24
  return prompt
 
349
  i2i_cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
350
  i2i_denoising = gr.Slider(label="Denoising Strength", minimum=0, maximum=1, value=0.7, step=0.1)
351
  i2i_seed = gr.Number(label="Seed", value=-1)
352
+
353
 
354
  with gr.Column(scale=2):
355
  i2i_image_output = gr.Gallery(show_label=False, rows=2)
 
476
  send_to_img2img_prompt.click(send_prompt, inputs=prompt_full, outputs=i2i_prompt)
477
  idea.submit(prompt_gen, inputs=idea, outputs=prompt_full)
478
  prompt_button.click(prompt_gen, inputs=idea, outputs=prompt_full)
479
+ with gr.Tab("Upscaler"):
480
+ gr.HTML(value="""
481
+ <h1><center>Upscaler</center></h1>
482
+ """)
483
+ with gr.Row():
484
+ us_input = gr.Image(show_label=False, interactive=True)
485
+ us_radio = gr.Radio(label="Upscale Levels", choices=[2, 4, 6, 8, 10], value=2)
486
+ us_button = gr.Button(value="Generate with Upscaler", variant="primary")
487
+ with gr.Row():
488
+ us_output = gr.Gallery(show_label=False, rows=3, preview=True)
489
+ send_to_img2img_us = gr.Button(value="Send UPSCALED IMAGE to img2img")
490
+ us_past = gr.Image(interactive=False)
491
+
492
+ us_button.click(upscale_image, inputs=[us_input, us_radio], outputs=[us_output, us_past])
493
+ send_to_img2img_us.click(send_to_img2img_def, inputs=us_past, outputs=i2i_image_input)
494
 
495
  with gr.Tab("BLIP"):
496
  with gr.Tab("Base"):