Commit 3603075 0 parents commit 3603075 Copy full SHA for 3603075
File tree 5 files changed +89
-0
lines changed
5 files changed +89
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build Images
2
+
3
+ on :
4
+ release :
5
+ types : [ created ]
6
+ permissions :
7
+ actions : write
8
+ packages : write
9
+
10
+ env :
11
+ IMAGE_NAME : " amikos/hf-model-downloader"
12
+
13
+ jobs :
14
+ build-images :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - name : Checkout
18
+ uses : actions/checkout@v4
19
+ with :
20
+ fetch-depth : 0
21
+ - name : Log in to the Container registry
22
+ uses : docker/login-action@v3
23
+ with :
24
+ username : ${{ secrets.DOCKERHUB_TOKEN }}
25
+ password : ${{ secrets.DOCKERHUB_USERNAME }}
26
+ - name : Docker meta
27
+ id : meta
28
+ uses : docker/metadata-action@v4
29
+ with :
30
+ images : ${{ env.IMAGE_NAME }}
31
+ - name : Set up QEMU
32
+ uses : docker/setup-qemu-action@v3
33
+ - name : Set up Docker Buildx
34
+ uses : docker/setup-buildx-action@v3
35
+ - name : Build and push release Docker image
36
+ uses : docker/build-push-action@v5
37
+ with :
38
+ context : .
39
+ file : Dockerfile
40
+ push : true
41
+ platforms : linux/amd64,linux/arm64
42
+ tags : " ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }},${{ env.IMAGE_NAME }}:latest"
Original file line number Diff line number Diff line change
1
+ FROM python:alpine3.12
2
+
3
+ LABEL maintainer=
"[email protected] "
4
+
5
+
6
+ COPY docker-entrypoint.sh /
7
+ RUN pip install 'huggingface_hub[cli]' && \
8
+ chmod +x /docker-entrypoint.sh
9
+
10
+ ENTRYPOINT [ "/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change
1
+ # HuggingFace Hub Model Downloader
2
+
3
+ The purpose of this docker image is to provide a convenient way to download models from the HuggingFace Hub using HF's CLI.
4
+
5
+ ## Usage
6
+
7
+ ``` bash
8
+ docker run -it --rm -v $( PWD) :/models amikos/hf-model-downloader sentence-transformers/all-MiniLM-L6-v2
9
+ ```
10
+
11
+ With HF Token:
12
+
13
+ ``` bash
14
+ export HF_TOKEN=" your_huggingface_token"
15
+ docker run -it --rm -e HF_TOKEN=" $HF_TOKEN " -v $( PWD) :/models amikos/hf-model-downloader sentence-transformers/all-MiniLM-L6-v2
16
+ ```
17
+
18
+ ## Building
19
+
20
+ ``` bash
21
+ docker build -t < tag> .
22
+ ```
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ for model in " $@ "
4
+ do
5
+ # Sanitize the model name
6
+ sanitized_model=$( printf ' %s' " $model " | sed ' s/[^a-zA-Z0-9._-]/_/g' )
7
+ token=" "
8
+ # Add token if HF_TOKEN is defined
9
+ if [ -n " $HF_TOKEN " ]; then
10
+ token=" --token ${HF_TOKEN} "
11
+ echo " Found HF token, using it to download $model "
12
+ fi
13
+ # Use printf to safely pass arguments
14
+ printf ' %s\0' " --local-dir" " /models/$sanitized_model " " $model " | xargs -0 huggingface-cli download $token
15
+ done
You can’t perform that action at this time.
0 commit comments