fangxia
fix bug
16e3a48
import os
import time
import gradio as gr
from client1 import inference
title = "Dreamoving-Phantom"
img_urls=['https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/public/dashscope/show3.png']
description = f""" Gradio demo for [Dreamoving-Phantom](https://github.com/dreamoving/Phantom)
DreaMoving-Phantom is a general and automatic image enhancement and super resolution framework.
**No need to adjust parameters or select models, just run with one click.** The demo can be adapted to a variety of scenarios.
🔥 New feature: We added text super-resolution module so that the demo can better handle text scenes. This module will still be updated iteratively.
🧭 Instructions: Input resolution: 64<=short_side<=2160, long_side<=3840, aspect ratio<=4; best input resolution: no larger than 1080p.
"""
examples=[['examples/3.png'],['examples/4.png'],['examples/5.png'],['examples/6.png'],
['examples/7.png'],['examples/8.png'],['examples/1.png'],['examples/9.jpg'],['examples/10.png'],
['examples/12.png'],['examples/13.png'],['examples/14.png']]
# result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2)
with gr.Blocks(css="style.css") as demo:
gr.Markdown(f"<h1 style='text-align: center; font-size: 2em;'>{title}</h1>")
gr.Markdown(description, elem_id='description')
with gr.Row():
with gr.Column(scale=0.67):
input_image = gr.Image(type="pil", label="Input Image", image_mode="RGBA")
upsample_scale = gr.Slider(label="Upsample Scale", minimum=1, maximum=4, value=2, step=1, elem_id='slider')
btn = gr.Button("Run", elem_id='button_param')
with gr.Column():
output_gallery = gr.Gallery(label="Output", elem_id="output_gallery")
# output_gallery = gr.Image(type="pil", label="Output", elem_id="output_gallery", image_mode="RGBA")
output_text = gr.Textbox(label="Log", elem_id="output_text")
btn.click(
inference,
inputs=[input_image, upsample_scale],
outputs=[output_gallery, output_text]
)
with gr.Row():
with gr.Column(scale=2):
gr.Markdown('**Examples**', elem_id='example')
gr.Examples(label='', examples=examples, inputs=[input_image, upsample_scale], outputs=[output_gallery, output_text], examples_per_page=15, elem_id='examples')
with gr.Column(scale=3):
additional_text = "**Gallery**"
gr.Markdown(additional_text, elem_id='additional_text')
gr.HTML(
f"""
<div style='text-align: center;'>
<img src='{img_urls[0]}' alt='gallery' style='max-width: 100%; height: auto; margin-top: 5px;'>
</div>
""",
elem_id='html_image'
)
# concurrency_count, concurrency_limit, max_threads
demo.queue(api_open=False, max_size=1000).launch(
server_name="0.0.0.0", # if os.getenv('GRADIO_LISTEN', '') != '' else "127.0.0.1",
share=True,
server_port=7860,
root_path=f"/{os.getenv('GRADIO_PROXY_PATH')}" if os.getenv('GRADIO_PROXY_PATH') else ""
)