fffiloni commited on
Commit
6368dcf
β€’
1 Parent(s): 4417b20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -110,18 +110,25 @@ def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode, openai_
110
 
111
  prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
112
  print(prompt)
 
113
  if openai_api_key != None:
114
  gpt_adaptation = try_api(prompt, openai_api_key)
115
  if gpt_adaptation[0] != "oups":
116
  musical_prompt = gpt_adaptation[0]
 
117
  else:
118
- musical_prompt = prompt
119
- music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
120
 
 
 
 
 
 
 
121
  #wave_file = convert_mp3_to_wav(music_result[1])
122
 
123
  time.sleep(1)
124
- return music_result[1],music_result[2], gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
125
 
126
  def try_api(message, openai_api_key):
127
 
@@ -274,6 +281,7 @@ with gr.Blocks(css="style.css") as demo:
274
  </div>""")
275
 
276
  input_img = gr.Image(type="filepath", elem_id="input-img")
 
277
  music_output = gr.Audio(label="Result", type="filepath", elem_id="music-output").style(height="5rem")
278
  music_url = gr.Textbox(max_lines=1, info="If player do not work, try to copy/paste the link in a new browser window")
279
  #text_status = gr.Textbox(label="status")
@@ -293,7 +301,7 @@ with gr.Blocks(css="style.css") as demo:
293
 
294
  gr.HTML(article)
295
 
296
- generate.click(get_prompts, inputs=[input_img,track_duration,gen_intensity,gen_mode, openai_api_key], outputs=[music_output, music_url, share_button, community_icon, loading_icon], api_name="i2m")
297
  share_button.click(None, [], [], _js=share_js)
298
 
299
  demo.queue(max_size=32, concurrency_count=20).launch()
 
110
 
111
  prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
112
  print(prompt)
113
+ musical_prompt = 'None'
114
  if openai_api_key != None:
115
  gpt_adaptation = try_api(prompt, openai_api_key)
116
  if gpt_adaptation[0] != "oups":
117
  musical_prompt = gpt_adaptation[0]
118
+ music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
119
  else:
120
+ music_result = get_results(prompt, track_duration, gen_intensity, gen_mode)
 
121
 
122
+ show_prompts = f"""
123
+ CLIP Interrogator Caption: '{prompt}'
124
+ β€”
125
+ OpenAI Musical Adaptation: '{musical_prompt}'
126
+
127
+ """
128
  #wave_file = convert_mp3_to_wav(music_result[1])
129
 
130
  time.sleep(1)
131
+ return show_prompts, music_result[1],music_result[2], gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
132
 
133
  def try_api(message, openai_api_key):
134
 
 
281
  </div>""")
282
 
283
  input_img = gr.Image(type="filepath", elem_id="input-img")
284
+ prompts_out = gr.Textbox(label="Captions")
285
  music_output = gr.Audio(label="Result", type="filepath", elem_id="music-output").style(height="5rem")
286
  music_url = gr.Textbox(max_lines=1, info="If player do not work, try to copy/paste the link in a new browser window")
287
  #text_status = gr.Textbox(label="status")
 
301
 
302
  gr.HTML(article)
303
 
304
+ generate.click(get_prompts, inputs=[input_img,track_duration,gen_intensity,gen_mode, openai_api_key], outputs=[prompts_out, music_output, music_url, share_button, community_icon, loading_icon], api_name="i2m")
305
  share_button.click(None, [], [], _js=share_js)
306
 
307
  demo.queue(max_size=32, concurrency_count=20).launch()