fffiloni commited on
Commit
3577ab2
1 Parent(s): 2699d44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -40,7 +40,7 @@ def load_model(version):
40
  return MusicGen.get_pretrained(version)
41
 
42
 
43
- def predict(music_prompt, melody, duration):
44
  text = music_prompt
45
  global MODEL
46
  topk = int(250)
@@ -54,7 +54,7 @@ def predict(music_prompt, melody, duration):
54
  top_k=250,
55
  top_p=0,
56
  temperature=1.0,
57
- cfg_coef=3.0,
58
  duration=duration,
59
  )
60
 
@@ -113,6 +113,7 @@ with gr.Blocks(css=css) as demo:
113
  with gr.Row():
114
  #model = gr.Radio(["melody", "medium", "small", "large"], label="MusicGen Model", value="melody", interactive=True)
115
  duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Generated Music Duration", interactive=True)
 
116
  with gr.Row():
117
  submit = gr.Button("Submit")
118
  #with gr.Row():
@@ -129,34 +130,39 @@ with gr.Blocks(css=css) as demo:
129
  [
130
  "An 80s driving pop song with heavy drums and synth pads in the background",
131
  None,
132
- 10
 
133
  ],
134
  [
135
  "A cheerful country song with acoustic guitars",
136
  None,
137
- 10
 
138
  ],
139
  [
140
  "90s rock song with electric guitar and heavy drums",
141
  None,
142
- 10
 
143
  ],
144
  [
145
  "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
146
  None,
147
- 10
 
148
  ],
149
  [
150
  "lofi slow bpm electro chill with organic samples",
151
  None,
152
- 10
 
153
  ],
154
  ],
155
- inputs=[music_prompt, melody, duration],
156
  outputs=[output]
157
  )
158
  load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track], outputs=[melody])
159
- submit.click(predict, inputs=[music_prompt, melody, duration], outputs=[output])
160
 
161
 
162
  demo.queue(max_size=32).launch()
 
40
  return MusicGen.get_pretrained(version)
41
 
42
 
43
+ def predict(music_prompt, melody, duration, cfg_coef):
44
  text = music_prompt
45
  global MODEL
46
  topk = int(250)
 
54
  top_k=250,
55
  top_p=0,
56
  temperature=1.0,
57
+ cfg_coef=cfg_coef,
58
  duration=duration,
59
  )
60
 
 
113
  with gr.Row():
114
  #model = gr.Radio(["melody", "medium", "small", "large"], label="MusicGen Model", value="melody", interactive=True)
115
  duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Generated Music Duration", interactive=True)
116
+ cfg_coef = gr.Number(label="Classifier Free Guidance", minimum=1.0, maximum=10.0, step=0.1, value=3.0, interactive=True)
117
  with gr.Row():
118
  submit = gr.Button("Submit")
119
  #with gr.Row():
 
130
  [
131
  "An 80s driving pop song with heavy drums and synth pads in the background",
132
  None,
133
+ 10,
134
+ 3.0
135
  ],
136
  [
137
  "A cheerful country song with acoustic guitars",
138
  None,
139
+ 10,
140
+ 3.0
141
  ],
142
  [
143
  "90s rock song with electric guitar and heavy drums",
144
  None,
145
+ 10,
146
+ 3.0
147
  ],
148
  [
149
  "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
150
  None,
151
+ 10,
152
+ 3.0
153
  ],
154
  [
155
  "lofi slow bpm electro chill with organic samples",
156
  None,
157
+ 10,
158
+ 3.0
159
  ],
160
  ],
161
+ inputs=[music_prompt, melody, duration, cfg_coef],
162
  outputs=[output]
163
  )
164
  load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track], outputs=[melody])
165
+ submit.click(predict, inputs=[music_prompt, melody, duration, cfg_coef], outputs=[output])
166
 
167
 
168
  demo.queue(max_size=32).launch()