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

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

parent 1ebd337d
......@@ -17,7 +17,6 @@ import numpy as np
from RealESRGAN import RealESRGAN
import gradio as gr
from gradio_imageslider import ImageSlider
USE_TORCH_COMPILE = False
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,
result = lazy_pipe(**options).images[0]
print("Image processing completed successfully")
# Convert input_image and result to numpy arrays
input_array = np.array(input_image)
result_array = np.array(result)
return [input_array, result_array]
return result
title = """<h1 align="center">Image Upscaler with Tile Controlnet</h1>
<p align="center">The main ideas come from</p>
......@@ -219,7 +214,7 @@ with gr.Blocks(css="./theme.css") as demo:
input_image = gr.Image(type="pil", label="Input Image")
run_button = gr.Button("Enhance Image")
with gr.Column():
output_slider = ImageSlider(label="Before / After", type="numpy")
gallery = gr.Image(label="Generated Images")
with gr.Accordion("Advanced Options", open=False):
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")
......@@ -229,7 +224,7 @@ with gr.Blocks(css="./theme.css") as demo:
run_button.click(fn=gradio_process_image,
inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],
outputs=output_slider)
outputs=gallery)
# Add examples with all required inputs
gr.Examples(
......@@ -239,7 +234,7 @@ with gr.Blocks(css="./theme.css") as demo:
["image3.png", 512, 20, 0.4, 0, 3],
],
inputs=[input_image, resolution, num_inference_steps, strength, hdr, guidance_scale],
outputs=output_slider,
outputs=gallery,
fn=gradio_process_image,
cache_examples=True,
)
......
......@@ -9,6 +9,5 @@ accelerate
safetensors
spaces
peft
gradio
pillow
gradio-imageslider
\ No newline at end of file
gradio==3.40.0
pillow
\ 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