Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 =
|
| 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 ==
|
| 132 |
img = lazy_realesrgan_x2.predict(img)
|
| 133 |
else:
|
| 134 |
img = lazy_realesrgan_x4.predict(img)
|
|
@@ -208,10 +208,10 @@ with gr.Blocks() as demo:
|
|
| 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=
|
| 212 |
-
strength = gr.Slider(minimum=0, maximum=1, value=0.
|
| 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=
|
| 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 = 3 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 == 3:
|
| 132 |
img = lazy_realesrgan_x2.predict(img)
|
| 133 |
else:
|
| 134 |
img = lazy_realesrgan_x4.predict(img)
|
|
|
|
| 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=20, step=1, label="Number of Inference Steps")
|
| 212 |
+
strength = gr.Slider(minimum=0, maximum=1, value=0.1, 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=3, 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],
|