-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload gigaspeech zipformer models in CI (#1412)
- Loading branch information
1 parent
20a82c9
commit 9e9fe79
Showing
4 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,16 +26,80 @@ git lfs pull --include "data/lang_bpe_500/bpe.model" | |
git lfs pull --include "data/lang_bpe_500/tokens.txt" | ||
git lfs pull --include "exp/jit_script.pt" | ||
git lfs pull --include "exp/pretrained.pt" | ||
ln -s pretrained.pt epoch-99.pt | ||
ls -lh *.pt | ||
rm epoch-30.pt | ||
ln -s pretrained.pt epoch-30.pt | ||
rm *.onnx | ||
ls -lh | ||
popd | ||
|
||
log "----------------------------------------" | ||
log "Export ONNX transducer models " | ||
log "----------------------------------------" | ||
|
||
./zipformer/export-onnx.py \ | ||
--tokens $repo/data/lang_bpe_500/tokens.txt \ | ||
--use-averaged-model 0 \ | ||
--epoch 30 \ | ||
--avg 1 \ | ||
--exp-dir $repo/exp | ||
|
||
ls -lh $repo/exp | ||
|
||
log "------------------------------------------------------------" | ||
log "Test exported ONNX transducer models (Python code) " | ||
log "------------------------------------------------------------" | ||
|
||
log "test fp32" | ||
./zipformer/onnx_pretrained.py \ | ||
--encoder-model-filename $repo/exp/encoder-epoch-30-avg-1.onnx \ | ||
--decoder-model-filename $repo/exp/decoder-epoch-30-avg-1.onnx \ | ||
--joiner-model-filename $repo/exp/joiner-epoch-30-avg-1.onnx \ | ||
--tokens $repo/data/lang_bpe_500/tokens.txt \ | ||
$repo/test_wavs/1089-134686-0001.wav \ | ||
$repo/test_wavs/1221-135766-0001.wav \ | ||
$repo/test_wavs/1221-135766-0002.wav | ||
|
||
log "test int8" | ||
./zipformer/onnx_pretrained.py \ | ||
--encoder-model-filename $repo/exp/encoder-epoch-30-avg-1.int8.onnx \ | ||
--decoder-model-filename $repo/exp/decoder-epoch-30-avg-1.onnx \ | ||
--joiner-model-filename $repo/exp/joiner-epoch-30-avg-1.int8.onnx \ | ||
--tokens $repo/data/lang_bpe_500/tokens.txt \ | ||
$repo/test_wavs/1089-134686-0001.wav \ | ||
$repo/test_wavs/1221-135766-0001.wav \ | ||
$repo/test_wavs/1221-135766-0002.wav | ||
|
||
log "Upload models to huggingface" | ||
git config --global user.name "k2-fsa" | ||
git config --global user.email "[email protected]" | ||
|
||
url=https://huggingface.co/k2-fsa/sherpa-onnx-zipformer-gigaspeech-2023-12-12 | ||
GIT_LFS_SKIP_SMUDGE=1 git clone $url | ||
dst=$(basename $url) | ||
cp -v $repo/exp/*.onnx $dst | ||
cp -v $repo/data/lang_bpe_500/tokens.txt $dst | ||
cp -v $repo/data/lang_bpe_500/bpe.model $dst | ||
mkdir -p $dst/test_wavs | ||
cp -v $repo/test_wavs/*.wav $dst/test_wavs | ||
cd $dst | ||
git lfs track "*.onnx" | ||
git add . | ||
git commit -m "upload model" && git push https://k2-fsa:${HF_TOKEN}@huggingface.co/k2-fsa/$dst main || true | ||
|
||
log "Upload models to https://github.com/k2-fsa/sherpa-onnx" | ||
rm -rf .git | ||
rm -fv .gitattributes | ||
cd .. | ||
tar cjfv $dst.tar.bz2 $dst | ||
ls -lh | ||
mv -v $dst.tar.bz2 ../../../ | ||
|
||
log "Export to torchscript model" | ||
./zipformer/export.py \ | ||
--exp-dir $repo/exp \ | ||
--use-averaged-model false \ | ||
--tokens $repo/data/lang_bpe_500/tokens.txt \ | ||
--epoch 99 \ | ||
--epoch 30 \ | ||
--avg 1 \ | ||
--jit 1 | ||
|
||
|
@@ -67,7 +131,7 @@ echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" | |
echo "GITHUB_EVENT_LABEL_NAME: ${GITHUB_EVENT_LABEL_NAME}" | ||
if [[ x"${GITHUB_EVENT_NAME}" == x"schedule" || x"${GITHUB_EVENT_LABEL_NAME}" == x"run-decode" ]]; then | ||
mkdir -p zipformer/exp | ||
ln -s $PWD/$repo/exp/pretrained.pt zipformer/exp/epoch-999.pt | ||
ln -s $PWD/$repo/exp/pretrained.pt zipformer/exp/epoch-30.pt | ||
ln -s $PWD/$repo/data/lang_bpe_500 data/ | ||
|
||
ls -lh data | ||
|
@@ -83,7 +147,7 @@ if [[ x"${GITHUB_EVENT_NAME}" == x"schedule" || x"${GITHUB_EVENT_LABEL_NAME}" == | |
|
||
./zipformer/decode.py \ | ||
--decoding-method $method \ | ||
--epoch 999 \ | ||
--epoch 30 \ | ||
--avg 1 \ | ||
--use-averaged-model 0 \ | ||
--max-duration $max_duration \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters