Spaces:
Runtime error
Runtime error
add button to open in colab!
Browse files- ESRGAN_MANGA.ipynb +72 -0
- app.py +11 -6
ESRGAN_MANGA.ipynb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {
|
| 6 |
+
"id": "9LQUHs0MNqsh"
|
| 7 |
+
},
|
| 8 |
+
"source": [
|
| 9 |
+
"# ESRGAN Upscaling With Custom Models\n",
|
| 10 |
+
"\n",
|
| 11 |
+
"<br>\n",
|
| 12 |
+
"\n",
|
| 13 |
+
"This space uses old ESRGAN architecture to upscale images, using models made by the community.\n",
|
| 14 |
+
"\n",
|
| 15 |
+
"Once the photo upscaled (*it can take a long time, this space only uses CPU*), click or tap the **download button** under the image to download it. **The preview image is not the upscaled one.**\n",
|
| 16 |
+
"\n",
|
| 17 |
+
"To run, just click or tap the play button below, and open the second Gradio link.\n",
|
| 18 |
+
"\n",
|
| 19 |
+
"<br>\n",
|
| 20 |
+
"\n",
|
| 21 |
+
"<a href='https://ko-fi.com/Y8Y7GVAAF' target='_blank' style='display:block;margin-bottom:5px'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "markdown",
|
| 26 |
+
"metadata": {
|
| 27 |
+
"id": "IuJNlXTDFNRi"
|
| 28 |
+
},
|
| 29 |
+
"source": [
|
| 30 |
+
"## Clone Hugging Face Spaces Repo and install requeriments and start Gradio server"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"cell_type": "code",
|
| 35 |
+
"execution_count": null,
|
| 36 |
+
"metadata": {
|
| 37 |
+
"colab": {
|
| 38 |
+
"base_uri": "https://localhost:8080/"
|
| 39 |
+
},
|
| 40 |
+
"id": "KzHQxbDoEHVm",
|
| 41 |
+
"outputId": "a0aad94e-df09-4207-dca4-1845c5d5d59a"
|
| 42 |
+
},
|
| 43 |
+
"outputs": [],
|
| 44 |
+
"source": [
|
| 45 |
+
"from IPython.display import clear_output\n",
|
| 46 |
+
"!git lfs install\n",
|
| 47 |
+
"!git lfs clone \"https://huggingface.co/spaces/0x90e/ESRGAN-MANGA\"\n",
|
| 48 |
+
"%cd ESRGAN-MANGA\n",
|
| 49 |
+
"!pip install -r requirements.txt -q\n",
|
| 50 |
+
"!pip install gradio\n",
|
| 51 |
+
"clear_output()\n",
|
| 52 |
+
"!python app.py"
|
| 53 |
+
]
|
| 54 |
+
}
|
| 55 |
+
],
|
| 56 |
+
"metadata": {
|
| 57 |
+
"accelerator": "GPU",
|
| 58 |
+
"colab": {
|
| 59 |
+
"provenance": []
|
| 60 |
+
},
|
| 61 |
+
"gpuClass": "standard",
|
| 62 |
+
"kernelspec": {
|
| 63 |
+
"display_name": "Python 3",
|
| 64 |
+
"name": "python3"
|
| 65 |
+
},
|
| 66 |
+
"language_info": {
|
| 67 |
+
"name": "python"
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"nbformat": 4,
|
| 71 |
+
"nbformat_minor": 0
|
| 72 |
+
}
|
app.py
CHANGED
|
@@ -19,6 +19,7 @@ css = '''
|
|
| 19 |
.file-preview div div:nth-child(3) {
|
| 20 |
text-align: right !important;
|
| 21 |
padding: 0.5rem 0;
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
#preview_img {
|
|
@@ -45,6 +46,10 @@ css = '''
|
|
| 45 |
color: white;
|
| 46 |
background-color: gray;
|
| 47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
'''
|
| 49 |
|
| 50 |
title = "ESRGAN Upscaling With Custom Models"
|
|
@@ -52,14 +57,14 @@ title = "ESRGAN Upscaling With Custom Models"
|
|
| 52 |
with gr.Blocks(title=title, css=css) as demo:
|
| 53 |
gr.Markdown(
|
| 54 |
f"""
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
**Colab coming soon™**
|
| 61 |
""")
|
| 62 |
|
|
|
|
|
|
|
| 63 |
gr.HTML(value="<a href='https://ko-fi.com/Y8Y7GVAAF' target='_blank' style='display:block;margin-bottom:5px'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>")
|
| 64 |
|
| 65 |
with gr.Box():
|
|
@@ -78,7 +83,7 @@ with gr.Blocks(title=title, css=css) as demo:
|
|
| 78 |
with gr.Row():
|
| 79 |
out_file = gr.File(interactive=False, show_label=False, elem_id="preview_file")
|
| 80 |
|
| 81 |
-
gr.HTML(value="<p><a href='https://upscale.wiki/wiki/Model_Database'>Model Database</a></p>")
|
| 82 |
|
| 83 |
upscale_btn.click(process_image.inference, inputs=[input_image, upscale_size, upscale_type], outputs=[output_image, out_file])
|
| 84 |
|
|
|
|
| 19 |
.file-preview div div:nth-child(3) {
|
| 20 |
text-align: right !important;
|
| 21 |
padding: 0.5rem 0;
|
| 22 |
+
width: auto;
|
| 23 |
}
|
| 24 |
|
| 25 |
#preview_img {
|
|
|
|
| 46 |
color: white;
|
| 47 |
background-color: gray;
|
| 48 |
}
|
| 49 |
+
|
| 50 |
+
.colab_img {
|
| 51 |
+
margin: 10px 0;
|
| 52 |
+
}
|
| 53 |
'''
|
| 54 |
|
| 55 |
title = "ESRGAN Upscaling With Custom Models"
|
|
|
|
| 57 |
with gr.Blocks(title=title, css=css) as demo:
|
| 58 |
gr.Markdown(
|
| 59 |
f"""
|
| 60 |
+
# {title}
|
| 61 |
+
This space uses old ESRGAN architecture to upscale images, using models made by the community.
|
| 62 |
|
| 63 |
+
Once the photo upscaled (*it can take a long time, this space only uses CPU*), click or tap the **download button** under the image to download it. **The preview image is not the upscaled one**
|
|
|
|
|
|
|
| 64 |
""")
|
| 65 |
|
| 66 |
+
gr.HTML(value="For faster upscaling: <a href='https://colab.research.google.com/drive/1QfOA6BBdL4NrUmx-9d-pjacxNfu81HQo#scrollTo=H7qo-6AWFbLH' target='_blank'><img class='colab_img' src='https://colab.research.google.com/assets/colab-badge.svg' alt='Open In Colab'></a>")
|
| 67 |
+
|
| 68 |
gr.HTML(value="<a href='https://ko-fi.com/Y8Y7GVAAF' target='_blank' style='display:block;margin-bottom:5px'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>")
|
| 69 |
|
| 70 |
with gr.Box():
|
|
|
|
| 83 |
with gr.Row():
|
| 84 |
out_file = gr.File(interactive=False, show_label=False, elem_id="preview_file")
|
| 85 |
|
| 86 |
+
gr.HTML(value="<p><a href='https://upscale.wiki/wiki/Model_Database'>Model Database</a></p><p><h2>Known issue:</h2> when downloading a photo for the second time in Colab, it doesn't work. If someone knows why, please create a thread in the discussion tab and I'll fix this issue.</p>")
|
| 87 |
|
| 88 |
upscale_btn.click(process_image.inference, inputs=[input_image, upscale_size, upscale_type], outputs=[output_image, out_file])
|
| 89 |
|