import gradio as gr import util import process_image from run_cmd import run_cmd is_colab = util.is_google_colab() title = "ESRGAN Upscaling With Custom Models" with gr.Blocks(title=title, fill_height=True) as demo: gr.Markdown( f""" # {title} This space uses old ESRGAN architecture to upscale images, using models made by the community. Once the photo upscaled (*it can take a long time, this space only uses CPU*). """) gr.HTML(value="For faster upscaling using GPU: buy me a coffee (beer) if this helped πΊπ") gr.HTML(value="") with gr.Row(): with gr.Column(): input_image = gr.Image( sources="upload", type="filepath", label="Image to upscale" ) upscale_size = gr.Radio( ["x4", "x2"], label="Upscale by:", value="x4" ) upscale_type = gr.Radio( ["Manga", "Anime", "Photo", "General"], label="Select the type of picture you want to upscale:", value="Manga" ) with gr.Row(): upscale_btn = gr.Button(value="Upscale", variant="primary") with gr.Column(): output_image = gr.Image( type="pil", interactive=False, label="Upscaled image", elem_id="preview_img" ) with gr.Row(): out_file = gr.DownloadButton( visible=False, ) gr.HTML(value="
") upscale_btn.click( process_image.inference, inputs=[input_image, upscale_size, upscale_type], outputs=[output_image, out_file] ) demo.queue() demo.launch(debug=is_colab, share=is_colab, inline=is_colab)