Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,80 +11,120 @@ from diffusers import AutoencoderKL, LMSDiscreteScheduler, UNet2DConditionModel,
|
|
11 |
HTML_TEMPLATE = """
|
12 |
<style>
|
13 |
body {
|
14 |
-
background: linear-gradient(135deg, #
|
|
|
|
|
15 |
}
|
16 |
#app-header {
|
17 |
text-align: center;
|
18 |
-
background: rgba(255, 255, 255, 0.
|
19 |
-
padding:
|
20 |
-
border-radius:
|
21 |
-
box-shadow: 0
|
22 |
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
#app-header h1 {
|
25 |
-
color: #
|
26 |
-
font-size:
|
27 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
.concept {
|
30 |
position: relative;
|
31 |
-
transition: transform 0.3s;
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
.concept:hover {
|
34 |
-
transform:
|
|
|
35 |
}
|
36 |
.concept img {
|
37 |
-
width:
|
38 |
-
|
39 |
-
|
|
|
40 |
}
|
41 |
.concept-description {
|
42 |
-
|
43 |
-
bottom: -30px;
|
44 |
-
left: 50%;
|
45 |
-
transform: translateX(-50%);
|
46 |
-
background-color: #4CAF50;
|
47 |
color: white;
|
48 |
-
padding:
|
49 |
-
|
50 |
-
|
51 |
-
transition: opacity 0.3s;
|
52 |
-
}
|
53 |
-
.concept:hover .concept-description {
|
54 |
-
opacity: 1;
|
55 |
}
|
56 |
.artifact {
|
57 |
position: absolute;
|
58 |
-
background:
|
59 |
border-radius: 50%;
|
|
|
60 |
}
|
61 |
.artifact.large {
|
62 |
-
width:
|
63 |
-
height:
|
64 |
-
top: -
|
65 |
-
left: -
|
|
|
66 |
}
|
67 |
.artifact.medium {
|
68 |
-
width:
|
69 |
-
height:
|
70 |
-
bottom: -
|
71 |
-
right: -
|
|
|
72 |
}
|
73 |
.artifact.small {
|
74 |
-
width:
|
75 |
-
height:
|
76 |
top: 50%;
|
77 |
left: 50%;
|
78 |
transform: translate(-50%, -50%);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
</style>
|
81 |
<div id="app-header">
|
82 |
<div class="artifact large"></div>
|
83 |
<div class="artifact medium"></div>
|
84 |
<div class="artifact small"></div>
|
85 |
-
<h1>
|
86 |
-
<p>
|
87 |
-
<div
|
88 |
<div class="concept">
|
89 |
<img src="https://example.com/illustration-style.jpg" alt="Illustration Style">
|
90 |
<div class="concept-description">Illustration Style</div>
|
@@ -93,7 +133,14 @@ HTML_TEMPLATE = """
|
|
93 |
<img src="https://example.com/line-art.jpg" alt="Line Art">
|
94 |
<div class="concept-description">Line Art</div>
|
95 |
</div>
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
</div>
|
98 |
</div>
|
99 |
"""
|
@@ -198,37 +245,39 @@ title = "Generative Art with Textual Inversion and Guidance"
|
|
198 |
description = "Create unique artworks using Stable Diffusion with various styles and guidance methods."
|
199 |
|
200 |
with gr.Blocks(css=HTML_TEMPLATE) as demo:
|
201 |
-
gr.HTML(HTML_TEMPLATE)
|
202 |
with gr.Row():
|
203 |
-
text = gr.Textbox(label="Prompt", placeholder="
|
204 |
style = gr.Dropdown(label="Style", choices=list(style_token_dict.keys()), value="Illustration Style")
|
205 |
with gr.Row():
|
206 |
-
inference_step = gr.Slider(1, 50,
|
207 |
guidance_scale = gr.Slider(1, 10, 7.5, step=0.1, label="Guidance scale")
|
208 |
seed = gr.Slider(0, 10000, 42, step=1, label="Seed")
|
209 |
with gr.Row():
|
210 |
guidance_method = gr.Dropdown(label="Guidance method", choices=['Grayscale', 'Bright', 'Contrast', 'Symmetry', 'Saturation'], value="Grayscale")
|
211 |
loss_scale = gr.Slider(100, 10000, 200, step=100, label="Loss scale")
|
212 |
with gr.Row():
|
213 |
-
|
|
|
|
|
214 |
with gr.Row():
|
215 |
-
output_image = gr.Image(
|
216 |
-
output_image_guided = gr.Image(
|
217 |
|
218 |
generate_button.click(
|
219 |
inference,
|
220 |
-
inputs=[text, style, inference_step, guidance_scale, seed, guidance_method, loss_scale],
|
221 |
outputs=[output_image, output_image_guided]
|
222 |
)
|
223 |
|
224 |
gr.Examples(
|
225 |
examples=[
|
226 |
-
["A
|
227 |
],
|
228 |
-
inputs=[text, style, inference_step, guidance_scale, seed, guidance_method, loss_scale],
|
229 |
outputs=[output_image, output_image_guided],
|
230 |
fn=inference,
|
231 |
cache_examples=True,
|
232 |
)
|
233 |
|
234 |
-
demo.launch()
|
|
|
11 |
HTML_TEMPLATE = """
|
12 |
<style>
|
13 |
body {
|
14 |
+
background: linear-gradient(135deg, #6e48aa, #9d50bb, #f4d03f);
|
15 |
+
font-family: 'Arial', sans-serif;
|
16 |
+
color: #333;
|
17 |
}
|
18 |
#app-header {
|
19 |
text-align: center;
|
20 |
+
background: rgba(255, 255, 255, 0.9);
|
21 |
+
padding: 30px;
|
22 |
+
border-radius: 20px;
|
23 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
|
24 |
position: relative;
|
25 |
+
overflow: hidden;
|
26 |
+
margin-bottom: 30px;
|
27 |
+
}
|
28 |
+
#app-header::before {
|
29 |
+
content: "";
|
30 |
+
position: absolute;
|
31 |
+
top: -50%;
|
32 |
+
left: -50%;
|
33 |
+
width: 200%;
|
34 |
+
height: 200%;
|
35 |
+
background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
|
36 |
+
animation: shimmer 10s infinite linear;
|
37 |
+
}
|
38 |
+
@keyframes shimmer {
|
39 |
+
0% { transform: rotate(0deg); }
|
40 |
+
100% { transform: rotate(360deg); }
|
41 |
}
|
42 |
#app-header h1 {
|
43 |
+
color: #6e48aa;
|
44 |
+
font-size: 2.5em;
|
45 |
+
margin-bottom: 15px;
|
46 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
47 |
+
}
|
48 |
+
#app-header p {
|
49 |
+
font-size: 1.2em;
|
50 |
+
color: #555;
|
51 |
+
}
|
52 |
+
.concept-container {
|
53 |
+
display: flex;
|
54 |
+
justify-content: center;
|
55 |
+
gap: 30px;
|
56 |
+
margin-top: 30px;
|
57 |
+
flex-wrap: wrap;
|
58 |
}
|
59 |
.concept {
|
60 |
position: relative;
|
61 |
+
transition: transform 0.3s, box-shadow 0.3s;
|
62 |
+
border-radius: 15px;
|
63 |
+
overflow: hidden;
|
64 |
+
background: white;
|
65 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
66 |
}
|
67 |
.concept:hover {
|
68 |
+
transform: translateY(-10px) rotate(3deg);
|
69 |
+
box-shadow: 0 15px 30px rgba(0,0,0,0.2);
|
70 |
}
|
71 |
.concept img {
|
72 |
+
width: 120px;
|
73 |
+
height: 120px;
|
74 |
+
object-fit: cover;
|
75 |
+
border-radius: 15px 15px 0 0;
|
76 |
}
|
77 |
.concept-description {
|
78 |
+
background-color: #6e48aa;
|
|
|
|
|
|
|
|
|
79 |
color: white;
|
80 |
+
padding: 10px;
|
81 |
+
font-size: 0.9em;
|
82 |
+
text-align: center;
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
.artifact {
|
85 |
position: absolute;
|
86 |
+
background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
|
87 |
border-radius: 50%;
|
88 |
+
opacity: 0.5;
|
89 |
}
|
90 |
.artifact.large {
|
91 |
+
width: 400px;
|
92 |
+
height: 400px;
|
93 |
+
top: -100px;
|
94 |
+
left: -200px;
|
95 |
+
animation: float 20s infinite ease-in-out;
|
96 |
}
|
97 |
.artifact.medium {
|
98 |
+
width: 300px;
|
99 |
+
height: 300px;
|
100 |
+
bottom: -150px;
|
101 |
+
right: -150px;
|
102 |
+
animation: float 15s infinite ease-in-out reverse;
|
103 |
}
|
104 |
.artifact.small {
|
105 |
+
width: 150px;
|
106 |
+
height: 150px;
|
107 |
top: 50%;
|
108 |
left: 50%;
|
109 |
transform: translate(-50%, -50%);
|
110 |
+
animation: pulse 5s infinite alternate;
|
111 |
+
}
|
112 |
+
@keyframes float {
|
113 |
+
0%, 100% { transform: translateY(0) rotate(0deg); }
|
114 |
+
50% { transform: translateY(-20px) rotate(10deg); }
|
115 |
+
}
|
116 |
+
@keyframes pulse {
|
117 |
+
0% { transform: scale(1); opacity: 0.5; }
|
118 |
+
100% { transform: scale(1.1); opacity: 0.8; }
|
119 |
}
|
120 |
</style>
|
121 |
<div id="app-header">
|
122 |
<div class="artifact large"></div>
|
123 |
<div class="artifact medium"></div>
|
124 |
<div class="artifact small"></div>
|
125 |
+
<h1>Dreamscape Creator</h1>
|
126 |
+
<p>Unleash your imagination with AI-powered generative art</p>
|
127 |
+
<div class="concept-container">
|
128 |
<div class="concept">
|
129 |
<img src="https://example.com/illustration-style.jpg" alt="Illustration Style">
|
130 |
<div class="concept-description">Illustration Style</div>
|
|
|
133 |
<img src="https://example.com/line-art.jpg" alt="Line Art">
|
134 |
<div class="concept-description">Line Art</div>
|
135 |
</div>
|
136 |
+
<div class="concept">
|
137 |
+
<img src="https://example.com/midjourney-style.jpg" alt="Midjourney Style">
|
138 |
+
<div class="concept-description">Midjourney Style</div>
|
139 |
+
</div>
|
140 |
+
<div class="concept">
|
141 |
+
<img src="https://example.com/hanfu-anime-style.jpg" alt="Hanfu Anime">
|
142 |
+
<div class="concept-description">Hanfu Anime</div>
|
143 |
+
</div>
|
144 |
</div>
|
145 |
</div>
|
146 |
"""
|
|
|
245 |
description = "Create unique artworks using Stable Diffusion with various styles and guidance methods."
|
246 |
|
247 |
with gr.Blocks(css=HTML_TEMPLATE) as demo:
|
248 |
+
gr.HTML(HTML_TEMPLATE)
|
249 |
with gr.Row():
|
250 |
+
text = gr.Textbox(label="Prompt", placeholder="Describe your dreamscape...")
|
251 |
style = gr.Dropdown(label="Style", choices=list(style_token_dict.keys()), value="Illustration Style")
|
252 |
with gr.Row():
|
253 |
+
inference_step = gr.Slider(1, 50, 20, step=1, label="Inference steps")
|
254 |
guidance_scale = gr.Slider(1, 10, 7.5, step=0.1, label="Guidance scale")
|
255 |
seed = gr.Slider(0, 10000, 42, step=1, label="Seed")
|
256 |
with gr.Row():
|
257 |
guidance_method = gr.Dropdown(label="Guidance method", choices=['Grayscale', 'Bright', 'Contrast', 'Symmetry', 'Saturation'], value="Grayscale")
|
258 |
loss_scale = gr.Slider(100, 10000, 200, step=100, label="Loss scale")
|
259 |
with gr.Row():
|
260 |
+
image_size = gr.Radio(["256x256", "512x512"], label="Image Size", value="256x256")
|
261 |
+
with gr.Row():
|
262 |
+
generate_button = gr.Button("Create Dreamscape", variant="primary")
|
263 |
with gr.Row():
|
264 |
+
output_image = gr.Image(label="Your Dreamscape")
|
265 |
+
output_image_guided = gr.Image(label="Guided Dreamscape")
|
266 |
|
267 |
generate_button.click(
|
268 |
inference,
|
269 |
+
inputs=[text, style, inference_step, guidance_scale, seed, guidance_method, loss_scale, image_size],
|
270 |
outputs=[output_image, output_image_guided]
|
271 |
)
|
272 |
|
273 |
gr.Examples(
|
274 |
examples=[
|
275 |
+
["A mystical floating island with cascading waterfalls and ethereal butterflies", 'Illustration Style', 20, 7.5, 42, 'Grayscale', 200, "256x256"]
|
276 |
],
|
277 |
+
inputs=[text, style, inference_step, guidance_scale, seed, guidance_method, loss_scale, image_size],
|
278 |
outputs=[output_image, output_image_guided],
|
279 |
fn=inference,
|
280 |
cache_examples=True,
|
281 |
)
|
282 |
|
283 |
+
demo.launch()
|