From f1ee52fa152112e78ae86fe4c6778e4f66ab6b1a Mon Sep 17 00:00:00 2001 From: GrandaddyShmax Date: Mon, 7 Aug 2023 17:11:12 +0300 Subject: [PATCH] MBD kept loading on each generation (#184) --- demos/musicgen_app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/musicgen_app.py b/demos/musicgen_app.py index d8f0ce12..74c893e7 100644 --- a/demos/musicgen_app.py +++ b/demos/musicgen_app.py @@ -31,6 +31,7 @@ MAX_BATCH_SIZE = 12 BATCHED_DURATION = 15 INTERRUPTING = False +MBD = None # We have to wrap subprocess call to clean a bit the log when using gr.make_waveform _old_call = sp.call @@ -95,8 +96,9 @@ def load_model(version='facebook/musicgen-melody'): def load_diffusion(): global MBD - print("loading MBD") - MBD = MultiBandDiffusion.get_mbd_musicgen() + if MBD is None: + print("loading MBD") + MBD = MultiBandDiffusion.get_mbd_musicgen() def _do_predictions(texts, melodies, duration, progress=False, **gen_kwargs):