fantos commited on
Commit
26c3a03
โ€ข
1 Parent(s): 4bd30d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -77
app.py CHANGED
@@ -82,10 +82,15 @@ css = """
82
  margin: auto;
83
  padding: 20px;
84
  position: relative;
 
 
 
85
  background-image: url('file/example0.webp');
86
  background-size: cover;
87
  background-position: center;
88
- min-height: 100vh;
 
 
89
  }
90
  .header {
91
  text-align: center;
@@ -103,112 +108,69 @@ css = """
103
  .generate-btn:hover {
104
  background-color: #27ae60 !important;
105
  }
106
- .parameter-box {
107
- background-color: rgba(245, 246, 250, 0.9);
108
  padding: 20px;
109
  border-radius: 10px;
110
  margin: 10px 0;
 
111
  }
112
  .result-box {
113
- background-color: rgba(245, 246, 250, 0.9);
114
- padding: 20px;
115
- border-radius: 10px;
116
- margin: 0 auto 20px auto;
117
- text-align: center;
118
  }
119
  .image-output {
120
  margin: 0 auto;
121
  display: block;
122
  max-width: 800px !important;
123
  }
 
 
 
 
124
  .accordion {
125
  margin-top: 20px;
 
 
126
  }
127
- .prompt-box {
128
  position: fixed;
129
- top: 20px;
130
  right: 20px;
131
- width: 300px;
132
- background-color: rgba(245, 246, 250, 0.9);
133
- padding: 20px;
134
- border-radius: 10px;
135
  z-index: 1000;
 
 
 
136
  }
137
-
138
- @keyframes snow {
139
- 0% {
140
- transform: translateY(0) translateX(0);
141
- }
142
- 100% {
143
- transform: translateY(100vh) translateX(100px);
144
- }
145
- }
146
-
147
- .snowflake {
148
- position: fixed;
149
- top: -10px;
150
  color: white;
151
- font-size: 20px;
152
- animation: snow 5s linear infinite;
153
  }
154
- """
155
-
156
- js_code = """
157
- function createSnowflake() {
158
- const snowflake = document.createElement('div');
159
- snowflake.classList.add('snowflake');
160
- snowflake.innerHTML = 'โ„';
161
- snowflake.style.left = Math.random() * 100 + 'vw';
162
- snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
163
- snowflake.style.opacity = Math.random();
164
- document.body.appendChild(snowflake);
165
-
166
- setTimeout(() => {
167
- snowflake.remove();
168
- }, 5000);
169
  }
170
-
171
- setInterval(createSnowflake, 100);
172
  """
173
 
 
174
  with gr.Blocks(css=css) as app:
175
- # JavaScript ๋ˆˆ ํšจ๊ณผ
176
  gr.HTML(f"<script>{js_code}</script>")
177
 
178
- # HTML5 ์˜ค๋””์˜ค ์š”์†Œ ์ถ”๊ฐ€
179
- gr.HTML("""
180
- <audio id="bgMusic1" loop style="display: none;">
181
- <source src="file/1.mp3" type="audio/mp3">
182
- </audio>
183
- <audio id="bgMusic2" loop style="display: none;">
184
- <source src="file/2.mp3" type="audio/mp3">
185
- </audio>
186
- <script>
187
- window.addEventListener('load', function() {
188
- const audio1 = document.getElementById('bgMusic1');
189
- const audio2 = document.getElementById('bgMusic2');
190
-
191
- audio1.addEventListener('ended', function() {
192
- audio2.play();
193
- });
194
-
195
- audio2.addEventListener('ended', function() {
196
- audio1.play();
197
- });
198
-
199
- // ์ž๋™ ์žฌ์ƒ ์‹œ์ž‘
200
- audio1.play().catch(function(error) {
201
- console.log("Audio playback failed:", error);
202
- });
203
- });
204
- </script>
205
- """)
206
 
207
  with gr.Column(elem_classes="container"):
208
-
209
  gr.Markdown("# ๐ŸŽ„ X-MAS LoRA", elem_classes="header")
210
 
211
- # ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ ๋ฐ•์Šค๋ฅผ ๋ณ„๋„๋กœ ๋ฐฐ์น˜
 
 
 
 
 
212
  with gr.Group(elem_classes="prompt-box"):
213
  prompt = gr.TextArea(
214
  label="โœ๏ธ Your Prompt (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
@@ -220,6 +182,48 @@ with gr.Blocks(css=css) as app:
220
  elem_classes="generate-btn"
221
  )
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  # ์ด๋ฏธ์ง€ ์ถœ๋ ฅ ์˜์—ญ
224
  with gr.Group(elem_classes="result-box"):
225
  gr.Markdown("### ๐Ÿ–ผ๏ธ Generated Image")
 
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;
 
108
  .generate-btn:hover {
109
  background-color: #27ae60 !important;
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
  margin: 0 auto;
124
  display: block;
125
  max-width: 800px !important;
126
  }
127
+ .prompt-box {
128
+ width: 90%;
129
+ margin: 20px auto;
130
+ }
131
  .accordion {
132
  margin-top: 20px;
133
+ background-color: rgba(245, 246, 250, 0.8);
134
+ backdrop-filter: blur(5px);
135
  }
136
+ .audio-controls {
137
  position: fixed;
138
+ bottom: 20px;
139
  right: 20px;
 
 
 
 
140
  z-index: 1000;
141
+ display: flex;
142
+ gap: 10px;
143
+ align-items: center;
144
  }
145
+ .audio-btn {
146
+ padding: 10px 20px;
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: rgba(39, 174, 96, 0.9);
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
+ [๊ฐ™์€ snow ๊ด€๋ จ CSS...]
 
157
  """
