Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,7 @@ from PIL import Image
|
|
5 |
from diffusers import DiffusionPipeline
|
6 |
import random
|
7 |
from transformers import pipeline
|
8 |
-
|
9 |
-
import os
|
10 |
-
import threading
|
11 |
|
12 |
torch.backends.cudnn.deterministic = True
|
13 |
torch.backends.cudnn.benchmark = False
|
@@ -25,22 +23,7 @@ pipe.load_lora_weights(lora_repo)
|
|
25 |
|
26 |
pipe.to("cuda")
|
27 |
|
28 |
-
# pygame μ΄κΈ°ν λ° μμ
μ€μ
|
29 |
-
pygame.mixer.init()
|
30 |
-
def play_music():
|
31 |
-
pygame.mixer.music.load("1.mp3")
|
32 |
-
pygame.mixer.music.play()
|
33 |
-
pygame.mixer.music.queue("2.mp3")
|
34 |
-
pygame.mixer.music.set_endevent(pygame.USEREVENT)
|
35 |
-
while True:
|
36 |
-
for event in pygame.event.get():
|
37 |
-
if event.type == pygame.USEREVENT:
|
38 |
-
pygame.mixer.music.queue("1.mp3")
|
39 |
-
pygame.mixer.music.queue("2.mp3")
|
40 |
|
41 |
-
# λ°°κ²½μμ
μ¬μ μμ (λ³λ μ€λ λμμ μ€ν)
|
42 |
-
music_thread = threading.Thread(target=play_music, daemon=True)
|
43 |
-
music_thread.start()
|
44 |
|
45 |
MAX_SEED = 2**32-1
|
46 |
|
@@ -189,9 +172,40 @@ setInterval(createSnowflake, 100);
|
|
189 |
"""
|
190 |
|
191 |
with gr.Blocks(css=css) as app:
|
|
|
192 |
gr.HTML(f"<script>{js_code}</script>")
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
with gr.Column(elem_classes="container"):
|
|
|
195 |
gr.Markdown("# π X-MAS LoRA", elem_classes="header")
|
196 |
|
197 |
# ν둬ννΈ μ
λ ₯ λ°μ€λ₯Ό λ³λλ‘ λ°°μΉ
|
|
|
5 |
from diffusers import DiffusionPipeline
|
6 |
import random
|
7 |
from transformers import pipeline
|
8 |
+
|
|
|
|
|
9 |
|
10 |
torch.backends.cudnn.deterministic = True
|
11 |
torch.backends.cudnn.benchmark = False
|
|
|
23 |
|
24 |
pipe.to("cuda")
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
|
|
|
|
|
|
27 |
|
28 |
MAX_SEED = 2**32-1
|
29 |
|
|
|
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 |
# ν둬ννΈ μ
λ ₯ λ°μ€λ₯Ό λ³λλ‘ λ°°μΉ
|