Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkosm committed Dec 27, 2024
1 parent ba811a5 commit 05352b0
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions download_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,34 @@ echo "Starting model downloads at $(date)" | tee -a "$LOG_FILE"
download_and_extract() {
local url=$1
local destination_path=$2
local output_tar="$destination_path.tar"
local model_name=$3

echo "Downloading ${model_name} from ${url}" | tee -a "$LOG_FILE"
curl -L -o "${output_tar}" "${url}" 2>&1 | tee -a "$LOG_FILE"

# **Create the destination directory before downloading**
mkdir -p "$(dirname "${destination_path}")"

# **Download the file directly to destination_path without appending .tar**
if ! curl -L -o "${destination_path}" "${url}" 2>&1 | tee -a "$LOG_FILE"; then
echo "Failed to download ${model_name} from ${url}" | tee -a "$LOG_FILE"
exit 1
fi

echo "Extracting ${model_name}" | tee -a "$LOG_FILE"
mkdir -p "$(dirname "${destination_path}")"
tar -xvf "${output_tar}" -C "$(dirname "${destination_path}")" 2>&1 | tee -a "$LOG_FILE"

# **Extract the downloaded tar file**
if ! tar -xvf "${destination_path}" -C "$(dirname "${destination_path}")" 2>&1 | tee -a "$LOG_FILE"; then
echo "Failed to extract ${model_name}" | tee -a "$LOG_FILE"
exit 1
fi

echo "Removing archive for ${model_name}" | tee -a "$LOG_FILE"
rm "${output_tar}" | tee -a "$LOG_FILE"

# **Remove the downloaded tar file**
if ! rm "${destination_path}" | tee -a "$LOG_FILE"; then
echo "Failed to remove archive for ${model_name}" | tee -a "$LOG_FILE"
exit 1
fi

echo "${model_name} download and extraction completed." | tee -a "$LOG_FILE"
echo "----------------------------------------" | tee -a "$LOG_FILE"
Expand All @@ -36,7 +52,7 @@ download_and_extract "https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCR
download_and_extract "https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_infer.tar" \
"/root/.paddleocr/whl/rec/ch_ppocr_mobile_v2.0_rec_infer/ch_ppocr_mobile_v2.0_rec_infer.tar" \
"PP Rec Model"

# **New Addition**: Download PP Rec Model to /root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/
download_and_extract "https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_rec_infer.tar" \
"/root/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer/ch_PP-OCRv4_rec_infer.tar" \
Expand Down

0 comments on commit 05352b0

Please sign in to comment.