seawolf2357 commited on
Commit
ba5f8a7
Β·
verified Β·
1 Parent(s): 0a6664d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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(image_classification_result):
9
- # μŒμ•… 생성 API 호좜
10
  client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
11
- "The rnb beat of 85BPM drums. playing Violin."
12
- "Low quality."
13
- 5, # μŒμ•…μ˜ 길이 (초), ν‚€μ›Œλ“œ 인자둜 λ³€κ²½
14
- 0, # κ°€μ΄λ˜μŠ€ μŠ€μΌ€μΌ, ν‚€μ›Œλ“œ 인자둜 λ³€κ²½
15
- 5, # μ‹œλ“œ κ°’, ν‚€μ›Œλ“œ 인자둜 λ³€κ²½
16
- 1, # 생성할 waveform의 수, ν‚€μ›Œλ“œ 인자둜 λ³€κ²½
17
- fn_index=1 # ν•¨μˆ˜ 인덱슀, 이미 ν‚€μ›Œλ“œ 인자둜 λ˜μ–΄ 있음
 
 
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'] λ“±