onebitss commited on
Commit
83ae567
·
verified ·
1 Parent(s): 015fd06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -121,14 +121,14 @@ lazy_realesrgan_x4 = LazyRealESRGAN(device, scale=4)
121
 
122
  @timer_func
123
  def resize_and_upscale(input_image, resolution):
124
- scale = 5 if resolution <= 2048 else 4
125
  input_image = input_image.convert("RGB")
126
  W, H = input_image.size
127
  k = float(resolution) / min(H, W)
128
  H = int(round(H * k / 64.0)) * 64
129
  W = int(round(W * k / 64.0)) * 64
130
  img = input_image.resize((W, H), resample=Image.LANCZOS)
131
- if scale == 5:
132
  img = lazy_realesrgan_x2.predict(img)
133
  else:
134
  img = lazy_realesrgan_x4.predict(img)
@@ -207,11 +207,11 @@ with gr.Blocks() as demo:
207
  with gr.Column():
208
  output_slider = ImageSlider(label="Before / After", type="numpy")
209
  with gr.Accordion("Advanced Options", open=False):
210
- resolution = gr.Slider(minimum=256, maximum=2048, value=1920, step=256, label="Resolution")
211
- num_inference_steps = gr.Slider(minimum=1, maximum=50, value=49, step=1, label="Number of Inference Steps")
212
- strength = gr.Slider(minimum=0, maximum=1, value=0.15, step=0.01, label="Strength")
213
  hdr = gr.Slider(minimum=0, maximum=1, value=0, step=0.1, label="HDR Effect")
214
- guidance_scale = gr.Slider(minimum=0, maximum=20, value=6, step=0.5, label="Guidance Scale")
215
 
216
  run_button.click(fn=gradio_process_image,
217
  inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],
 
121
 
122
  @timer_func
123
  def resize_and_upscale(input_image, resolution):
124
+ scale = 2 if resolution <= 2048 else 4
125
  input_image = input_image.convert("RGB")
126
  W, H = input_image.size
127
  k = float(resolution) / min(H, W)
128
  H = int(round(H * k / 64.0)) * 64
129
  W = int(round(W * k / 64.0)) * 64
130
  img = input_image.resize((W, H), resample=Image.LANCZOS)
131
+ if scale == 2:
132
  img = lazy_realesrgan_x2.predict(img)
133
  else:
134
  img = lazy_realesrgan_x4.predict(img)
 
207
  with gr.Column():
208
  output_slider = ImageSlider(label="Before / After", type="numpy")
209
  with gr.Accordion("Advanced Options", open=False):
210
+ resolution = gr.Slider(minimum=256, maximum=2048, value=1080, step=256, label="Resolution")
211
+ num_inference_steps = gr.Slider(minimum=1, maximum=50, value=30, step=1, label="Number of Inference Steps")
212
+ strength = gr.Slider(minimum=0, maximum=1, value=0.2, step=0.01, label="Strength")
213
  hdr = gr.Slider(minimum=0, maximum=1, value=0, step=0.1, label="HDR Effect")
214
+ guidance_scale = gr.Slider(minimum=0, maximum=20, value=4, step=0.5, label="Guidance Scale")
215
 
216
  run_button.click(fn=gradio_process_image,
217
  inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],