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(