models : make all scripts to be POSIX Compliant (#1725)

* download-coreml-model: make it POSIX-compliant

* download-ggml-model: posix compliant (2nd)

* minor edit

* forgot to add newline

* generate-coreml-interface: far more straightforward

* generate-coreml-model: done with the posix thingy

* typo

* Update download-ggml-model.sh

* fix

* fix typo

* another fix

* Update download-coreml-model.sh

* Update download-ggml-model.sh

* Update download-coreml-model.sh
This commit is contained in:
Sơn Phan Trung
2024-01-12 19:11:04 +07:00
committed by GitHub
parent 6dcee35129
commit d05b7ee90e
4 changed files with 81 additions and 80 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Usage: ./generate-coreml-model.sh <model-name>
if [ $# -eq 0 ]; then
@ -6,7 +6,7 @@ if [ $# -eq 0 ]; then
echo "Usage for Whisper models: ./generate-coreml-model.sh <model-name>"
echo "Usage for HuggingFace models: ./generate-coreml-model.sh -h5 <model-name> <model-path>"
exit 1
elif [[ "$1" == "-h5" && $# != 3 ]]; then
elif [ "$1" = "-h5" ] && [ $# != 3 ]; then
echo "No model name and model path supplied for a HuggingFace model"
echo "Usage for HuggingFace models: ./generate-coreml-model.sh -h5 <model-name> <model-path>"
exit 1
@ -15,20 +15,20 @@ fi
mname="$1"
wd=$(dirname "$0")
cd "$wd/../"
cd "$wd/../" || exit
if [[ $mname == "-h5" ]]; then
if [ "$mname" = "-h5" ]; then
mname="$2"
mpath="$3"
echo $mpath
python3 models/convert-h5-to-coreml.py --model-name $mname --model-path $mpath --encoder-only True
echo "$mpath"
python3 models/convert-h5-to-coreml.py --model-name "$mname" --model-path "$mpath" --encoder-only True
else
python3 models/convert-whisper-to-coreml.py --model $mname --encoder-only True --optimize-ane True
python3 models/convert-whisper-to-coreml.py --model "$mname" --encoder-only True --optimize-ane True
fi
xcrun coremlc compile models/coreml-encoder-${mname}.mlpackage models/
rm -rf models/ggml-${mname}-encoder.mlmodelc
mv -v models/coreml-encoder-${mname}.mlmodelc models/ggml-${mname}-encoder.mlmodelc
xcrun coremlc compile models/coreml-encoder-"${mname}".mlpackage models/
rm -rf models/ggml-"${mname}"-encoder.mlmodelc
mv -v models/coreml-encoder-"${mname}".mlmodelc models/ggml-"${mname}"-encoder.mlmodelc
# TODO: decoder (sometime in the future maybe)
#xcrun coremlc compile models/whisper-decoder-${mname}.mlpackage models/