ESRGAN-MANGA / app.py
0x90e's picture
add image tiling from Real-ESRGAN to save memory
17cfe57
raw
history blame
2.19 kB
import gradio as gr
import util
import process_image
from run_cmd import run_cmd
is_colab = util.is_google_colab()
css = '''
.file-preview {
overflow: hidden !important;
margin: 5px 0 !important;
padding: 0 10px !important;
}
.file-preview div div:nth-child(2) {
flex-grow: 1 !important;
}
.file-preview div div:nth-child(3) {
text-align: right !important;
}
#preview_img {
user-select: none !important;
touch-action: none !important;
pointer-events: none !important;
}
'''
title = "ESRGAN Upscaling With Custom Models"
with gr.Blocks(title=title, css=css) 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, click or tap the **download button** under the image to download it. **The preview image is not the upscaled one**
I'll add more models after optimizing to size of the output image, right now it could be quite big.
**Colab coming soon™**
""")
with gr.Box():
with gr.Row():
with gr.Column():
input_image = gr.Image(type="pil", label="Input")
upscale_size = gr.Radio(["x4", "x2"], label="Upscale by:", value="x4")
upscale_type = gr.Radio(["Manga", "Anime", "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="filepath", interactive=False, label="Upscaled image", elem_id="preview_img")
with gr.Row():
out_file = gr.File(interactive=False, show_label=False, visible=False)
gr.HTML(value="<p><a href='https://upscale.wiki/wiki/Model_Database'>Model Database</a></p>")
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)