Spaces:
Running
on
Zero
Running
on
Zero
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)
|
@@ -164,7 +164,7 @@ def gradio_process_image(input_image, resolution, num_inference_steps, strength,
|
|
164 |
|
165 |
condition_image = prepare_image(input_image, resolution, hdr)
|
166 |
|
167 |
-
prompt = "masterpiece, best quality, highres"
|
168 |
negative_prompt = "low quality, normal quality, ugly, blurry, blur, lowres, bad anatomy, bad hands, cropped, worst quality, verybadimagenegative_v1.3, JuggernautNegative-neg"
|
169 |
|
170 |
options = {
|
@@ -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=
|
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 = 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)
|
|
|
164 |
|
165 |
condition_image = prepare_image(input_image, resolution, hdr)
|
166 |
|
167 |
+
prompt = "masterpiece, best quality, highres, family guy, 2d animation, family guy tv series animation"
|
168 |
negative_prompt = "low quality, normal quality, ugly, blurry, blur, lowres, bad anatomy, bad hands, cropped, worst quality, verybadimagenegative_v1.3, JuggernautNegative-neg"
|
169 |
|
170 |
options = {
|
|
|
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],
|