mirror of
https://github.com/hanzoai/mugen.git
synced 2026-11-03 01:48:40 +00:00
MAGNeT - Fix for xformers 0.0.22 compatibility, thanks to @nateraw catch. In addition, the following smaller fixes are also contained in this PR: * MAGNeT notebook - change to stride1 span arrangement by default. * MAGNeT doc fix of a typo. * MAGNeT music training grid typo fix.
7.4 KiB
7.4 KiB
In [ ]:
from audiocraft.models import MAGNeT
model = MAGNeT.get_pretrained('facebook/magnet-small-10secs')In [ ]:
model.set_generation_params(
use_sampling=True,
top_k=0,
top_p=0.9,
temperature=3.0,
max_cfg_coef=10.0,
min_cfg_coef=1.0,
decoding_steps=[int(20 * model.lm.cfg.dataset.segment_duration // 10), 10, 10, 10],
span_arrangement='stride1'
)In [ ]:
from audiocraft.utils.notebook import display_audio
###### Text-to-music prompts - examples ######
text = "80s electronic track with melodic synthesizers, catchy beat and groovy bass"
# text = "80s electronic track with melodic synthesizers, catchy beat and groovy bass. 170 bpm"
# text = "Earthy tones, environmentally conscious, ukulele-infused, harmonic, breezy, easygoing, organic instrumentation, gentle grooves"
# text = "Funky groove with electric piano playing blue chords rhythmically"
# text = "Rock with saturated guitars, a heavy bass line and crazy drum break and fills."
# text = "A grand orchestral arrangement with thunderous percussion, epic brass fanfares, and soaring strings, creating a cinematic atmosphere fit for a heroic battle"
N_VARIATIONS = 3
descriptions = [text for _ in range(N_VARIATIONS)]
print(f"text prompt: {text}\n")
output = model.generate(descriptions=descriptions, progress=True, return_tokens=True)
display_audio(output[0], sample_rate=model.compression_model.sample_rate)In [ ]:
from audiocraft.models import MAGNeT
model = MAGNeT.get_pretrained('facebook/audio-magnet-small')In [ ]:
model.set_generation_params(
use_sampling=True,
top_k=0,
top_p=0.8,
temperature=3.5,
max_cfg_coef=20.0,
min_cfg_coef=1.0,
decoding_steps=[int(20 * model.lm.cfg.dataset.segment_duration // 10), 10, 10, 10],
span_arrangement='stride1'
)In [ ]:
from audiocraft.utils.notebook import display_audio
###### Text-to-audio prompts - examples ######
text = "Seagulls squawking as ocean waves crash while wind blows heavily into a microphone."
# text = "A toilet flushing as music is playing and a man is singing in the distance."
N_VARIATIONS = 3
descriptions = [text for _ in range(N_VARIATIONS)]
print(f"text prompt: {text}\n")
output = model.generate(descriptions=descriptions, progress=True, return_tokens=True)
display_audio(output[0], sample_rate=model.compression_model.sample_rate)