fffiloni commited on
Commit
0b066f5
1 Parent(s): 52fd1af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -26,6 +26,10 @@ def cut_audio(input_path, output_path, max_duration=30000):
26
 
27
  return output_path
28
 
 
 
 
 
29
  def infer(audio_file):
30
 
31
  truncated_audio = cut_audio(audio_file, "trunc_audio.mp3")
@@ -74,7 +78,7 @@ def infer(audio_file):
74
  images = pipe(prompt=result).images[0]
75
 
76
  #return cap_result, result, images
77
- return images
78
 
79
  css = """
80
  #col-container {max-width: 510px; margin-left: auto; margin-right: auto;}
@@ -104,10 +108,12 @@ with gr.Blocks(css=css) as demo:
104
  audio_input = gr.Audio(label="Music input", type="filepath", source="upload")
105
  infer_btn = gr.Button("Generate Image from Music")
106
  #lpmc_cap = gr.Textbox(label="Lp Music Caps caption")
107
- #llama_trans_cap = gr.Textbox(label="Llama translation")
108
  img_result = gr.Image(label="Image Result")
 
109
 
110
  #infer_btn.click(fn=infer, inputs=[audio_input], outputs=[lpmc_cap, llama_trans_cap, img_result])
111
- infer_btn.click(fn=infer, inputs=[audio_input], outputs=[img_result])
 
112
 
113
  demo.queue().launch()
 
26
 
27
  return output_path
28
 
29
+ def solo_xd(prompt):
30
+ images = pipe(prompt=result).images[0]
31
+ return images
32
+
33
  def infer(audio_file):
34
 
35
  truncated_audio = cut_audio(audio_file, "trunc_audio.mp3")
 
78
  images = pipe(prompt=result).images[0]
79
 
80
  #return cap_result, result, images
81
+ return images, gr.update(visible=True)
82
 
83
  css = """
84
  #col-container {max-width: 510px; margin-left: auto; margin-right: auto;}
 
108
  audio_input = gr.Audio(label="Music input", type="filepath", source="upload")
109
  infer_btn = gr.Button("Generate Image from Music")
110
  #lpmc_cap = gr.Textbox(label="Lp Music Caps caption")
111
+ llama_trans_cap = gr.Textbox(label="Llama translation", visible=False)
112
  img_result = gr.Image(label="Image Result")
113
+ tryagain_btn = gr.Button("Try again ?", visible=False)
114
 
115
  #infer_btn.click(fn=infer, inputs=[audio_input], outputs=[lpmc_cap, llama_trans_cap, img_result])
116
+ infer_btn.click(fn=infer, inputs=[audio_input], outputs=[img_result, tryagain_btn])
117
+ tryagain_btn.click(fn=solo_xd, inputs=[llama_trans_cap], outputs=[img_result])
118
 
119
  demo.queue().launch()