158
 
159
+
160
  with gr.Blocks(css=css) as app:
 
161
  gr.HTML(f"<script>{js_code}</script>")
162
 
163
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  with gr.Column(elem_classes="container"):
 
166
  gr.Markdown("# ๐ŸŽ„ X-MAS LoRA", elem_classes="header")
167
 
168
+ # ์ด๋ฏธ์ง€ ์ถœ๋ ฅ ์˜์—ญ
169
+ with gr.Group(elem_classes="result-box"):
170
+ gr.Markdown("### ๐Ÿ–ผ๏ธ Generated Image")
171
+ result = gr.Image(label="Result", elem_classes="image-output")
172
+
173
+ # ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ ๋ฐ•์Šค
174
  with gr.Group(elem_classes="prompt-box"):
175
  prompt = gr.TextArea(
176
  label="โœ๏ธ Your Prompt (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
 
182
  elem_classes="generate-btn"
183
  )
184
 
185
+
186
+ # HTML5 ์˜ค๋””์˜ค ์š”์†Œ ์ถ”๊ฐ€
187
+ gr.HTML("""
188
+ <div class="audio-controls">
189
+ <button class="audio-btn" onclick="toggleAudio(1)">Play Music 1</button>
190
+ <button class="audio-btn" onclick="toggleAudio(2)">Play Music 2</button>
191
+ <button class="audio-btn" onclick="stopAllAudio()">Stop All</button>
192
+ </div>
193
+ <audio id="bgMusic1" loop style="display: none;">
194
+ <source src="file/1.mp3" type="audio/mp3">
195
+ </audio>
196
+ <audio id="bgMusic2" loop style="display: none;">
197
+ <source src="file/2.mp3" type="audio/mp3">
198
+ </audio>
199
+ <script>
200
+ let currentlyPlaying = null;
201
+
202
+ function toggleAudio(num) {
203
+ const audio = document.getElementById('bgMusic' + num);
204
+ const otherAudio = document.getElementById('bgMusic' + (num === 1 ? 2 : 1));
205
+
206
+ if (currentlyPlaying === audio) {
207
+ audio.pause();
208
+ currentlyPlaying = null;
209
+ } else {
210
+ if (currentlyPlaying) {
211
+ currentlyPlaying.pause();
212
+ }
213
+ otherAudio.pause();
214
+ audio.play();
215
+ currentlyPlaying = audio;
216
+ }
217
+ }
218
+
219
+ function stopAllAudio() {
220
+ document.getElementById('bgMusic1').pause();
221
+ document.getElementById('bgMusic2').pause();
222
+ currentlyPlaying = null;
223
+ }
224
+ </script>
225
+ """)
226
+
227
  # ์ด๋ฏธ์ง€ ์ถœ๋ ฅ ์˜์—ญ
228
  with gr.Group(elem_classes="result-box"):
229
  gr.Markdown("### ๐Ÿ–ผ๏ธ Generated Image")