Commit 4bd3600f authored by chenpangpang's avatar chenpangpang
Browse files

feat: 删除输出图片对比,解决gradio显示不全的问题

parent 1ebd337d
...@@ -17,7 +17,6 @@ import numpy as np ...@@ -17,7 +17,6 @@ import numpy as np
from RealESRGAN import RealESRGAN from RealESRGAN import RealESRGAN
import gradio as gr import gradio as gr
from gradio_imageslider import ImageSlider
USE_TORCH_COMPILE = False USE_TORCH_COMPILE = False
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1" ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
...@@ -198,11 +197,7 @@ def gradio_process_image(input_image, resolution, num_inference_steps, strength, ...@@ -198,11 +197,7 @@ def gradio_process_image(input_image, resolution, num_inference_steps, strength,
result = lazy_pipe(**options).images[0] result = lazy_pipe(**options).images[0]
print("Image processing completed successfully") print("Image processing completed successfully")
# Convert input_image and result to numpy arrays return result
input_array = np.array(input_image)
result_array = np.array(result)
return [input_array, result_array]
title = """<h1 align="center">Image Upscaler with Tile Controlnet</h1> title = """<h1 align="center">Image Upscaler with Tile Controlnet</h1>
<p align="center">The main ideas come from</p> <p align="center">The main ideas come from</p>
...@@ -219,7 +214,7 @@ with gr.Blocks(css="./theme.css") as demo: ...@@ -219,7 +214,7 @@ with gr.Blocks(css="./theme.css") as demo:
input_image = gr.Image(type="pil", label="Input Image") input_image = gr.Image(type="pil", label="Input Image")
run_button = gr.Button("Enhance Image") run_button = gr.Button("Enhance Image")
with gr.Column(): with gr.Column():
output_slider = ImageSlider(label="Before / After", type="numpy") gallery = gr.Image(label="Generated Images")
with gr.Accordion("Advanced Options", open=False): with gr.Accordion("Advanced Options", open=False):
resolution = gr.Slider(minimum=256, maximum=2048, value=512, step=256, label="Resolution") resolution = gr.Slider(minimum=256, maximum=2048, value=512, step=256, label="Resolution")
num_inference_steps = gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Number of Inference Steps") num_inference_steps = gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Number of Inference Steps")
...@@ -229,7 +224,7 @@ with gr.Blocks(css="./theme.css") as demo: ...@@ -229,7 +224,7 @@ with gr.Blocks(css="./theme.css") as demo:
run_button.click(fn=gradio_process_image, run_button.click(fn=gradio_process_image,
inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale], inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],
outputs=output_slider) outputs=gallery)
# Add examples with all required inputs # Add examples with all required inputs
gr.Examples( gr.Examples(
...@@ -239,7 +234,7 @@ with gr.Blocks(css="./theme.css") as demo: ...@@ -239,7 +234,7 @@ with gr.Blocks(css="./theme.css") as demo:
["image3.png", 512, 20, 0.4, 0, 3], ["image3.png", 512, 20, 0.4, 0, 3],
], ],
inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale], inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],
outputs=output_slider, outputs=gallery,
fn=gradio_process_image, fn=gradio_process_image,
cache_examples=True, cache_examples=True,
) )
......
...@@ -9,6 +9,5 @@ accelerate ...@@ -9,6 +9,5 @@ accelerate
safetensors safetensors
spaces spaces
peft peft
gradio gradio==3.40.0
pillow pillow
gradio-imageslider \ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment