Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -110,7 +110,7 @@ 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 |
-
musical_prompt = '
|
114 |
if openai_api_key != None:
|
115 |
gpt_adaptation = try_api(prompt, openai_api_key)
|
116 |
if gpt_adaptation[0] != "oups":
|
@@ -123,12 +123,13 @@ def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode, openai_
|
|
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],
|
132 |
|
133 |
def try_api(message, openai_api_key):
|
134 |
|
@@ -281,9 +282,9 @@ with gr.Blocks(css="style.css") as demo:
|
|
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")
|
288 |
with gr.Group(elem_id="share-btn-container"):
|
289 |
community_icon = gr.HTML(community_icon_html, visible=False)
|
@@ -301,7 +302,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
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,
|
305 |
share_button.click(None, [], [], _js=share_js)
|
306 |
|
307 |
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 = 'You did not use any OpenAI API key to pimp your result :)'
|
114 |
if openai_api_key != None:
|
115 |
gpt_adaptation = try_api(prompt, openai_api_key)
|
116 |
if gpt_adaptation[0] != "oups":
|
|
|
123 |
CLIP Interrogator Caption: '{prompt}'
|
124 |
β
|
125 |
OpenAI Musical Adaptation: '{musical_prompt}'
|
126 |
+
β
|
127 |
+
Audio file link: {music_result[2]}
|
128 |
"""
|
129 |
#wave_file = convert_mp3_to_wav(music_result[1])
|
130 |
|
131 |
time.sleep(1)
|
132 |
+
return show_prompts, music_result[1], gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
133 |
|
134 |
def try_api(message, openai_api_key):
|
135 |
|
|
|
282 |
</div>""")
|
283 |
|
284 |
input_img = gr.Image(type="filepath", elem_id="input-img")
|
285 |
+
prompts_out = gr.Textbox(label="Text Captions", info="If player do not work, try to copy/paste the link in a new browser window")
|
286 |
music_output = gr.Audio(label="Result", type="filepath", elem_id="music-output").style(height="5rem")
|
287 |
+
#music_url = gr.Textbox(max_lines=1, info="If player do not work, try to copy/paste the link in a new browser window")
|
288 |
#text_status = gr.Textbox(label="status")
|
289 |
with gr.Group(elem_id="share-btn-container"):
|
290 |
community_icon = gr.HTML(community_icon_html, visible=False)
|
|
|
302 |
|
303 |
gr.HTML(article)
|
304 |
|
305 |
+
generate.click(get_prompts, inputs=[input_img,track_duration,gen_intensity,gen_mode, openai_api_key], outputs=[prompts_out, music_output, share_button, community_icon, loading_icon], api_name="i2m")
|
306 |
share_button.click(None, [], [], _js=share_js)
|
307 |
|
308 |
demo.queue(max_size=32, concurrency_count=20).launch()
|