fantos commited on
Commit
54d0511
β€’
1 Parent(s): 0d91959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -18
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
- import pygame
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
  # ν”„λ‘¬ν”„νŠΈ μž…λ ₯ λ°•μŠ€λ₯Ό λ³„λ„λ‘œ 배치