Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,28 @@ def get_caption_from_MD(image_in):
|
|
65 |
print(result)
|
66 |
return result
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
import re
|
70 |
import torch
|
71 |
from transformers import pipeline
|
@@ -102,8 +123,10 @@ def infer(image_in):
|
|
102 |
cleaned_text = re.sub(pattern, '', outputs[0]["generated_text"], flags=re.DOTALL)
|
103 |
|
104 |
print(f"SUGGESTED Musical prompt: {cleaned_text}")
|
|
|
|
|
105 |
|
106 |
-
return
|
107 |
|
108 |
title = "Image to Music V2",
|
109 |
description = "Get music from a picture"
|
@@ -133,14 +156,10 @@ with gr.Blocks(css=css) as demo:
|
|
133 |
submit_btn = gr.Button("Make LLM system from my pic !")
|
134 |
with gr.Column():
|
135 |
caption = gr.Textbox(
|
136 |
-
label = "
|
137 |
-
elem_id = "image-caption"
|
138 |
)
|
139 |
-
result = gr.
|
140 |
-
label = "
|
141 |
-
lines = 6,
|
142 |
-
max_lines = 30,
|
143 |
-
elem_id = "suggested-system-prompt"
|
144 |
)
|
145 |
with gr.Row():
|
146 |
gr.Examples(
|
|
|
65 |
print(result)
|
66 |
return result
|
67 |
|
68 |
+
def get_magnet(prompt):
|
69 |
+
amended_prompt = f"{prompt}"
|
70 |
+
print(amended_prompt)
|
71 |
+
client = Client("https://fffiloni-magnet.hf.space/")
|
72 |
+
result = client.predict(
|
73 |
+
"facebook/magnet-small-10secs", # Literal['facebook/magnet-small-10secs', 'facebook/magnet-medium-10secs', 'facebook/magnet-small-30secs', 'facebook/magnet-medium-30secs', 'facebook/audio-magnet-small', 'facebook/audio-magnet-medium'] in 'Model' Radio component
|
74 |
+
"", # str in 'Model Path (custom models)' Textbox component
|
75 |
+
amended_prompt, # str in 'Input Text' Textbox component
|
76 |
+
3, # float in 'Temperature' Number component
|
77 |
+
0.9, # float in 'Top-p' Number component
|
78 |
+
10, # float in 'Max CFG coefficient' Number component
|
79 |
+
1, # float in 'Min CFG coefficient' Number component
|
80 |
+
20, # float in 'Decoding Steps (stage 1)' Number component
|
81 |
+
10, # float in 'Decoding Steps (stage 2)' Number component
|
82 |
+
10, # float in 'Decoding Steps (stage 3)' Number component
|
83 |
+
10, # float in 'Decoding Steps (stage 4)' Number component
|
84 |
+
"prod-stride1 (new!)", # Literal['max-nonoverlap', 'prod-stride1 (new!)'] in 'Span Scoring' Radio component
|
85 |
+
api_name="/predict_full"
|
86 |
+
)
|
87 |
+
print(result)
|
88 |
+
return result[1]
|
89 |
+
|
90 |
import re
|
91 |
import torch
|
92 |
from transformers import pipeline
|
|
|
123 |
cleaned_text = re.sub(pattern, '', outputs[0]["generated_text"], flags=re.DOTALL)
|
124 |
|
125 |
print(f"SUGGESTED Musical prompt: {cleaned_text}")
|
126 |
+
|
127 |
+
music_o = get_magnet(cleaned_text)
|
128 |
|
129 |
+
return cleaned_text, music_o
|
130 |
|
131 |
title = "Image to Music V2",
|
132 |
description = "Get music from a picture"
|
|
|
156 |
submit_btn = gr.Button("Make LLM system from my pic !")
|
157 |
with gr.Column():
|
158 |
caption = gr.Textbox(
|
159 |
+
label = "Musical prompt"
|
|
|
160 |
)
|
161 |
+
result = gr.Audio(
|
162 |
+
label = "Music"
|
|
|
|
|
|
|
163 |
)
|
164 |
with gr.Row():
|
165 |
gr.Examples(
|