Skip to content

Commit

Permalink
Refactor download_model.sh to improve comments, correct download path…
Browse files Browse the repository at this point in the history
…s, and add additional model downloads
  • Loading branch information
tomkosm committed Jan 2, 2025
1 parent 00e6e3f commit 6161aa3
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions download_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ download_and_extract() {

echo "Downloading ${model_name} from ${url}" | tee -a "$LOG_FILE"

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

# **Download the file directly to destination_path without appending .tar**
# 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"

# **Extract the downloaded tar 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"

# **Remove the downloaded tar 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
Expand All @@ -43,19 +43,16 @@ download_and_extract() {
echo "----------------------------------------" | tee -a "$LOG_FILE"
}

# Download PP Detect Model to /root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/
# Corrected download paths without double directories
download_and_extract "https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar" \
"/root/.paddleocr/whl/cls/ch/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar" \
"/root/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer.tar" \
"PP Detect Model"
download_and_extract "https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar" \
"/root/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.tar" \
"PP Class Model"

# Download PP Rec Model to /root/.paddleocr/whl/rec/ch_ppocr_mobile_v2.0_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_ppocr_mobile_v2.0_rec_infer/ch_ppocr_mobile_v2.0_rec_infer.tar" \
"/root/.paddleocr/whl/rec/ch/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" \
"PP Rec Model Additional Path"

echo "All model downloads completed at $(date)" | tee -a "$LOG_FILE"

0 comments on commit 6161aa3

Please sign in to comment.