Closed 0xlws closed 1 year ago
usage:
from audiocraft.models import MusicGen from audiocraft.models import MultiBandDiffusion import torch USE_DIFFUSION_DECODER = False CACHE_DIR = 'models'
medium
or large
.model = MusicGen.get_pretrained('facebook/musicgen-small', cache_dir=CACHE_DIR) if USE_DIFFUSION_DECODER: mbd = MultiBandDiffusion.get_mbd_musicgen(cache_dir=CACHE_DIR)
@0xlws where is this located on the audiocraft? what folder, and whats the name of the file? do we need to replace a specific line there? or just add that?
Thanks. We would rather not add more complex behavior in the model API for now and these cache dir location can be controlled by environment variables:
AUDIOCRAFT_CACHE_DIR
as mentioned in the README. TORCH_HOME
variable.@JadeCopet @adefossez big Thanks for this amazing repo.
i just now tried using the global variable (i wasnt handy with Python env vars), and it works for the musicgen model, but again the t5 lm still goes into the .cache.
in point 3 you mention 'other models', not sure but i guess you were referring to that t5 lm. i went over the huggingface page and could not find anything clear related...
the way it was solved was by 'simply' passing in the cache_dir variable.
instead of passing it in at the root call we can also use the env var instead as such before these lines:
correction:
# if cache_dir is None:
cache_dir = os.environ.get('AUDIOCRAFT_CACHE_DIR', None)
and pass it as such. this way the language model gets stored in the same specified folder.
id love to hear your thoughts
is this related to my problem @0xlws ?
@0xlws where is this code located on the folder ? if cache_dir is None: cache_dir = os.environ.get('AUDIOCRAFT_CACHE_DIR', None)
please help
@nel1991
is this related to my problem @0xlws ?
yes but youre experiencing issues even after following the same instructions i used, which work in my case and still give errors in your case.
@0xlws where is this code located on the folder ? if cache_dir is None: cache_dir = os.environ.get('AUDIOCRAFT_CACHE_DIR', None)
as @JadeCopet mentioned the use of the env vars, i took the existing implementation from: https://github.com/facebookresearch/audiocraft/blob/5ecdc68ef7a442ed81b6d316fc5029b5a2c16290/audiocraft/models/loaders.py#L44
actual function being on line 34.
so i would also advice you to use the env vars. in the collab cell i ran:
import os
os.environ['AUDIOCRAFT_CACHE_DIR'] = 'models'
os.environ['TORCH_HOME'] = 'models'
which also created the models folder and stored the models, t5 model was still being written inside the .cache folder. so in your case this may not be solved as it will still try to write to your unwritable .cache folder. thats why i still propose to set the cache for the model in the function using the same env var instead.
under model/loaders.py under demos\musicgen_app.py is the code correct on the top?
im still getting an error:
@nel1991 i notice youre still using my repo, i may have opened a can of worms for you. i just updated my repo to align again with the main repo, and using the env vars.
edit: added a commit to support storing T5.
i tested it and it works the same. please make sure to update the latest changes, the ROOT = Path... ... (on lines 31 - 36) will be removed if updated.
i did download the main folder and the error is unable to find the cache folder, when i downloaded yours, your updated repo, still the same error. your repository is already updated right? once i downloaded your repository again, it will show the changes. But the error still the same. i dont know what to do
usage: