seawolf2357 commited on
Commit
ebcd803
ยท
verified ยท
1 Parent(s): bc25881

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -5,6 +5,21 @@ from gradio_client import Client # ๊ฐ€์ •: gradio_client ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์‚ฌ
5
  # ์ด๋ฏธ์ง€ ์ธ์‹ ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ
6
  image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def generate_voice(prompt):
9
  # Tango API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Œ์„ฑ ์ƒ์„ฑ
10
  client = Client("https://declare-lab-tango.hf.space/")
@@ -25,10 +40,12 @@ def classify_and_generate_voice(uploaded_image):
25
 
26
  # ์Œ์„ฑ ์ƒ์„ฑ
27
  voice_result = generate_voice(top_prediction)
 
 
28
 
29
- # ๋ฐ˜ํ™˜๋œ ์Œ์„ฑ ๊ฒฐ๊ณผ๋ฅผ Gradio ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ „๋‹ฌ
30
  # ์˜ˆ: voice_result['url'] ๋˜๋Š” voice_result['audio_data'] ๋“ฑ
31
- return top_prediction, voice_result
32
 
33
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
34
  iface = gr.Interface(
 
5
  # ์ด๋ฏธ์ง€ ์ธ์‹ ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ
6
  image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
7
 
8
+ def generate_music(prompt):
9
+ # ์Œ์•… ์ƒ์„ฑ API ํ˜ธ์ถœ
10
+ client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
11
+ result = client.predict(
12
+ prompt,
13
+ prompt, # ์Œ์„ฑ ์ƒ์„ฑ์— ์‚ฌ์šฉ๋  ํ”„๋กฌํ”„ํŠธ
14
+ 5, # ์Œ์•…์˜ ๊ธธ์ด (์ดˆ)
15
+ 0, # ๊ฐ€์ด๋˜์Šค ์Šค์ผ€์ผ
16
+ 5, # ์‹œ๋“œ ๊ฐ’
17
+ 1, # ์ƒ์„ฑํ•  waveform์˜ ์ˆ˜
18
+ fn_index=1 # ํ•จ์ˆ˜ ์ธ๋ฑ์Šค
19
+ )
20
+ # API ํ˜ธ์ถœ ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ
21
+ return result
22
+
23
  def generate_voice(prompt):
24
  # Tango API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Œ์„ฑ ์ƒ์„ฑ
25
  client = Client("https://declare-lab-tango.hf.space/")
 
40
 
41
  # ์Œ์„ฑ ์ƒ์„ฑ
42
  voice_result = generate_voice(top_prediction)
43
+ # ์Œ์•… ์ƒ์„ฑ
44
+ music_result = generate_music("Generate music for: " + top_prediction)
45
 
46
+ # ๋ฐ˜ํ™˜๋œ ์Œ์„ฑ ๋ฐ ์Œ์•… ๊ฒฐ๊ณผ๋ฅผ Gradio ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ „๋‹ฌ
47
  # ์˜ˆ: voice_result['url'] ๋˜๋Š” voice_result['audio_data'] ๋“ฑ
48
+ return top_prediction, voice_result, music_result
49
 
50
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
51
  iface = gr.Interface(