Blame view

egs/yomdle_korean/v1/local/extract_features.sh 1.15 KB
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  #!/bin/bash
  
  # Copyright   2017 Yiwen Shao
  #             2018 Ashish Arora
  
  # Apache 2.0
  # This script runs the make features script in parallel. 
  
  nj=4
  cmd=run.pl
  feat_dim=40
  augment='no_aug'
  fliplr=false
  echo "$0 $@"
  
  . ./cmd.sh
  . ./path.sh
  . ./utils/parse_options.sh || exit 1;
  
  data=$1
  featdir=$data/data
  scp=$data/images.scp
  logdir=$data/log
  
  mkdir -p $logdir
  mkdir -p $featdir
  
  # make $featdir an absolute pathname
  featdir=`perl -e '($dir,$pwd)= @ARGV; if($dir!~m:^/:) { $dir = "$pwd/$dir"; } print $dir; ' $featdir ${PWD}`
  
  for n in $(seq $nj); do
      split_scps="$split_scps $logdir/images.$n.scp"
  done
  
  # split images.scp
  utils/split_scp.pl $scp $split_scps || exit 1;
  
  $cmd JOB=1:$nj $logdir/extract_features.JOB.log \
    image/ocr/make_features.py $logdir/images.JOB.scp \
      --allowed_len_file_path $data/allowed_lengths.txt \
      --feat-dim $feat_dim --fliplr $fliplr --augment_type $augment \| \
      copy-feats --compress=true --compression-method=7 \
      ark:- ark,scp:$featdir/images.JOB.ark,$featdir/images.JOB.scp
  
  ## aggregates the output scp's to get feats.scp
  for n in $(seq $nj); do
    cat $featdir/images.$n.scp || exit 1;
  done > $data/feats.scp || exit 1