-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tool.sh
74 lines (61 loc) · 1.83 KB
/
run_tool.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
#!/bin/bash
CAFFE_ROOT="$HOME/CAFFE"
ROOT_DIR="$HOME/CF_tools"
#ROOT_DIR="./"
#dataset_dir="VOCdevkit" # or Pedestrian
#model="ssd" # or yolo
usage() { echo "Usage: $0 [-t <Train|Test|Evaluate] [-n <num classes>] [-g <Gen path (VOC0712|PedGen)>] [-m <Model (ssd|fssd|yolo)>] [-w <weight_file>] [-s <img_size>] [-u <gpu_id>] [-i <image file>] " 1>&2; exit 1; }
while getopts ":n:t:g:m:w:s:u:i:" o; do
case "${o}" in
n)
num_classes=${OPTARG}
;;
g)
gen_dir=${OPTARG}
;;
t)
type=${OPTARG}
;;
m)
model=${OPTARG}
;;
w)
weight_file=${OPTARG}
;;
s)
img_size=${OPTARG}
;;
u)
gpu_id=${OPTARG}
;;
i)
img_file=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
gen_dir_name=${gen_dir##*/}
echo $model
if [ "$model" == "ssd" ] || [ "$model" == "fssd" ]
then
LABEL_FILE=$gen_dir/ssd/label_map.txt
fi
if [ "$model" == "yolo" ]
then
LABEL_FILE=$gen_dir/yolo/label_map.txt
fi
if [ "$type" == "detect" ]
then
python $ROOT_DIR/CF_$model/${model}_detect.py --num_classes=$num_classes --gpu_id=$gpu_id --labelmap_file=$LABEL_FILE --image_resize=$img_size --model_weights=$weight_file --image_file=$img_file 2>&1
fi
if [ "$type" == "train" ]
then
python $ROOT_DIR/CF_$model/${model}_pascal.py --num_classes=$num_classes --gen_dir=$gen_dir_name --image_resize=$img_size --model_weights=$weight_file --labelmap_file=$LABEL_FILE 2>&1
fi
if [ "$type" == "evaluate" ]
then
python $ROOT_DIR/CF_$model/score_${model}_pascal.py --num_classes=$num_classes --gen_dir=$gen_dir_name --image_resize=$img_size --model_weights=$weight_file --labelmap_file=$LABEL_FILE 2>&1
fi