Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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(
|