fffiloni commited on
Commit
ade087a
β€’
1 Parent(s): 58498d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -32
app.py CHANGED
@@ -5,51 +5,62 @@ img_to_text = gr.Blocks.load(name="spaces/pharma/CLIP-Interrogator")
5
  text_to_music = gr.Interface.load("spaces/fffiloni/text-2-music")
6
 
7
  def get_prompts(uploaded_image):
8
- print("calling Clip interrogator ...")
9
 
10
- prompt = img_to_text(uploaded_image, fn_index=1)[0]
11
-
12
- print(f"""β€”β€”β€”
13
- Got prompt result:
14
- {prompt}
15
- β€”β€”β€”β€”β€”β€”β€”
16
  """)
17
 
 
 
18
  music_result = get_music(prompt)
19
 
20
  return music_result
21
 
22
  def get_music(prompt):
23
- print(f"""β€”β€”β€”
24
- Calling now mubertAI with the prompt:
25
- {prompt}
26
  β€”β€”β€”β€”β€”β€”β€”
27
  """)
 
28
  result = text_to_music(prompt, fn_index=0)
29
- print(result)
 
 
 
 
 
 
 
30
  return result
31
 
32
- with gr.Blocks() as demo:
33
- gr.HTML("""<div style="text-align: center; max-width: 700px; margin: 0 auto;">
34
- <div
35
- style="
36
- display: inline-flex;
37
- align-items: center;
38
- gap: 0.8rem;
39
- font-size: 1.75rem;
40
- "
41
- >
42
- <h1 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
43
- Image to Music
44
- </h1>
45
- </div>
46
- <p style="margin-bottom: 10px; font-size: 94%">
47
- Sends an image in to <a href="https://huggingface.co/spaces/pharma/CLIP-Interrogator" target="_blank">CLIP Interrogator</a>
48
- to generate a text prompt which is then run through
49
- Mubert text-to-music to generate music from the input image!
50
- </p>
51
- </div>""")
52
- with gr.Row():
 
 
 
 
 
 
53
  with gr.Column():
54
  input_img = gr.Image(type="filepath")
55
  generate = gr.Button("Generate Music from Image")
 
5
  text_to_music = gr.Interface.load("spaces/fffiloni/text-2-music")
6
 
7
  def get_prompts(uploaded_image):
 
8
 
9
+ print(f"""β€”β€”β€”β€”β€”
10
+ Calling CLIP Interrogator ...
 
 
 
 
11
  """)
12
 
13
+ prompt = img_to_text(uploaded_image, fn_index=1)[0]
14
+
15
  music_result = get_music(prompt)
16
 
17
  return music_result
18
 
19
  def get_music(prompt):
20
+
21
+ print(f"""β€”β€”β€”β€”β€”
22
+ Calling now MubertAI ...
23
  β€”β€”β€”β€”β€”β€”β€”
24
  """)
25
+
26
  result = text_to_music(prompt, fn_index=0)
27
+
28
+ print(f"""β€”β€”β€”β€”β€”
29
+ NEW RESULTS
30
+ prompt : {prompt}
31
+ music : {result}
32
+ β€”β€”β€”β€”β€”β€”β€”
33
+ """)
34
+
35
  return result
36
 
37
+ css = """
38
+ #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
39
+ a {text-decoration-line: underline; font-weight: 600;}
40
+ """
41
+
42
+ with gr.Blocks(css=css) as demo:
43
+ with gr.Column(elem_id="col-container"):
44
+ gr.HTML("""<div style="text-align: center; max-width: 700px; margin: 0 auto;">
45
+ <div
46
+ style="
47
+ display: inline-flex;
48
+ align-items: center;
49
+ gap: 0.8rem;
50
+ font-size: 1.75rem;
51
+ "
52
+ >
53
+ <h1 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
54
+ Image to Music
55
+ </h1>
56
+ </div>
57
+ <p style="margin-bottom: 10px; font-size: 94%">
58
+ Sends an image in to <a href="https://huggingface.co/spaces/pharma/CLIP-Interrogator" target="_blank">CLIP Interrogator</a>
59
+ to generate a text prompt which is then run through
60
+ <a href="https://huggingface.co/Mubert" target="_blank">Mubert</a> text-to-music to generate music from the input image!
61
+ </p>
62
+ </div>""")
63
+
64
  with gr.Column():
65
  input_img = gr.Image(type="filepath")
66
  generate = gr.Button("Generate Music from Image")