Blame view

egs/yomdle_zh/v1/local/extract_features.sh 1.12 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
  #!/bin/bash
  # Copyright   2017 Yiwen Shao
  #             2018 Ashish Arora
  
  nj=4
  cmd=run.pl
  feat_dim=40
  fliplr=false
  augment='no_aug'
  num_channels=3
  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 --num-channels $num_channels --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