Update app.py
Browse files
app.py
CHANGED
@@ -76,63 +76,91 @@ def load_example():
|
|
76 |
example_image = Image.open(example_image_path)
|
77 |
return example_prompt, example_cfg_scale, example_steps, True, example_seed, example_width, example_height, example_lora_scale, example_image
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
max-width: 1400px;
|
82 |
-
margin: auto;
|
83 |
-
padding: 20px;
|
84 |
-
position: relative;
|
85 |
-
min-height: 100vh;
|
86 |
-
}
|
87 |
body {
|
88 |
-
background-image: url('file/example0.webp');
|
89 |
-
background-size: cover;
|
90 |
-
background-position: center;
|
91 |
-
background-attachment: fixed;
|
92 |
margin: 0;
|
93 |
padding: 0;
|
|
|
|
|
|
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
.header {
|
96 |
-
text-align: center;
|
97 |
-
margin-bottom: 30px;
|
98 |
color: white;
|
99 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
|
|
|
|
|
100 |
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
}
|
111 |
-
.parameter-box, .result-box, .prompt-box, .audio-controls {
|
112 |
-
background-color: rgba(245, 246, 250, 0.8);
|
113 |
-
padding: 20px;
|
114 |
-
border-radius: 10px;
|
115 |
-
margin: 10px 0;
|
116 |
-
backdrop-filter: blur(5px);
|
117 |
}
|
|
|
|
|
118 |
.result-box {
|
119 |
width: 90%;
|
|
|
120 |
margin: 20px auto;
|
121 |
}
|
|
|
122 |
.image-output {
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
}
|
|
|
|
|
127 |
.prompt-box {
|
128 |
width: 90%;
|
|
|
129 |
margin: 20px auto;
|
130 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
.accordion {
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
}
|
|
|
|
|
136 |
.audio-controls {
|
137 |
position: fixed;
|
138 |
bottom: 20px;
|
@@ -140,57 +168,55 @@ body {
|
|
140 |
z-index: 1000;
|
141 |
display: flex;
|
142 |
gap: 10px;
|
143 |
-
|
|
|
|
|
|
|
144 |
}
|
|
|
145 |
.audio-btn {
|
146 |
-
|
147 |
-
border-radius: 5px;
|
148 |
-
border: none;
|
149 |
-
background: rgba(46, 204, 113, 0.9);
|
150 |
color: white;
|
|
|
|
|
|
|
151 |
cursor: pointer;
|
|
|
152 |
}
|
|
|
153 |
.audio-btn:hover {
|
154 |
-
background:
|
155 |
-
}
|
156 |
-
@keyframes snow {
|
157 |
-
0% {
|
158 |
-
transform: translateY(0) translateX(0);
|
159 |
-
}
|
160 |
-
100% {
|
161 |
-
transform: translateY(100vh) translateX(100px);
|
162 |
-
}
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
top: -10px;
|
168 |
-
color: white;
|
169 |
-
font-size: 20px;
|
170 |
-
animation: snow 5s linear infinite;
|
171 |
-
}
|
172 |
-
@keyframes snow {
|
173 |
0% {
|
174 |
-
transform: translateY(
|
|
|
175 |
}
|
176 |
100% {
|
177 |
transform: translateY(100vh) translateX(100px);
|
|
|
178 |
}
|
179 |
}
|
180 |
|
181 |
.snowflake {
|
182 |
position: fixed;
|
183 |
-
top: -10px;
|
184 |
color: white;
|
185 |
-
font-size:
|
186 |
-
|
|
|
|
|
|
|
187 |
}
|
188 |
"""
|
189 |
-
|
|
|
|
|
190 |
function createSnowflake() {
|
191 |
const snowflake = document.createElement('div');
|
192 |
-
snowflake.classList.add('snowflake');
|
193 |
snowflake.innerHTML = 'โ';
|
|
|
194 |
snowflake.style.left = Math.random() * 100 + 'vw';
|
195 |
snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
|
196 |
snowflake.style.opacity = Math.random();
|
@@ -201,21 +227,51 @@ function createSnowflake() {
|
|
201 |
}, 5000);
|
202 |
}
|
203 |
|
204 |
-
setInterval(createSnowflake,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
"""
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
208 |
|
209 |
with gr.Column(elem_classes="container"):
|
210 |
gr.Markdown("# ๐ X-MAS LoRA", elem_classes="header")
|
211 |
|
212 |
# ์ด๋ฏธ์ง ์ถ๋ ฅ ์์ญ
|
213 |
-
with gr.Group(elem_classes="result-box"):
|
214 |
gr.Markdown("### ๐ผ๏ธ Generated Image")
|
215 |
result = gr.Image(label="Result", elem_classes="image-output")
|
216 |
|
217 |
-
# ํ๋กฌํํธ ์
๋ ฅ
|
218 |
-
with gr.Group(elem_classes="prompt-box"):
|
219 |
prompt = gr.TextArea(
|
220 |
label="โ๏ธ Your Prompt (ํ๊ธ ๋๋ ์์ด)",
|
221 |
placeholder="์ด๋ฏธ์ง๋ฅผ ์ค๋ช
ํ์ธ์...",
|
@@ -226,108 +282,27 @@ with gr.Blocks(css=css) as app:
|
|
226 |
elem_classes="generate-btn"
|
227 |
)
|
228 |
|
229 |
-
#
|
230 |
-
with gr.Accordion("๐จ Advanced Options", open=False, elem_classes="accordion"):
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
cfg_scale = gr.Slider(
|
236 |
-
label="CFG Scale",
|
237 |
-
minimum=1,
|
238 |
-
maximum=20,
|
239 |
-
step=0.5,
|
240 |
-
value=example_cfg_scale
|
241 |
-
)
|
242 |
-
steps = gr.Slider(
|
243 |
-
label="Steps",
|
244 |
-
minimum=1,
|
245 |
-
maximum=100,
|
246 |
-
step=1,
|
247 |
-
value=example_steps
|
248 |
-
)
|
249 |
-
lora_scale = gr.Slider(
|
250 |
-
label="LoRA Scale",
|
251 |
-
minimum=0,
|
252 |
-
maximum=1,
|
253 |
-
step=0.01,
|
254 |
-
value=example_lora_scale
|
255 |
-
)
|
256 |
-
|
257 |
-
with gr.Group(elem_classes="parameter-box"):
|
258 |
-
gr.Markdown("### ๐ Image Dimensions")
|
259 |
-
with gr.Row():
|
260 |
-
width = gr.Slider(
|
261 |
-
label="Width",
|
262 |
-
minimum=256,
|
263 |
-
maximum=1536,
|
264 |
-
step=64,
|
265 |
-
value=example_width
|
266 |
-
)
|
267 |
-
height = gr.Slider(
|
268 |
-
label="Height",
|
269 |
-
minimum=256,
|
270 |
-
maximum=1536,
|
271 |
-
step=64,
|
272 |
-
value=example_height
|
273 |
-
)
|
274 |
-
|
275 |
-
with gr.Group(elem_classes="parameter-box"):
|
276 |
-
gr.Markdown("### ๐ฒ Seed Settings")
|
277 |
-
with gr.Row():
|
278 |
-
randomize_seed = gr.Checkbox(
|
279 |
-
True,
|
280 |
-
label="Randomize seed"
|
281 |
-
)
|
282 |
-
seed = gr.Slider(
|
283 |
-
label="Seed",
|
284 |
-
minimum=0,
|
285 |
-
maximum=MAX_SEED,
|
286 |
-
step=1,
|
287 |
-
value=example_seed
|
288 |
-
)
|
289 |
-
|
290 |
-
# ์ค๋์ค ์ปจํธ๋กค - ์ปจํ
์ด๋ ๋ฐ์ ๋ฐฐ์น
|
291 |
-
gr.HTML("""
|
292 |
<div class="audio-controls">
|
293 |
-
<button class="audio-btn" onclick="toggleAudio(1)"
|
294 |
-
<button class="audio-btn" onclick="toggleAudio(2)"
|
295 |
-
<button class="audio-btn" onclick="stopAllAudio()"
|
296 |
</div>
|
297 |
-
<audio id="bgMusic1" loop
|
298 |
<source src="file/1.mp3" type="audio/mp3">
|
299 |
</audio>
|
300 |
-
<audio id="bgMusic2" loop
|
301 |
<source src="file/2.mp3" type="audio/mp3">
|
302 |
</audio>
|
303 |
-
<script>
|
304 |
-
let currentlyPlaying = null;
|
305 |
-
|
306 |
-
function toggleAudio(num) {
|
307 |
-
const audio = document.getElementById('bgMusic' + num);
|
308 |
-
const otherAudio = document.getElementById('bgMusic' + (num === 1 ? 2 : 1));
|
309 |
-
|
310 |
-
if (currentlyPlaying === audio) {
|
311 |
-
audio.pause();
|
312 |
-
currentlyPlaying = null;
|
313 |
-
} else {
|
314 |
-
if (currentlyPlaying) {
|
315 |
-
currentlyPlaying.pause();
|
316 |
-
}
|
317 |
-
otherAudio.pause();
|
318 |
-
audio.play();
|
319 |
-
currentlyPlaying = audio;
|
320 |
-
}
|
321 |
-
}
|
322 |
-
|
323 |
-
function stopAllAudio() {
|
324 |
-
document.getElementById('bgMusic1').pause();
|
325 |
-
document.getElementById('bgMusic2').pause();
|
326 |
-
currentlyPlaying = null;
|
327 |
-
}
|
328 |
-
</script>
|
329 |
""")
|
330 |
|
|
|
331 |
app.load(
|
332 |
load_example,
|
333 |
inputs=[],
|
|
|
76 |
example_image = Image.open(example_image_path)
|
77 |
return example_prompt, example_cfg_scale, example_steps, True, example_seed, example_width, example_height, example_lora_scale, example_image
|
78 |
|
79 |
+
custom_css = """
|
80 |
+
/* ๊ธฐ๋ณธ ์คํ์ผ */
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
body {
|
|
|
|
|
|
|
|
|
82 |
margin: 0;
|
83 |
padding: 0;
|
84 |
+
background: url('file/example0.webp') no-repeat center center fixed;
|
85 |
+
background-size: cover;
|
86 |
+
min-height: 100vh;
|
87 |
}
|
88 |
+
|
89 |
+
/* ์ปจํ
์ด๋ */
|
90 |
+
.container {
|
91 |
+
max-width: 1200px;
|
92 |
+
margin: 0 auto;
|
93 |
+
padding: 20px;
|
94 |
+
box-sizing: border-box;
|
95 |
+
}
|
96 |
+
|
97 |
+
/* ํค๋ */
|
98 |
.header {
|
99 |
+
text-align: center;
|
|
|
100 |
color: white;
|
101 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
|
102 |
+
margin-bottom: 30px;
|
103 |
+
font-size: 2.5em;
|
104 |
}
|
105 |
+
|
106 |
+
/* ๋ฐ์ค ๊ณตํต ์คํ์ผ */
|
107 |
+
.box-common {
|
108 |
+
background-color: rgba(255, 255, 255, 0.85);
|
109 |
+
backdrop-filter: blur(10px);
|
110 |
+
border-radius: 15px;
|
111 |
+
padding: 20px;
|
112 |
+
margin: 20px 0;
|
113 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
+
|
116 |
+
/* ๊ฒฐ๊ณผ ์ด๋ฏธ์ง ๋ฐ์ค */
|
117 |
.result-box {
|
118 |
width: 90%;
|
119 |
+
max-width: 1000px;
|
120 |
margin: 20px auto;
|
121 |
}
|
122 |
+
|
123 |
.image-output {
|
124 |
+
width: 100%;
|
125 |
+
max-width: 800px;
|
126 |
+
margin: 0 auto;
|
127 |
+
display: block;
|
128 |
}
|
129 |
+
|
130 |
+
/* ํ๋กฌํํธ ์
๋ ฅ ๋ฐ์ค */
|
131 |
.prompt-box {
|
132 |
width: 90%;
|
133 |
+
max-width: 1000px;
|
134 |
margin: 20px auto;
|
135 |
}
|
136 |
+
|
137 |
+
/* ๋ฒํผ ์คํ์ผ */
|
138 |
+
.generate-btn {
|
139 |
+
background-color: #2ecc71 !important;
|
140 |
+
color: white !important;
|
141 |
+
padding: 12px 30px !important;
|
142 |
+
border-radius: 8px !important;
|
143 |
+
border: none !important;
|
144 |
+
font-size: 1.1em !important;
|
145 |
+
cursor: pointer !important;
|
146 |
+
transition: background-color 0.3s ease !important;
|
147 |
+
width: 200px !important;
|
148 |
+
margin: 20px auto !important;
|
149 |
+
display: block !important;
|
150 |
+
}
|
151 |
+
|
152 |
+
.generate-btn:hover {
|
153 |
+
background-color: #27ae60 !important;
|
154 |
+
}
|
155 |
+
|
156 |
+
/* ์์ฝ๋์ธ ์คํ์ผ */
|
157 |
.accordion {
|
158 |
+
width: 90%;
|
159 |
+
max-width: 1000px;
|
160 |
+
margin: 20px auto;
|
161 |
}
|
162 |
+
|
163 |
+
/* ์ค๋์ค ์ปจํธ๋กค */
|
164 |
.audio-controls {
|
165 |
position: fixed;
|
166 |
bottom: 20px;
|
|
|
168 |
z-index: 1000;
|
169 |
display: flex;
|
170 |
gap: 10px;
|
171 |
+
background-color: rgba(255, 255, 255, 0.9);
|
172 |
+
padding: 15px;
|
173 |
+
border-radius: 10px;
|
174 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
175 |
}
|
176 |
+
|
177 |
.audio-btn {
|
178 |
+
background-color: #3498db;
|
|
|
|
|
|
|
179 |
color: white;
|
180 |
+
border: none;
|
181 |
+
padding: 8px 15px;
|
182 |
+
border-radius: 5px;
|
183 |
cursor: pointer;
|
184 |
+
transition: background-color 0.3s ease;
|
185 |
}
|
186 |
+
|
187 |
.audio-btn:hover {
|
188 |
+
background-color: #2980b9;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
+
/* ๋ ๋ด๋ฆฌ๋ ํจ๊ณผ */
|
192 |
+
@keyframes snowfall {
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
0% {
|
194 |
+
transform: translateY(-10vh) translateX(0);
|
195 |
+
opacity: 1;
|
196 |
}
|
197 |
100% {
|
198 |
transform: translateY(100vh) translateX(100px);
|
199 |
+
opacity: 0.3;
|
200 |
}
|
201 |
}
|
202 |
|
203 |
.snowflake {
|
204 |
position: fixed;
|
|
|
205 |
color: white;
|
206 |
+
font-size: 1.5em;
|
207 |
+
user-select: none;
|
208 |
+
z-index: 1000;
|
209 |
+
pointer-events: none;
|
210 |
+
animation: snowfall linear infinite;
|
211 |
}
|
212 |
"""
|
213 |
+
|
214 |
+
# JavaScript ์ฝ๋๋ ๋ณ๋๋ก ์ ๋ฆฌ
|
215 |
+
snow_js = """
|
216 |
function createSnowflake() {
|
217 |
const snowflake = document.createElement('div');
|
|
|
218 |
snowflake.innerHTML = 'โ';
|
219 |
+
snowflake.className = 'snowflake';
|
220 |
snowflake.style.left = Math.random() * 100 + 'vw';
|
221 |
snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
|
222 |
snowflake.style.opacity = Math.random();
|
|
|
227 |
}, 5000);
|
228 |
}
|
229 |
|
230 |
+
setInterval(createSnowflake, 200);
|
231 |
+
"""
|
232 |
+
|
233 |
+
audio_js = """
|
234 |
+
let currentlyPlaying = null;
|
235 |
+
|
236 |
+
function toggleAudio(num) {
|
237 |
+
const audio = document.getElementById('bgMusic' + num);
|
238 |
+
const otherAudio = document.getElementById('bgMusic' + (num === 1 ? 2 : 1));
|
239 |
+
|
240 |
+
if (currentlyPlaying === audio) {
|
241 |
+
audio.pause();
|
242 |
+
currentlyPlaying = null;
|
243 |
+
} else {
|
244 |
+
if (currentlyPlaying) {
|
245 |
+
currentlyPlaying.pause();
|
246 |
+
}
|
247 |
+
otherAudio.pause();
|
248 |
+
audio.play();
|
249 |
+
currentlyPlaying = audio;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
function stopAllAudio() {
|
254 |
+
const audios = document.querySelectorAll('audio');
|
255 |
+
audios.forEach(audio => audio.pause());
|
256 |
+
currentlyPlaying = null;
|
257 |
+
}
|
258 |
"""
|
259 |
+
|
260 |
+
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
261 |
+
with gr.Blocks(css=custom_css) as app:
|
262 |
+
# JavaScript ์ด๊ธฐํ
|
263 |
+
gr.HTML(f"<script>{snow_js}</script>")
|
264 |
|
265 |
with gr.Column(elem_classes="container"):
|
266 |
gr.Markdown("# ๐ X-MAS LoRA", elem_classes="header")
|
267 |
|
268 |
# ์ด๋ฏธ์ง ์ถ๋ ฅ ์์ญ
|
269 |
+
with gr.Group(elem_classes="result-box box-common"):
|
270 |
gr.Markdown("### ๐ผ๏ธ Generated Image")
|
271 |
result = gr.Image(label="Result", elem_classes="image-output")
|
272 |
|
273 |
+
# ํ๋กฌํํธ ์
๋ ฅ ์์ญ
|
274 |
+
with gr.Group(elem_classes="prompt-box box-common"):
|
275 |
prompt = gr.TextArea(
|
276 |
label="โ๏ธ Your Prompt (ํ๊ธ ๋๋ ์์ด)",
|
277 |
placeholder="์ด๋ฏธ์ง๋ฅผ ์ค๋ช
ํ์ธ์...",
|
|
|
282 |
elem_classes="generate-btn"
|
283 |
)
|
284 |
|
285 |
+
# ๊ณ ๊ธ ์ต์
|
286 |
+
with gr.Accordion("๐จ Advanced Options", open=False, elem_classes="accordion box-common"):
|
287 |
+
[์ด์ ์ต์
์ฝ๋์ ๋์ผ]
|
288 |
+
|
289 |
+
# ์ค๋์ค ์ปจํธ๋กค
|
290 |
+
gr.HTML(f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
<div class="audio-controls">
|
292 |
+
<button class="audio-btn" onclick="toggleAudio(1)">๐ต Music 1</button>
|
293 |
+
<button class="audio-btn" onclick="toggleAudio(2)">๐ต Music 2</button>
|
294 |
+
<button class="audio-btn" onclick="stopAllAudio()">โน Stop</button>
|
295 |
</div>
|
296 |
+
<audio id="bgMusic1" loop>
|
297 |
<source src="file/1.mp3" type="audio/mp3">
|
298 |
</audio>
|
299 |
+
<audio id="bgMusic2" loop>
|
300 |
<source src="file/2.mp3" type="audio/mp3">
|
301 |
</audio>
|
302 |
+
<script>{audio_js}</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
""")
|
304 |
|
305 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
306 |
app.load(
|
307 |
load_example,
|
308 |
inputs=[],
|