Spaces:
Running
on
Zero
Running
on
Zero
lucakempkes
commited on
Commit
·
f74caab
1
Parent(s):
6f345cc
update models
Browse files- .gitattributes +1 -1
- app.py +64 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
@@ -32,4 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
from gradio_imageslider import ImageSlider
|
4 |
+
from image_gen_aux import UpscaleWithModel
|
5 |
+
from image_gen_aux.utils import load_image
|
6 |
+
|
7 |
+
MODELS = {
|
8 |
+
"4xRealESRGAN": "luca115/4xRealESRGAN",
|
9 |
+
"4xUltraSharp": "Kim2091/UltraSharp",
|
10 |
+
"4xNomosWebPhoto_RealPLKSR": "OzzyGT/4xNomosWebPhoto_RealPLKSR",
|
11 |
+
"4xRemacri": "OzzyGT/4xRemacri",
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
@spaces.GPU
|
16 |
+
def upscale_image(image, model_selection):
|
17 |
+
original = load_image(image)
|
18 |
+
|
19 |
+
upscaler = UpscaleWithModel.from_pretrained(MODELS[model_selection]).to("cuda")
|
20 |
+
image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
21 |
+
|
22 |
+
return original, image
|
23 |
+
|
24 |
+
|
25 |
+
def clear_result():
|
26 |
+
return gr.update(value=None)
|
27 |
+
|
28 |
+
|
29 |
+
title = """<h1 align="center">Best Upscaling Models</h1>
|
30 |
+
<div align="center">This space is a showcase of the different super resolution models you can use to upscale with the
|
31 |
+
<a href="https://github.com/asomoza/image_gen_aux">Image Generation Auxiliary Tools</a> library.</div>
|
32 |
+
"""
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
gr.HTML(title)
|
36 |
+
with gr.Row():
|
37 |
+
with gr.Column():
|
38 |
+
input_image = gr.Image(type="pil", label="Input Image")
|
39 |
+
|
40 |
+
model_selection = gr.Dropdown(
|
41 |
+
choices=list(MODELS.keys()),
|
42 |
+
value="UltraSharp",
|
43 |
+
label="Model",
|
44 |
+
)
|
45 |
+
|
46 |
+
run_button = gr.Button("Upscale")
|
47 |
+
with gr.Column():
|
48 |
+
result = ImageSlider(
|
49 |
+
interactive=False,
|
50 |
+
label="Generated Image",
|
51 |
+
)
|
52 |
+
|
53 |
+
run_button.click(
|
54 |
+
fn=clear_result,
|
55 |
+
inputs=None,
|
56 |
+
outputs=result,
|
57 |
+
).then(
|
58 |
+
fn=upscale_image,
|
59 |
+
inputs=[input_image, model_selection],
|
60 |
+
outputs=result,
|
61 |
+
)
|
62 |
+
|
63 |
+
|
64 |
+
demo.launch(share=False)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
git+https://github.com/asomoza/image_gen_aux.git
|
3 |
+
spaces
|
4 |
+
gradio
|
5 |
+
gradio-imageslider
|
6 |
+
numpy==1.26.4
|