Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass env var to cache T5 #253

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions audiocraft/modules/conditioners.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import re
import typing as tp
import warnings
import os

import einops
from num2words import num2words
Expand Down Expand Up @@ -409,11 +410,12 @@ def __init__(self, name: str, output_dim: int, finetune: bool, device: str,
# thanks https://gist.github.com/simon-weber/7853144
previous_level = logging.root.manager.disable
logging.disable(logging.ERROR)
cache_dir = os.environ.get('AUDIOCRAFT_CACHE_DIR', None)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
try:
self.t5_tokenizer = T5Tokenizer.from_pretrained(name)
t5 = T5EncoderModel.from_pretrained(name).train(mode=finetune)
self.t5_tokenizer = T5Tokenizer.from_pretrained(name, cache_dir=cache_dir)
t5 = T5EncoderModel.from_pretrained(name, cache_dir=cache_dir).train(mode=finetune)
finally:
logging.disable(previous_level)
if finetune:
Expand Down
Loading