Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
7a7c4ea
1
Parent(s):
694aa5b
improving negative prompting if we can
Browse files
app.py
CHANGED
@@ -105,13 +105,16 @@ def generate_stable_audio_loop(prompt, loop_type, bpm, bars, seed=-1):
|
|
105 |
seconds_per_bar = seconds_per_beat * 4 # 4/4 time
|
106 |
target_loop_duration = seconds_per_bar * bars
|
107 |
|
108 |
-
|
|
|
109 |
if loop_type == "drums":
|
110 |
-
enhanced_prompt = f"{prompt}
|
111 |
-
|
|
|
112 |
else: # instruments
|
113 |
-
enhanced_prompt = f"{prompt}
|
114 |
-
|
|
|
115 |
|
116 |
# Set seed
|
117 |
if seed == -1:
|
@@ -144,8 +147,8 @@ def generate_stable_audio_loop(prompt, loop_type, bpm, bars, seed=-1):
|
|
144 |
|
145 |
# Removed aggressive resource cleanup wrapper
|
146 |
# Clear GPU cache once before generation (not after)
|
147 |
-
if device == "cuda":
|
148 |
-
|
149 |
|
150 |
with torch.cuda.amp.autocast(enabled=(device == "cuda")):
|
151 |
output = generate_diffusion_cond(
|
@@ -370,7 +373,7 @@ with gr.Blocks(title="stable-melodyflow") as iface:
|
|
370 |
- [our melodyflow api](https://github.com/betweentwomidnights/melodyflow)
|
371 |
""")
|
372 |
|
373 |
-
with gr.Accordion("gary4live
|
374 |
gr.Markdown("""
|
375 |
**gary4live** is a free/open source project that uses these models, along with musicGen, inside of ableton live to iterate on your projects with you. i run a backend myself so that we can all experiment with it, but you can also spin the backend up locally using docker-compose with our repo.
|
376 |
|
|
|
105 |
seconds_per_bar = seconds_per_beat * 4 # 4/4 time
|
106 |
target_loop_duration = seconds_per_bar * bars
|
107 |
|
108 |
+
|
109 |
+
# Enhance prompt based on loop type and BPM - minimal modification
|
110 |
if loop_type == "drums":
|
111 |
+
enhanced_prompt = f"{prompt} {bpm}bpm"
|
112 |
+
# Comprehensive negative prompting for drums - exclude all melodic/harmonic content
|
113 |
+
negative_prompt = "melody, harmony, pitched instruments, vocals, singing, piano, guitar, bass, synth, strings, horns, woodwinds, flute, saxophone, violin, cello, organ, keyboard, chords, notes, musical scale, tonal, melodic, harmonic"
|
114 |
else: # instruments
|
115 |
+
enhanced_prompt = f"{prompt} {bpm}bpm"
|
116 |
+
# Comprehensive negative prompting for instruments - exclude all percussive content
|
117 |
+
negative_prompt = "drums, percussion, kick, snare, hi-hat, cymbals, tom, drum kit, rhythm section, beats, drumming, percussive, drum machine, 808, trap drums, boom bap drums, breakbeat, drum breaks, kick drum, snare drum"
|
118 |
|
119 |
# Set seed
|
120 |
if seed == -1:
|
|
|
147 |
|
148 |
# Removed aggressive resource cleanup wrapper
|
149 |
# Clear GPU cache once before generation (not after)
|
150 |
+
# if device == "cuda":
|
151 |
+
# torch.cuda.empty_cache()
|
152 |
|
153 |
with torch.cuda.amp.autocast(enabled=(device == "cuda")):
|
154 |
output = generate_diffusion_cond(
|
|
|
373 |
- [our melodyflow api](https://github.com/betweentwomidnights/melodyflow)
|
374 |
""")
|
375 |
|
376 |
+
with gr.Accordion("gary4live project", open=False):
|
377 |
gr.Markdown("""
|
378 |
**gary4live** is a free/open source project that uses these models, along with musicGen, inside of ableton live to iterate on your projects with you. i run a backend myself so that we can all experiment with it, but you can also spin the backend up locally using docker-compose with our repo.
|
379 |
|