Spaces:
Runtime error
Runtime error
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +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_music(
|
9 |
-
# ์์
์์ฑ API ํธ์ถ
|
10 |
client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
5,
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
)
|
19 |
-
|
20 |
-
#
|
21 |
-
full_prompt = f"{base_prompt} Inspired by: {image_classification_result}."
|
22 |
-
# API ํธ์ถ ๊ฒฐ๊ณผ ์ฒ๋ฆฌ
|
23 |
return result
|
24 |
|
25 |
def generate_voice(prompt):
|
@@ -43,7 +43,7 @@ def classify_and_generate_voice(uploaded_image):
|
|
43 |
# ์์ฑ ์์ฑ
|
44 |
voice_result = generate_voice(top_prediction)
|
45 |
# ์์
์์ฑ
|
46 |
-
music_result = generate_music("Generate music for: " + top_prediction)
|
47 |
|
48 |
# ๋ฐํ๋ ์์ฑ ๋ฐ ์์
๊ฒฐ๊ณผ๋ฅผ Gradio ์ธํฐํ์ด์ค๋ก ์ ๋ฌ
|
49 |
# ์: voice_result['url'] ๋๋ voice_result['audio_data'] ๋ฑ
|
|
|
5 |
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ ๋ก๋
|
6 |
image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
7 |
|
8 |
+
def generate_music(prompt):
|
9 |
+
# audioldm API ์ฌ์ฉํ์ฌ ์์
์์ฑ API ํธ์ถ
|
10 |
client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
|
11 |
+
seed = random.randint(0, MAX_SEED)
|
12 |
+
result = client.predict(
|
13 |
+
prompt, # str in 'Input text' Textbox component
|
14 |
+
"Low quality.", # str in 'Negative prompt' Textbox component
|
15 |
+
5, # int | float (numeric value between 5 and 15) in 'Duration (seconds)' Slider component
|
16 |
+
6.5, # int | float (numeric value between 0 and 7) in 'Guidance scale' Slider component
|
17 |
+
seed, # int | float in 'Seed' Number component
|
18 |
+
3, # int | float (numeric value between 1 and 5) in 'Number waveforms to generate' Slider component
|
19 |
+
fn_index=1
|
20 |
)
|
21 |
+
#print(result)
|
22 |
+
#audio_result = extract_audio(result)
|
|
|
|
|
23 |
return result
|
24 |
|
25 |
def generate_voice(prompt):
|
|
|
43 |
# ์์ฑ ์์ฑ
|
44 |
voice_result = generate_voice(top_prediction)
|
45 |
# ์์
์์ฑ
|
46 |
+
music_result = generate_music("Generate music for: " + top_prediction + prompt)
|
47 |
|
48 |
# ๋ฐํ๋ ์์ฑ ๋ฐ ์์
๊ฒฐ๊ณผ๋ฅผ Gradio ์ธํฐํ์ด์ค๋ก ์ ๋ฌ
|
49 |
# ์: voice_result['url'] ๋๋ voice_result['audio_data'] ๋ฑ
|