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(
|