-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small util for downloading hf models
- Loading branch information
1 parent
36aad3a
commit 10b783c
Showing
4 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3 | ||
|
||
USER root | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY . . | ||
|
||
CMD [ "python", "./download_model.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Downloads a model form huggingface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from huggingface_hub import snapshot_download | ||
import os | ||
|
||
model_id = os.environ.get("MODEL", None) | ||
model_folder = os.environ.get("MODEL_DIR", "/models") | ||
os.makedirs(model_folder, exist_ok=True) | ||
|
||
if model_folder is None: | ||
print("INFO: Using default model dir: /models") | ||
|
||
if model_id is None: | ||
print("WARNING: Not all envs where specified, can not download anything") | ||
else: | ||
snapshot_download(repo_id=model_id, local_dir=os.path.join(model_folder, model_id), local_dir_use_symlinks=False, revision="main") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
huggingface_hub |