Update app.py
Browse files
app.py
CHANGED
@@ -77,94 +77,106 @@ def get_caption(image_in):
|
|
77 |
def get_magnet(prompt):
|
78 |
amended_prompt = f"{prompt}"
|
79 |
print(amended_prompt)
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
|
99 |
def get_audioldm(prompt):
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
113 |
|
114 |
def get_audiogen(prompt):
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
122 |
|
123 |
def get_tango(prompt):
|
124 |
try:
|
125 |
client = Client("declare-lab/tango")
|
126 |
-
|
127 |
-
raise gr.Error("Tango space API is not ready, please try again in few minutes ")
|
128 |
-
|
129 |
-
result = client.predict(
|
130 |
prompt, # str representing string value in 'Prompt' Textbox component
|
131 |
100, # int | float representing numeric value between 100 and 200 in 'Steps' Slider component
|
132 |
4, # int | float representing numeric value between 1 and 10 in 'Guidance Scale' Slider component
|
133 |
api_name="/predict"
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
|
138 |
def get_tango2(prompt):
|
139 |
try:
|
140 |
client = Client("declare-lab/tango2")
|
141 |
-
|
142 |
-
raise gr.Error("Tango2 space API is not ready, please try again in few minutes ")
|
143 |
-
|
144 |
-
result = client.predict(
|
145 |
prompt,
|
146 |
100,
|
147 |
4,
|
148 |
api_name="/predict"
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
152 |
|
153 |
def get_stable_audio_open(prompt):
|
154 |
try:
|
155 |
client = Client("fffiloni/Stable-Audio-Open-A10", hf_token=hf_token)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
except:
|
157 |
raise gr.Error("Stable Audio Open space API is not ready, please try again in few minutes ")
|
158 |
|
159 |
-
|
160 |
-
prompt=prompt,
|
161 |
-
seconds_total=30,
|
162 |
-
steps=100,
|
163 |
-
cfg_scale=7,
|
164 |
-
api_name="/predict"
|
165 |
-
)
|
166 |
-
print(result)
|
167 |
-
return result
|
168 |
|
169 |
def infer(image_in, chosen_model):
|
170 |
caption = get_caption(image_in)
|
@@ -217,7 +229,6 @@ with gr.Blocks(css=css) as demo:
|
|
217 |
fn=infer,
|
218 |
inputs=[image_in, chosen_model],
|
219 |
outputs=[audio_o],
|
220 |
-
concurrency_limit = 2
|
221 |
)
|
222 |
|
223 |
demo.queue(max_size=10).launch(debug=True, show_error=True)
|
|
|
77 |
def get_magnet(prompt):
|
78 |
amended_prompt = f"{prompt}"
|
79 |
print(amended_prompt)
|
80 |
+
try:
|
81 |
+
client = Client("https://fffiloni-magnet.hf.space/")
|
82 |
+
result = client.predict(
|
83 |
+
"facebook/audio-magnet-medium", # 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
|
84 |
+
"", # str in 'Model Path (custom models)' Textbox component
|
85 |
+
amended_prompt, # str in 'Input Text' Textbox component
|
86 |
+
3, # float in 'Temperature' Number component
|
87 |
+
0.9, # float in 'Top-p' Number component
|
88 |
+
10, # float in 'Max CFG coefficient' Number component
|
89 |
+
1, # float in 'Min CFG coefficient' Number component
|
90 |
+
20, # float in 'Decoding Steps (stage 1)' Number component
|
91 |
+
10, # float in 'Decoding Steps (stage 2)' Number component
|
92 |
+
10, # float in 'Decoding Steps (stage 3)' Number component
|
93 |
+
10, # float in 'Decoding Steps (stage 4)' Number component
|
94 |
+
"prod-stride1 (new!)", # Literal['max-nonoverlap', 'prod-stride1 (new!)'] in 'Span Scoring' Radio component
|
95 |
+
api_name="/predict_full"
|
96 |
+
)
|
97 |
+
print(result)
|
98 |
+
return result[1]
|
99 |
+
except:
|
100 |
+
raise gr.Error("MAGNet space API is not ready, please try again in few minutes ")
|
101 |
|
102 |
def get_audioldm(prompt):
|
103 |
+
try:
|
104 |
+
client = Client("https://haoheliu-audioldm2-text2audio-text2music.hf.space/")
|
105 |
+
result = client.predict(
|
106 |
+
prompt, # str in 'Input text' Textbox component
|
107 |
+
"Low quality. Music.", # str in 'Negative prompt' Textbox component
|
108 |
+
10, # int | float (numeric value between 5 and 15) in 'Duration (seconds)' Slider component
|
109 |
+
3.5, # int | float (numeric value between 0 and 7) in 'Guidance scale' Slider component
|
110 |
+
45, # int | float in 'Seed' Number component
|
111 |
+
3, # int | float (numeric value between 1 and 5) in 'Number waveforms to generate' Slider component
|
112 |
+
fn_index=1
|
113 |
+
)
|
114 |
+
print(result)
|
115 |
+
audio_result = extract_audio(result)
|
116 |
+
return audio_result
|
117 |
+
except:
|
118 |
+
raise gr.Error("AudioLDM space API is not ready, please try again in few minutes ")
|
119 |
|
120 |
def get_audiogen(prompt):
|
121 |
+
try:
|
122 |
+
client = Client("https://fffiloni-audiogen.hf.space/")
|
123 |
+
result = client.predict(
|
124 |
+
prompt,
|
125 |
+
10,
|
126 |
+
api_name="/infer"
|
127 |
+
)
|
128 |
+
return result
|
129 |
+
except:
|
130 |
+
raise gr.Error("AudioGen space API is not ready, please try again in few minutes ")
|
131 |
|
132 |
def get_tango(prompt):
|
133 |
try:
|
134 |
client = Client("declare-lab/tango")
|
135 |
+
result = client.predict(
|
|
|
|
|
|
|
136 |
prompt, # str representing string value in 'Prompt' Textbox component
|
137 |
100, # int | float representing numeric value between 100 and 200 in 'Steps' Slider component
|
138 |
4, # int | float representing numeric value between 1 and 10 in 'Guidance Scale' Slider component
|
139 |
api_name="/predict"
|
140 |
+
)
|
141 |
+
print(result)
|
142 |
+
return result[0]
|
143 |
+
except:
|
144 |
+
raise gr.Error("Tango space API is not ready, please try again in few minutes ")
|
145 |
+
|
146 |
+
|
147 |
|
148 |
def get_tango2(prompt):
|
149 |
try:
|
150 |
client = Client("declare-lab/tango2")
|
151 |
+
result = client.predict(
|
|
|
|
|
|
|
152 |
prompt,
|
153 |
100,
|
154 |
4,
|
155 |
api_name="/predict"
|
156 |
+
)
|
157 |
+
print(result)
|
158 |
+
return result
|
159 |
+
except:
|
160 |
+
raise gr.Error("Tango2 space API is not ready, please try again in few minutes ")
|
161 |
+
|
162 |
+
|
163 |
|
164 |
def get_stable_audio_open(prompt):
|
165 |
try:
|
166 |
client = Client("fffiloni/Stable-Audio-Open-A10", hf_token=hf_token)
|
167 |
+
result = client.predict(
|
168 |
+
prompt=prompt,
|
169 |
+
seconds_total=30,
|
170 |
+
steps=100,
|
171 |
+
cfg_scale=7,
|
172 |
+
api_name="/predict"
|
173 |
+
)
|
174 |
+
print(result)
|
175 |
+
return result
|
176 |
except:
|
177 |
raise gr.Error("Stable Audio Open space API is not ready, please try again in few minutes ")
|
178 |
|
179 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
def infer(image_in, chosen_model):
|
182 |
caption = get_caption(image_in)
|
|
|
229 |
fn=infer,
|
230 |
inputs=[image_in, chosen_model],
|
231 |
outputs=[audio_o],
|
|
|
232 |
)
|
233 |
|
234 |
demo.queue(max_size=10).launch(debug=True, show_error=True)
|