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

Limit Huggingface model download size #754

Merged
merged 15 commits into from
May 26, 2024
Merged
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
22 changes: 20 additions & 2 deletions buzz/model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ def is_manually_downloadable(self):
ModelType.FASTER_WHISPER,
)

HUGGING_FACE_MODEL_ALLOW_PATTERNS = [
"added_tokens.json",
"config.json",
"generation_config.json",
"merges.txt",
"model.safetensors",
"normalizer.json",
"preprocessor_config.json",
"special_tokens_map.json",
"tokenizer.json",
"tokenizer_config.json",
"vocab.json",
]


@dataclass()
class TranscriptionModel:
Expand Down Expand Up @@ -179,7 +193,9 @@ def get_local_model_path(self) -> Optional[str]:
if self.model_type == ModelType.HUGGING_FACE:
try:
return huggingface_hub.snapshot_download(
self.hugging_face_model_id, local_files_only=True
self.hugging_face_model_id,
allow_patterns=HUGGING_FACE_MODEL_ALLOW_PATTERNS,
local_files_only=True
)
except (ValueError, FileNotFoundError):
return None
Expand Down Expand Up @@ -296,7 +312,9 @@ def close(self):

if self.model.model_type == ModelType.HUGGING_FACE:
model_path = huggingface_hub.snapshot_download(
self.model.hugging_face_model_id, tqdm_class=_tqdm
self.model.hugging_face_model_id,
allow_patterns=HUGGING_FACE_MODEL_ALLOW_PATTERNS,
tqdm_class=_tqdm
)
self.signals.finished.emit(model_path)
return
Expand Down
Loading