-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhf_dl.sh
More file actions
executable file
·33 lines (25 loc) · 817 Bytes
/
hf_dl.sh
File metadata and controls
executable file
·33 lines (25 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# You should install it if not
# pip install -U huggingface_hub
#export HF_ENDPOINT=https://hf-mirror.com
# Check if the correct number of arguments was passed
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <model-id> <save-dir>"
exit 1
fi
# Assign the script arguments to variables
MODEL_ID=$1
SAVE_DIR=$2
# Set the Hugging Face cache environment variable to the save directory
#export TRANSFORMERS_CACHE=$SAVE_DIR
# Create the directory if it does not exist
mkdir -p "$SAVE_DIR"
# Use transformers-cli to download the model
huggingface-cli download --resume-download --local-dir-use-symlinks False $MODEL_ID --local-dir $SAVE_DIR
# Check if the download was successful
if [ $? -eq 0 ]; then
echo "Model downloaded successfully."
else
echo "Failed to download the model."
exit 1
fi