From 6161aa34d69f9b282a6e7be19cd7a2138caaf375 Mon Sep 17 00:00:00 2001 From: Thomas Kosmas Date: Thu, 2 Jan 2025 18:51:14 +0200 Subject: [PATCH] Refactor download_model.sh to improve comments, correct download paths, and add additional model downloads --- download_model.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/download_model.sh b/download_model.sh index 788ad36..9f29651 100755 --- a/download_model.sh +++ b/download_model.sh @@ -14,10 +14,10 @@ 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 @@ -25,7 +25,7 @@ download_and_extract() { 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 @@ -33,7 +33,7 @@ download_and_extract() { 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 @@ -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" \ No newline at end of file