Skip to content

Commit

Permalink
small util for downloading hf models
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepCowProductions committed Sep 24, 2024
1 parent 36aad3a commit 10b783c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions images/downloadtool/Dockerfile
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" ]
1 change: 1 addition & 0 deletions images/downloadtool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Downloads a model form huggingface
15 changes: 15 additions & 0 deletions images/downloadtool/download_model.py
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")

1 change: 1 addition & 0 deletions images/downloadtool/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
huggingface_hub

0 comments on commit 10b783c

Please sign in to comment.