Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,55 @@ from gradio_imageslider import ImageSlider
|
|
4 |
from image_gen_aux import UpscaleWithModel
|
5 |
from image_gen_aux.utils import load_image
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# My models, alphabetically sorted
|
13 |
MODELS = {
|
@@ -117,41 +162,37 @@ MODELS = {
|
|
117 |
@spaces.GPU
|
118 |
def upscale_image(image, model_selection):
|
119 |
original = load_image(image)
|
120 |
-
|
121 |
upscaler = UpscaleWithModel.from_pretrained(MODELS[model_selection]).to("cuda")
|
122 |
image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
123 |
-
|
124 |
return original, image
|
125 |
|
126 |
-
|
127 |
def clear_result():
|
128 |
return gr.update(value=None)
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
<div align="center">Use this Space to upscale your images, makes use of the
|
133 |
-
<a href="https://github.com/asomoza/image_gen_aux">Image Generation Auxiliary Tools</a> library. <br>
|
134 |
-
This space makes use of <a href="https://github.com/Phhofm/models">my self trained models</a> and tiles at 1024x1024<br>
|
135 |
-
Here is an <a href="https://huggingface.co/spaces/Phips/Upscaler/resolve/main/input_example1.png">example input image</a> you can use to try it out.</div>
|
136 |
-
"""
|
137 |
-
|
138 |
-
with gr.Blocks() as demo:
|
139 |
gr.HTML(title)
|
140 |
with gr.Row():
|
141 |
-
with gr.Column():
|
142 |
-
input_image = gr.Image(type="pil", label="Input Image")
|
143 |
-
|
144 |
model_selection = gr.Dropdown(
|
145 |
choices=list(MODELS.keys()),
|
146 |
value="4xNomosWebPhoto_RealPLKSR",
|
147 |
label="Model (alphabetically sorted)",
|
|
|
148 |
)
|
149 |
-
|
150 |
-
|
151 |
-
with gr.Column():
|
152 |
result = ImageSlider(
|
153 |
interactive=False,
|
154 |
label="Generated Image",
|
|
|
155 |
)
|
156 |
|
157 |
run_button.click(
|
@@ -164,5 +205,5 @@ with gr.Blocks() as demo:
|
|
164 |
outputs=result,
|
165 |
)
|
166 |
|
167 |
-
|
168 |
-
demo.launch(share=False)
|
|
|
4 |
from image_gen_aux import UpscaleWithModel
|
5 |
from image_gen_aux.utils import load_image
|
6 |
|
7 |
+
# Custom CSS for dark grey-blue gradients, animations, and hover effects
|
8 |
+
custom_css = r"""
|
9 |
+
body {
|
10 |
+
background: linear-gradient(135deg, #2a2a3f, #1e1e2f);
|
11 |
+
color: #e0e0e0;
|
12 |
+
}
|
13 |
+
.gradio-container {
|
14 |
+
background: transparent;
|
15 |
+
}
|
16 |
+
.gradio-block {
|
17 |
+
background: rgba(30, 30, 47, 0.8);
|
18 |
+
border-radius: 16px;
|
19 |
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
|
20 |
+
padding: 20px;
|
21 |
+
margin-bottom: 20px;
|
22 |
+
transition: transform 0.3s ease;
|
23 |
+
}
|
24 |
+
.gradio-block:hover {
|
25 |
+
transform: translateY(-5px);
|
26 |
+
}
|
27 |
+
.gradio-button {
|
28 |
+
background: linear-gradient(135deg, #3a3a5f, #2a2a4f);
|
29 |
+
color: #ffffff;
|
30 |
+
border: none;
|
31 |
+
padding: 10px 20px;
|
32 |
+
font-size: 1rem;
|
33 |
+
border-radius: 8px;
|
34 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
|
35 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
36 |
+
}
|
37 |
+
.gradio-button:hover {
|
38 |
+
transform: translateY(-3px);
|
39 |
+
box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
|
40 |
+
}
|
41 |
+
.gradio-image {
|
42 |
+
border-radius: 12px;
|
43 |
+
transition: filter 0.4s ease;
|
44 |
+
}
|
45 |
+
.gradio-image:hover {
|
46 |
+
filter: brightness(1.1) saturate(1.2);
|
47 |
+
}
|
48 |
+
@keyframes glow {
|
49 |
+
0%, 100% { text-shadow: 0 0 5px rgba(58, 138, 189, 0.7), 0 0 10px rgba(58, 138, 189, 0.5); }
|
50 |
+
50% { text-shadow: 0 0 20px rgba(58, 138, 189, 1), 0 0 30px rgba(58, 138, 189, 0.8); }
|
51 |
+
}
|
52 |
+
.title {
|
53 |
+
animation: glow 2s infinite;
|
54 |
+
}
|
55 |
+
"""
|
56 |
|
57 |
# My models, alphabetically sorted
|
58 |
MODELS = {
|
|
|
162 |
@spaces.GPU
|
163 |
def upscale_image(image, model_selection):
|
164 |
original = load_image(image)
|
|
|
165 |
upscaler = UpscaleWithModel.from_pretrained(MODELS[model_selection]).to("cuda")
|
166 |
image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
|
|
167 |
return original, image
|
168 |
|
|
|
169 |
def clear_result():
|
170 |
return gr.update(value=None)
|
171 |
|
172 |
+
# Title with neon glow effect
|
173 |
+
title = '''<h1 align="center" class="title">Image Upscaler</h1>
|
174 |
+
<div align="center">Use this Space to upscale your images with fancy CSS animations and dark gradients. powered by
|
175 |
+
<a href="https://github.com/asomoza/image_gen_aux" style="color:#3aaebd; text-decoration:none;">Image Gen Aux</a> and
|
176 |
+
<a href="https://github.com/Phhofm/models" style="color:#3aaebd; text-decoration:none;">self-trained models</a>.</div>
|
177 |
+
'''
|
178 |
|
179 |
+
with gr.Blocks(css=custom_css) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
gr.HTML(title)
|
181 |
with gr.Row():
|
182 |
+
with gr.Column(scale=1, min_width=200):
|
183 |
+
input_image = gr.Image(type="pil", label="Input Image", elem_classes="gradio-image")
|
|
|
184 |
model_selection = gr.Dropdown(
|
185 |
choices=list(MODELS.keys()),
|
186 |
value="4xNomosWebPhoto_RealPLKSR",
|
187 |
label="Model (alphabetically sorted)",
|
188 |
+
elem_id="model-dropdown"
|
189 |
)
|
190 |
+
run_button = gr.Button("Upscale", elem_classes="gradio-button")
|
191 |
+
with gr.Column(scale=1, min_width=200):
|
|
|
192 |
result = ImageSlider(
|
193 |
interactive=False,
|
194 |
label="Generated Image",
|
195 |
+
elem_classes="gradio-image"
|
196 |
)
|
197 |
|
198 |
run_button.click(
|
|
|
205 |
outputs=result,
|
206 |
)
|
207 |
|
208 |
+
if __name__ == "__main__":
|
209 |
+
demo.launch(share=False)
|