fffiloni commited on
Commit
cbbd024
1 Parent(s): 3127104

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  import json
3
  import re
4
  from gradio_client import Client
@@ -98,7 +99,7 @@ pipe = pipeline("text-generation", model=zephyr_model, torch_dtype=torch.bfloat1
98
 
99
  agent_maker_sys = f"""
100
  You are an AI whose job is to help users create their own music which its genre will reflect the character or scene from an image described by users.
101
- In particular, you need to respond succintly in a friendly tone, write a musical prompt for an music generation model.
102
 
103
  For example, if a user says, "a picture of a man in a black suit and tie riding a black dragon", provide immediately a musical prompt corresponding to the image description.
104
  Immediately STOP after that. It should be EXACTLY in this format:
@@ -111,6 +112,7 @@ instruction = f"""
111
  <|user|>
112
  """
113
 
 
114
  def infer(image_in):
115
  gr.Info("Getting image caption with Kosmos2...")
116
  user_prompt = get_caption(image_in)
@@ -160,7 +162,8 @@ with gr.Blocks(css=css) as demo:
160
  submit_btn = gr.Button("Make music from my pic !")
161
  with gr.Column():
162
  caption = gr.Textbox(
163
- label = "Musical prompt"
 
164
  )
165
  result = gr.Audio(
166
  label = "Music"
 
1
  import gradio as gr
2
+ import spaces
3
  import json
4
  import re
5
  from gradio_client import Client
 
99
 
100
  agent_maker_sys = f"""
101
  You are an AI whose job is to help users create their own music which its genre will reflect the character or scene from an image described by users.
102
+ In particular, you need to respond succintly with few musical words, in a friendly tone, write a musical prompt for a music generation model.
103
 
104
  For example, if a user says, "a picture of a man in a black suit and tie riding a black dragon", provide immediately a musical prompt corresponding to the image description.
105
  Immediately STOP after that. It should be EXACTLY in this format:
 
112
  <|user|>
113
  """
114
 
115
+ @spaces.GPU(enable_queue=True, duration=60)
116
  def infer(image_in):
117
  gr.Info("Getting image caption with Kosmos2...")
118
  user_prompt = get_caption(image_in)
 
162
  submit_btn = gr.Button("Make music from my pic !")
163
  with gr.Column():
164
  caption = gr.Textbox(
165
+ label = "Musical prompt",
166
+ max_lines = 3
167
  )
168
  result = gr.Audio(
169
  label = "Music"