fffiloni commited on
Commit
a89612e
β€’
1 Parent(s): afd482c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -10,9 +10,14 @@ audio_gen = gr.Blocks.load(name="spaces/fffiloni/audioldm-text-to-audio-generati
10
 
11
  ph_message="If you're not happy with sound result, you can manually describe the scene depicted in your image :)"
12
 
13
- def clean():
14
-
15
- return manual_cap.update(value="",placeholder=ph_message), caption_output.update(value=None), sound_output.update(value=None)
 
 
 
 
 
16
 
17
  def infer(image_input, manual_caption, duration_in, seed):
18
  print(duration_in)
@@ -22,7 +27,7 @@ def infer(image_input, manual_caption, duration_in, seed):
22
  ph_update = "gpt2 caption: '" + cap + "' β€’ "
23
  else:
24
  cap = manual_caption
25
- print("manual captiony: " + cap)
26
  ph_update=""
27
 
28
  sound = audio_gen(cap, duration_in, 2.5, seed, 3, fn_index=0)
@@ -105,7 +110,8 @@ with gr.Blocks(css="style.css") as demo:
105
  gr.HTML(article)
106
 
107
  clean_out = [manual_cap, caption_output, sound_output]
108
- input_img.change(clean, None, clean_out)
 
109
  generate.click(infer, inputs=[input_img, manual_cap, duration_in, seed_in], outputs=[caption_output, sound_output, manual_cap, share_group], api_name="i2fx")
110
  share_button.click(None, [], [], _js=share_js)
111
 
 
10
 
11
  ph_message="If you're not happy with sound result, you can manually describe the scene depicted in your image :)"
12
 
13
+ def clean(input_img):
14
+ if input_img.value == None:
15
+ return manual_cap.update(value="",placeholder=ph_message), caption_output.update(value=None), sound_output.update(value=None)
16
+ else:
17
+ cap = caption(input_img.value, fn_index=0)
18
+ print("gpt2 caption: '" + cap + "' β€’ ")
19
+ ph_update = "gpt2 caption: '" + cap + "' β€’ "
20
+ return manual_cap.update(value="",placeholder=f"{ph_update}{ph_message}"), caption_output.update(value=cap), sound_output.update(value=None)
21
 
22
  def infer(image_input, manual_caption, duration_in, seed):
23
  print(duration_in)
 
27
  ph_update = "gpt2 caption: '" + cap + "' β€’ "
28
  else:
29
  cap = manual_caption
30
+ print("manual caption: " + cap)
31
  ph_update=""
32
 
33
  sound = audio_gen(cap, duration_in, 2.5, seed, 3, fn_index=0)
 
110
  gr.HTML(article)
111
 
112
  clean_out = [manual_cap, caption_output, sound_output]
113
+ input_img.change(clean, input_img, clean_out)
114
+
115
  generate.click(infer, inputs=[input_img, manual_cap, duration_in, seed_in], outputs=[caption_output, sound_output, manual_cap, share_group], api_name="i2fx")
116
  share_button.click(None, [], [], _js=share_js)
117