seawolf2357 commited on
Commit
bc5fe2a
ยท
verified ยท
1 Parent(s): 093e936

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -6,27 +6,19 @@ from gradio_client import Client # ๊ฐ€์ •: gradio_client ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์‚ฌ
6
  image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
7
 
8
  def generate_music(image_classification_result):
9
- # ๊ธฐ๋ณธ ํ”„๋กฌํ”„ํŠธ ์„ค์ •
10
- base_prompt = "The rnb beat of 85BPM drums. playing Violin."
11
- # ๋ถ€์ •์ ์ธ ํ”„๋กฌํ”„ํŠธ ์ถ”๊ฐ€
12
- negative_prompt = "Low quality."
13
-
14
- # ์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜ ๊ฒฐ๊ณผ๋ฅผ ํฌํ•จํ•œ ์ „์ฒด ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
15
- full_prompt = f"{base_prompt} Inspired by: {image_classification_result}."
16
-
17
-
18
  # ์Œ์•… ์ƒ์„ฑ API ํ˜ธ์ถœ
19
  client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
20
- result = client.predict(
21
- prompt=full_prompt,
22
- negative_prompt=negative_prompt,
23
- duration=5, # ์Œ์•…์˜ ๊ธธ์ด (์ดˆ), ํ‚ค์›Œ๋“œ ์ธ์ž๋กœ ๋ณ€๊ฒฝ
24
- guidance_scale=0, # ๊ฐ€์ด๋˜์Šค ์Šค์ผ€์ผ, ํ‚ค์›Œ๋“œ ์ธ์ž๋กœ ๋ณ€๊ฒฝ
25
- seed=5, # ์‹œ๋“œ ๊ฐ’, ํ‚ค์›Œ๋“œ ์ธ์ž๋กœ ๋ณ€๊ฒฝ
26
- num_waveforms=1, # ์ƒ์„ฑํ•  waveform์˜ ์ˆ˜, ํ‚ค์›Œ๋“œ ์ธ์ž๋กœ ๋ณ€๊ฒฝ
27
  fn_index=1 # ํ•จ์ˆ˜ ์ธ๋ฑ์Šค, ์ด๋ฏธ ํ‚ค์›Œ๋“œ ์ธ์ž๋กœ ๋˜์–ด ์žˆ์Œ
28
  )
29
 
 
 
30
  # API ํ˜ธ์ถœ ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ
31
  return result
32
 
 
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