Skip to content

Commit

Permalink
Merge pull request #48 from lissyx/xz-pkg
Browse files Browse the repository at this point in the history
Use xz to package to reduce size
  • Loading branch information
lissyx authored Jun 12, 2019
2 parents c9bf8b3 + 6a52725 commit 655643e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DeepSpeech/Dockerfile.train.fr
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends \
sox \
libsox-fmt-all \
locales locales-all \
zip
xz-utils

RUN groupadd -g 999 trainer && \
adduser --system --uid 999 --group trainer
Expand Down
48 changes: 26 additions & 22 deletions DeepSpeech/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@
set -xe

pushd /mnt
zip -r9 --junk-paths \
model_tensorflow_fr.zip \
models/output_graph.pbmm \
models/alphabet.txt \
lm/lm.binary \
lm/trie

zip -r9 --junk-paths \
model_tflite_fr.zip \
models/output_graph.tflite \
models/alphabet.txt \
lm/lm.binary \
lm/trie

all_checkpoint_path=""
for ckpt in $(grep 'all_model_checkpoint_paths' checkpoints/checkpoint | cut -d'"' -f2);
do
all_checkpoint_path="${all_checkpoint_path} ${ckpt}.*"
done;
if [ ! -f "model_tensorflow_fr.tar.xz" ]; then
tar -cf - \
-C /mnt/models/ output_graph.pbmm alphabet.txt \
-C /mnt/lm/ lm.binary trie | xz -T0 > model_tensorflow_fr.tar.xz
fi;

zip -r9 --junk-paths \
checkpoint_fr.zip \
checkpoints/checkpoint \
${all_checkpoint_path}
if [ ! -f "model_tflite_fr.tar.xz" ]; then
tar -cf - \
-C /mnt/models/ output_graph.tflite alphabet.txt \
-C /mnt/lm/ lm.binary trie | xz -T0 > model_tflite_fr.tar.xz
fi;

if [ ! -f "checkpoint_fr.tar.xz" ]; then
all_checkpoint_path=""
for ckpt in $(grep '^model_checkpoint_path:' checkpoints/checkpoint | cut -d'"' -f2);
do
ckpt_file=$(basename "${ckpt}")
for f in $(find checkpoints/ -type f -name "${ckpt_file}.*");
do
ckpt_to_add=$(basename "${f}")
all_checkpoint_path="${all_checkpoint_path} ${ckpt_to_add}"
done;
done;

tar -cf - \
-C /mnt/checkpoints/ checkpoint ${all_checkpoint_path} | xz -T0 > "checkpoint_fr.tar.xz"
fi;
popd

0 comments on commit 655643e

Please sign in to comment.