Update app.py
Browse files
app.py
CHANGED
|
@@ -179,8 +179,27 @@ def infer(video_in, chosen_model):
|
|
| 179 |
elif chosen_model == "Tango" :
|
| 180 |
audio_result = get_tango(caption)
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
final_res = blend_vsfx(video_in, audio_result)
|
| 183 |
return audio_result, final_res
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
css="""
|
| 185 |
#col-container{
|
| 186 |
margin: 0 auto;
|
|
@@ -205,8 +224,10 @@ with gr.Blocks(css=css) as demo:
|
|
| 205 |
video_in = gr.Video(sources=["upload"], label="Video input")
|
| 206 |
with gr.Row():
|
| 207 |
chosen_model = gr.Dropdown(label="Choose a model", choices=["MAGNet", "AudioLDM-2", "AudioGen", "Tango"], value="Tango")
|
| 208 |
-
submit_btn = gr.Button("Submit")
|
| 209 |
with gr.Column():
|
|
|
|
|
|
|
| 210 |
audio_o = gr.Audio(label="Audio output")
|
| 211 |
video_o = gr.Video(label="Video with soundFX")
|
| 212 |
|
|
@@ -217,15 +238,26 @@ with gr.Blocks(css=css) as demo:
|
|
| 217 |
["examples/chinese-new-year-dragon.mp4", "Tango"],
|
| 218 |
["examples/big-sur.mp4", "AudioLDM-2"]
|
| 219 |
],
|
| 220 |
-
|
| 221 |
-
inputs = [video_in, chosen_model],
|
| 222 |
-
outputs = [audio_o, video_o],
|
| 223 |
-
cache_examples = False
|
| 224 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
submit_btn.click(
|
| 227 |
fn=infer,
|
| 228 |
inputs=[video_in, chosen_model],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
outputs=[audio_o, video_o],
|
| 230 |
concurrency_limit = 2
|
| 231 |
)
|
|
|
|
| 179 |
elif chosen_model == "Tango" :
|
| 180 |
audio_result = get_tango(caption)
|
| 181 |
|
| 182 |
+
final_res = blend_vsfx(video_in, audio_result)
|
| 183 |
+
return gr.update(value=caption, interactive=True), gr.update(visible=True), audio_result, final_res
|
| 184 |
+
|
| 185 |
+
def retry(edited_prompt, video_in, chosen_model):
|
| 186 |
+
image_in = extract_firstframe(video_in)
|
| 187 |
+
caption = edited_prompt
|
| 188 |
+
if chosen_model == "MAGNet" :
|
| 189 |
+
audio_result = get_magnet(caption)
|
| 190 |
+
elif chosen_model == "AudioLDM-2" :
|
| 191 |
+
audio_result = get_audioldm(caption)
|
| 192 |
+
elif chosen_model == "AudioGen" :
|
| 193 |
+
audio_result = get_audiogen(caption)
|
| 194 |
+
elif chosen_model == "Tango" :
|
| 195 |
+
audio_result = get_tango(caption)
|
| 196 |
+
|
| 197 |
final_res = blend_vsfx(video_in, audio_result)
|
| 198 |
return audio_result, final_res
|
| 199 |
+
|
| 200 |
+
def refresh():
|
| 201 |
+
return gr.update(value="", interactive=False), gr.update(visible=False)
|
| 202 |
+
|
| 203 |
css="""
|
| 204 |
#col-container{
|
| 205 |
margin: 0 auto;
|
|
|
|
| 224 |
video_in = gr.Video(sources=["upload"], label="Video input")
|
| 225 |
with gr.Row():
|
| 226 |
chosen_model = gr.Dropdown(label="Choose a model", choices=["MAGNet", "AudioLDM-2", "AudioGen", "Tango"], value="Tango")
|
| 227 |
+
submit_btn = gr.Button("Submit", scale=0)
|
| 228 |
with gr.Column():
|
| 229 |
+
caption_o = gr.Textbox(label="Scene caption", interactive=False)
|
| 230 |
+
retry_btn = gr.Button("Retry with edited prompt", visible=False)
|
| 231 |
audio_o = gr.Audio(label="Audio output")
|
| 232 |
video_o = gr.Video(label="Video with soundFX")
|
| 233 |
|
|
|
|
| 238 |
["examples/chinese-new-year-dragon.mp4", "Tango"],
|
| 239 |
["examples/big-sur.mp4", "AudioLDM-2"]
|
| 240 |
],
|
| 241 |
+
inputs = [video_in, chosen_model]
|
|
|
|
|
|
|
|
|
|
| 242 |
)
|
| 243 |
+
|
| 244 |
+
video_in.change(
|
| 245 |
+
fn = refresh,
|
| 246 |
+
inputs = None,
|
| 247 |
+
outputs = [caption_o, retry_btn],
|
| 248 |
+
queue = False
|
| 249 |
+
)
|
| 250 |
|
| 251 |
submit_btn.click(
|
| 252 |
fn=infer,
|
| 253 |
inputs=[video_in, chosen_model],
|
| 254 |
+
outputs=[caption_o, retry_btn, audio_o, video_o],
|
| 255 |
+
concurrency_limit = 2
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
retry_btn.click(
|
| 259 |
+
fn=retry,
|
| 260 |
+
inputs=[caption_o, video_in, chosen_model],
|
| 261 |
outputs=[audio_o, video_o],
|
| 262 |
concurrency_limit = 2
|
| 263 |
)
|