seawolf2357 commited on
Commit
64f134f
ยท
verified ยท
1 Parent(s): 50d8012

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -5,17 +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(prompt):
9
  # ๊ธฐ๋ณธ ํ”„๋กฌํ”„ํŠธ ์„ค์ •
10
  base_prompt = "The rnb beat of 85BPM drums. playing Violin."
11
- # ์‚ฌ๋ฌผ ์ธ์‹ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋ณธ ํ”„๋กฌํ”„ํŠธ์— ์ถ”๊ฐ€
12
- full_prompt = f"{base_prompt} for a {object_detected}"
13
  # ๋ถ€์ •์ ์ธ ํ”„๋กฌํ”„ํŠธ ์ถ”๊ฐ€
14
  negative_prompt = "Low quality."
 
 
 
 
15
 
16
  # ์Œ์•… ์ƒ์„ฑ API ํ˜ธ์ถœ
17
  client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
18
  result = client.predict(
 
 
19
  prompt,
20
  prompt, # ์Œ์„ฑ ์ƒ์„ฑ์— ์‚ฌ์šฉ๋  ํ”„๋กฌํ”„ํŠธ
21
  5, # ์Œ์•…์˜ ๊ธธ์ด (์ดˆ)
 
5
  # ์ด๋ฏธ์ง€ ์ธ์‹ ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ
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
  prompt,
24
  prompt, # ์Œ์„ฑ ์ƒ์„ฑ์— ์‚ฌ์šฉ๋  ํ”„๋กฌํ”„ํŠธ
25
  5, # ์Œ์•…์˜ ๊ธธ์ด (์ดˆ)