File size: 827 Bytes
faf4679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Authenticate with Hugging Face
export HF_HOME=/home/user/data/hf_cache

echo "Using Hugging Face API token for authentication"
export HF_TOKEN=${HF_TOKEN}

# Use the environment variable for the model name
MODEL_DIR="/home/user/data/models/${HF_MODEL_NAME}"
MODEL_URL=${HF_MODEL_URL}  # Ensure consistent variable naming

# Download the model if it does not exist
if [ ! -d "$MODEL_DIR" ]; then
    echo "Model not found. Downloading ${HF_MODEL_NAME} from ${MODEL_URL}..."
    mkdir -p "$MODEL_DIR"  # Ensure the directory exists before downloading
    wget "$MODEL_URL" -P "$MODEL_DIR" || {
        echo "Failed to download model from ${MODEL_URL}"
        exit 1  # Exit if download fails
    }
else 
    echo "Model ${HF_MODEL_NAME} already present."
fi

# Execute the main command of the container
exec "$@"