-
Notifications
You must be signed in to change notification settings - Fork 0
/
inference.sh
59 lines (49 loc) · 1.27 KB
/
inference.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
config=$1
ckpt=$2
coarse_dir=$3
prefix=$4
IOU_THRESH=${IOU_THRESH:-0.55}
IMG_DIR=${IMG_DIR:-'data/cityscapes/leftImg8bit/val'}
GT_JSON=${GT_JSON:-'data/cityscapes/annotations/instancesonly_filtered_gtFine_val.json'}
BPR_ROOT=${BPR_ROOT:-'.'}
GPUS=${GPUS:-4}
coarse_json=${prefix}/coarse.json
out_pkl=${prefix}/refined.pkl
out_json=${prefix}/refined.json
out_dir=${prefix}/refined
dataset_dir=${prefix}/patches
set -x
GREEN='\033[0;32m'
END='\033[0m\n'
mkdir $prefix
printf ${GREEN}"convert to json format ..."${END}
python $BPR_ROOT/tools/cityscapes2json.py \
$coarse_dir \
$GT_JSON \
$coarse_json
printf ${GREEN}"build patches dataset ..."${END}
python $BPR_ROOT/tools/split_patches.py \
$coarse_json \
$GT_JSON \
$IMG_DIR \
$dataset_dir \
--iou-thresh $IOU_THRESH
printf ${GREEN}"inference the network ..."${END}
DATA_ROOT=$dataset_dir \
bash $BPR_ROOT/tools/dist_test_float.sh \
$config \
$ckpt \
$GPUS \
--out $out_pkl
printf ${GREEN}"reassemble ..."${END}
python $BPR_ROOT/tools/merge_patches.py \
$coarse_json \
$GT_JSON \
$out_pkl \
$dataset_dir/detail_dir/val \
$out_json
printf ${GREEN}"convert to cityscape format ..."${END}
python $BPR_ROOT/tools/json2cityscapes.py \
$out_json \
$GT_JSON \
$out_dir