Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,11 @@ token = os.environ.get('HF_TOKEN')
|
|
8 |
caption = gr.Blocks.load(name="spaces/SRDdev/Image-Caption")
|
9 |
audio_gen = gr.Blocks.load(name="spaces/fffiloni/audioldm-text-to-audio-generation-clone", api_key=token)
|
10 |
|
11 |
-
def infer(image_input):
|
12 |
-
|
|
|
|
|
|
|
13 |
sound = audio_gen(cap, 10, 2.5, 45, 3, fn_index=0)
|
14 |
|
15 |
return cap, sound[1], gr.Group.update(visible=True)
|
@@ -70,6 +73,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
70 |
gr.HTML(title)
|
71 |
|
72 |
input_img = gr.Image(type="filepath", elem_id="input-img")
|
|
|
73 |
caption_output = gr.Textbox(label="Caption", lines=1, visible=False, elem_id="text-caption")
|
74 |
sound_output = gr.Audio(label="Result", elem_id="sound-output")
|
75 |
|
@@ -82,7 +86,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
82 |
|
83 |
gr.HTML(article)
|
84 |
|
85 |
-
generate.click(infer, inputs=[input_img], outputs=[caption_output, sound_output, share_group], api_name="i2fx")
|
86 |
share_button.click(None, [], [], _js=share_js)
|
87 |
|
88 |
demo.queue(max_size=32).launch(debug=True)
|
|
|
8 |
caption = gr.Blocks.load(name="spaces/SRDdev/Image-Caption")
|
9 |
audio_gen = gr.Blocks.load(name="spaces/fffiloni/audioldm-text-to-audio-generation-clone", api_key=token)
|
10 |
|
11 |
+
def infer(image_input, manual_caption):
|
12 |
+
if manual_caption == None:
|
13 |
+
cap = caption(image_input, fn_index=0)
|
14 |
+
else:
|
15 |
+
cap = manual_caption
|
16 |
sound = audio_gen(cap, 10, 2.5, 45, 3, fn_index=0)
|
17 |
|
18 |
return cap, sound[1], gr.Group.update(visible=True)
|
|
|
73 |
gr.HTML(title)
|
74 |
|
75 |
input_img = gr.Image(type="filepath", elem_id="input-img")
|
76 |
+
manual_cap = gr.Textbox(label="Image description (optional)")
|
77 |
caption_output = gr.Textbox(label="Caption", lines=1, visible=False, elem_id="text-caption")
|
78 |
sound_output = gr.Audio(label="Result", elem_id="sound-output")
|
79 |
|
|
|
86 |
|
87 |
gr.HTML(article)
|
88 |
|
89 |
+
generate.click(infer, inputs=[input_img, manual_cap], outputs=[caption_output, sound_output, share_group], api_name="i2fx")
|
90 |
share_button.click(None, [], [], _js=share_js)
|
91 |
|
92 |
demo.queue(max_size=32).launch(debug=True)
|