Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
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 |
-
|
24 |
-
|
25 |
-
|
26 |
βββββββ
|
27 |
""")
|
|
|
28 |
result = text_to_music(prompt, fn_index=0)
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
return result
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|