Skip to content

Commit f24917b

Browse files
alancuckinv-kkudrynski
authored andcommitted
Add a script to download model from NGC
1 parent f4d6a00 commit f24917b

5 files changed

Lines changed: 34 additions & 7 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pretrained_models/
2+
results/

PyTorch/SpeechRecognition/QuartzNet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ To train your model using mixed or TF32 precision with Tensor Cores or using FP3
264264
7. Start inference/predictions.
265265
Inside the container, use the following script to run inference.
266266
Make sure the downloaded and preprocessed dataset is located at `$DATA_DIR/LibriSpeech` on the host, which is mounted as `/datasets/LibriSpeech` inside the container.
267-
A pretrained model checkpoint can be downloaded from [NGC model repository](https://ngc.nvidia.com/catalog/models).
267+
A pretrained model checkpoint can be downloaded from [NGC model repository](https://ngc.nvidia.com/catalog/models), manually or automatically using `scripts/download_quartznet.sh`.
268268

269269
```bash
270270
[OPTION1=value1 OPTION2=value2 ...] bash scripts/inference.sh

PyTorch/SpeechRecognition/QuartzNet/scripts/docker/launch.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ SCRIPT_DIR=$(cd $(dirname $0); pwd)
44
QN_REPO=${QN_REPO:-"${SCRIPT_DIR}/../.."}
55

66
DATA_DIR=${1:-${DATA_DIR-${QN_REPO}"/datasets"}}
7-
CHECKPOINT_DIR=${2:-${CHECKPOINT_DIR:-${QN_REPO}"/checkpoints"}}
8-
RESULT_DIR=${3:-${RESULT_DIR:-${QN_REPO}"/results"}}
9-
PROGRAM_PATH=${PROGRAM_PATH}
7+
RESULT_DIR=${2:-${RESULT_DIR:-${QN_REPO}"/results"}}
8+
SCRIPT=${3:-${SCRIPT:-""}}
109

1110
MOUNTS=""
1211
MOUNTS+=" -v $DATA_DIR:/datasets"
13-
MOUNTS+=" -v $CHECKPOINT_DIR:/checkpoints"
1412
MOUNTS+=" -v $RESULT_DIR:/results"
1513
MOUNTS+=" -v ${QN_REPO}:/quartznet"
1614

@@ -21,4 +19,4 @@ docker run -it --rm --gpus all\
2119
--ulimit stack=67108864 \
2220
$MOUNTS \
2321
-w /quartznet \
24-
quartznet:latest bash $PROGRAM_PATH
22+
quartznet:latest bash $SCRIPT
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
: ${MODEL_DIR:="pretrained_models/quartznet"}
6+
MODEL_ZIP="quartznet_pyt_ckpt_amp_21.03.0.zip"
7+
MODEL="nvidia_quartznet_210504.pt"
8+
MODEL_URL="https://api.ngc.nvidia.com/v2/models/nvidia/quartznet_pyt_ckpt_amp/versions/21.03.0/zip"
9+
10+
mkdir -p "$MODEL_DIR"
11+
12+
if [ ! -f "${MODEL_DIR}/${MODEL_ZIP}" ]; then
13+
echo "Downloading ${MODEL_ZIP} ..."
14+
wget -qO ${MODEL_DIR}/${MODEL_ZIP} ${MODEL_URL} \
15+
|| { echo "ERROR: Failed to download ${MODEL_ZIP} from NGC"; exit 1; }
16+
fi
17+
18+
if [ ! -f "${MODEL_DIR}/${MODEL}" ]; then
19+
echo "Extracting ${MODEL} ..."
20+
unzip -qo ${MODEL_DIR}/${MODEL_ZIP} -d ${MODEL_DIR} \
21+
|| { echo "ERROR: Failed to extract ${MODEL_ZIP}"; exit 1; }
22+
23+
echo "OK"
24+
25+
else
26+
echo "${MODEL} already downloaded."
27+
fi

PyTorch/SpeechRecognition/QuartzNet/scripts/inference.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
: ${DATA_DIR:=${1:-"/datasets/LibriSpeech"}}
1818
: ${MODEL_CONFIG:=${2:-"configs/quartznet15x5_speedp-online-1.15_speca.yaml"}}
1919
: ${OUTPUT_DIR:=${3:-"/results"}}
20-
: ${CHECKPOINT:=${4:-"/checkpoints/quartznet_fp16.pt"}}
20+
: ${CHECKPOINT:=${4:-"pretrained_models/quartznet/nvidia_quartznet_210504.pt"}}
2121
: ${DATASET:="test-other"}
2222
: ${LOG_FILE:=""}
2323
: ${CUDNN_BENCHMARK:=false}

0 commit comments

Comments
 (0)