forked from nii-yamagishilab/project-NN-Pytorch-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_demo.sh
131 lines (114 loc) · 3.49 KB
/
00_demo.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
########################
# Script for demontration
#
# Usage: bash 00_demo.sh PATH CONFIG RAND_SEED
# where
# PATH can be model-LFCC-LLGF
# or other model-* folders
# CONFIG can be config_train_toyset
# if you prepare other config, you can use them as well
# RAND_SEED can be 01, 02 or any other numbers
#
# This script will
# 1. install pytorch env using conda
# 2. untar data set (toy_dataset)
# 3. run training and scoring
#
# This script will use the data set in DATA/
#
# If GPU memory is less than 16GB, please reduce
# --batch-size in 01_train.sh
#
########################
RED='\033[0;32m'
NC='\033[0m'
PRJDIR=$1
CONFIG=$2
RAND_SEED=$3
#####
# configurations (no need to change)
link_set=https://zenodo.org/record/6456704/files/project-04-toy_example.tar.gz
set_name=project-04-toy_example.tar.gz
link_pretrained=https://zenodo.org/record/6456692/files/project-07-asvspoof-ssl.tar
model_name=project-07-asvspoof-ssl.tar
score_script=02_score.sh
train_script=01_train.sh
main_script=main.py
condafile=$PWD/../../env-fs-install.sh
envfile=$PWD/../../env-fs.sh
pretrained_model=__pretrained/trained_network.pt
trained_model=./trained_network.pt
# we will use this toy data set for demonstration
configs_name=${CONFIG}
PRJDIR=${PRJDIR}/${CONFIG}
#####
# check
SUBDIR=${RAND_SEED}
if [ ! -d ${PRJDIR}/${SUBDIR} ];
then
mkdir -p ${PRJDIR}/${SUBDIR}
fi
#####
# step 1
echo -e "\n${RED}=======================================================${NC}"
echo -e "${RED}Step1. load conda environment${NC}"
# create conda environment
bash ${condafile} || exit 1;
# load env.sh. It must be loaded inside a sub-folder $PWD/../../../env.sh
# otherwise, please follow env.sh and manually load the conda environment and
# add PYTHONPATH
cd DATA
source ${envfile} || exit 1;
cd ../
#####
# step 2 download
echo -e "\n${RED}=======================================================${NC}"
echo -e "${RED}Step2. download and untar the data set, pre-trained model${NC}"
cd DATA
if [ ! -e ${set_name} ];
then
echo -e "\nDownloading toy data set"
wget -q --show-progress ${link_set}
tar -xzf ${set_name}
fi
if [ ! -d asvspoof2019_LA ];
then
echo -e "\nCopy place holder for ASVspoof 2019 LA"
cp -rP ../../03-asvspoof-mega/DATA/asvspoof2019_LA/ ./
fi
cd ..
if [ ! -e ${model_name} ];
then
echo -e "\nDowloading pre-trained model"
wget -q --show-progress ${link_pretrained}
tar -xf ${model_name}
fi
echo -e "\nDowloading pre-trained SSL models"
bash 01_download_ssl.sh
#####
# step 3 training
echo -e "\n${RED}=======================================================${NC}"
echo -e "${RED}Step3. training using ${CONFIG} ${NC}"
com="bash ${train_script} ${RAND_SEED} ${CONFIG} ${PRJDIR}/${SUBDIR}"
echo ${com}
eval ${com}
#####
# step 4 inference
echo -e "\n${RED}=======================================================${NC}"
echo -e "${RED}Step4. scoring using the toy set${NC}"
com="bash ${score_script} $PWD/DATA/toy_example/eval toy_eval_set
$PWD/${PRJDIR}/${SUBDIR} $PWD/${PRJDIR}/${SUBDIR}/${trained_model}
trained"
echo ${com}
eval ${com}
#####
# step 5 inference
echo -e "\n${RED}=======================================================${NC}"
echo -e "${RED}Step5. scoring using the toy set and models trained by author${NC}"
com="bash ${score_script} $PWD/DATA/toy_example/eval toy_eval_set
$PWD/${PRJDIR}/../config_train_asvspoof2019/01
$PWD/${PRJDIR}/../config_train_asvspoof2019/01/__pretrained/${trained_model}
pretrained"
echo ${com}
eval ${com}