-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathb_getCocoJsonsCar.sh.example
More file actions
138 lines (120 loc) · 5.17 KB
/
b_getCocoJsonsCar.sh.example
File metadata and controls
138 lines (120 loc) · 5.17 KB
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
132
133
134
135
136
137
138
#!/bin/bash
# Script to extract COCO JSON file for each trained model
clear && clear
echo "Parameters to change"
NUMBER_FOLDER=22
NUMBER=${NUMBER_FOLDER}
EXPERIMENT=2_22car
IMAGE_DIR_CF="/home/gines/devel/images/car-fusion_val/"
IMAGE_DIR_P3="/home/gines/devel/images/pascal3d+_val/"
IMAGE_DIR_V7="/home/gines/devel/images/veri-776_val/"
echo "Common parameters to both files a_*.sh and b_*.sh"
SHARED_FOLDER=/media/posefs3b/Users/gines/openpose_train/training_results/${EXPERIMENT}/car/car_${NUMBER}/
echo " "
echo "Paths"
OPENPOSE_MODEL=CAR_${NUMBER}
OPENPOSE_MODEL_FILE_NAME=pose_iter_XXXXXX.caffemodel
OPENPOSE_FOLDER=/home/gines/Dropbox/Perceptual_Computing_Lab/openpose/openpose/
JSON_FOLDER_CF_1=${SHARED_FOLDER}scaleCF_1/
JSON_FOLDER_P3_1=${SHARED_FOLDER}scaleP3_1/
JSON_FOLDER_V7_1=${SHARED_FOLDER}scaleV7_1/
JSON_FOLDER_CF_4=${SHARED_FOLDER}scaleCF_4/
JSON_FOLDER_P3_4=${SHARED_FOLDER}scaleP3_4/
JSON_FOLDER_V7_4=${SHARED_FOLDER}scaleV7_4/
mkdir $JSON_FOLDER_CF_1
mkdir $JSON_FOLDER_P3_1
mkdir $JSON_FOLDER_V7_1
mkdir $JSON_FOLDER_CF_4
mkdir $JSON_FOLDER_P3_4
mkdir $JSON_FOLDER_V7_4
echo " "
# echo "Sleeping for 8h..."
# sleep 27000
# echo "Awaken!"
# Remove last XXXXXX.caffemodel
temporaryModel=${SHARED_FOLDER}/${OPENPOSE_MODEL_FILE_NAME}
echo "Using ${temporaryModel} as temporary model..."
echo " "
rm $temporaryModel
# Different code than a_*.sh
echo "Running OpenPose for each model"
MODEL_FOLDER=$(dirname $(dirname ${SHARED_FOLDER}))/
pwd
cd $OPENPOSE_FOLDER
# Sorted in natural order (NAT sort)
for modelPath in `ls -v ${SHARED_FOLDER}*.caffemodel`; do
# Not NAT sort
# for modelPath in ${SHARED_FOLDER}*.caffemodel; do
# temporaryModel=$(dirname ${modelPath})/${OPENPOSE_MODEL_FILE_NAME}
modelName=$(basename ${modelPath})
temporaryJsonFile=~/Desktop/temporaryJson_${EXPERIMENT}_${modelName}.json
finalJsonFileCF1=${JSON_FOLDER_CF_1}${modelName}_1.json
finalJsonFileP31=${JSON_FOLDER_P3_1}${modelName}_1.json
finalJsonFileV71=${JSON_FOLDER_V7_1}${modelName}_1.json
finalJsonFileCF4=${JSON_FOLDER_CF_4}${modelName}_4.json
finalJsonFileP34=${JSON_FOLDER_P3_4}${modelName}_4.json
finalJsonFileV74=${JSON_FOLDER_V7_4}${modelName}_4.json
echo "Processing $modelName in $EXPERIMENT"
# JSON file does exist (already created)
# if [ -f $finalJsonFileCF1 ]; then
# if [ -f $finalJsonFileCF1 ] && [ -f $finalJsonFileP31 ] && [ -f $finalJsonFileV71 ] && [ -f $finalJsonFileCF4 ]; then
if [ -f $finalJsonFileCF1 ] && [ -f $finalJsonFileP31 ] && [ -f $finalJsonFileV71 ]; then
echo "JSON file already exists!"
# JSON file does not exist
else
# Rename file to OpenPose name
mv $modelPath $temporaryModel
# 1 scale CF
if [ -f $finalJsonFileCF1 ]; then
echo "1-scale CF model already exists."
else
# Processing
./build/examples/openpose/openpose.bin \
--model_folder ${MODEL_FOLDER} --model_pose ${OPENPOSE_MODEL} --image_dir ${IMAGE_DIR_CF} \
--write_coco_json_variant 0 --write_coco_json $temporaryJsonFile --render_pose 0 --display 0 --num_gpu -1
# Move JSON after finished (so no Dropbox updating all the time)
mv $temporaryJsonFile $finalJsonFileCF1
fi
# 1 scale P3
if [ -f $finalJsonFileP31 ]; then
echo "1-scale P3 model already exists."
else
# Processing
./build/examples/openpose/openpose.bin \
--model_folder ${MODEL_FOLDER} --model_pose ${OPENPOSE_MODEL} --image_dir ${IMAGE_DIR_P3} \
--write_coco_json_variant 1 --write_coco_json $temporaryJsonFile --render_pose 0 --display 0 --num_gpu -1
# Move JSON after finished (so no Dropbox updating all the time)
mv $temporaryJsonFile $finalJsonFileP31
fi
# 1 scale V7
if [ -f $finalJsonFileV71 ]; then
echo "1-scale V7 model already exists."
else
# Processing
./build/examples/openpose/openpose.bin \
--model_folder ${MODEL_FOLDER} --model_pose ${OPENPOSE_MODEL} --image_dir ${IMAGE_DIR_V7} \
--write_coco_json_variant 2 --write_coco_json $temporaryJsonFile --render_pose 0 --display 0 --num_gpu -1
# Move JSON after finished (so no Dropbox updating all the time)
mv $temporaryJsonFile $finalJsonFileV71
fi
# # 4 scales
# if [ -f $finalJsonFileCF4 ]; then
# echo "4-scale model already exists."
# else
# # Processing
# ./build/examples/openpose/openpose.bin \
# --model_folder ${MODEL_FOLDER} --model_pose ${OPENPOSE_MODEL} --image_dir ${IMAGE_DIR_CF} \
# --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" \
# --write_coco_json_variant 0 --write_coco_json $temporaryJsonFile --render_pose 0 --display 0 --num_gpu 2
# # Move JSON after finished (so no Dropbox updating all the time)
# mv $temporaryJsonFile $finalJsonFileCF4
# fi
# Rename back to original name
mv $temporaryModel $modelPath
fi
# echo $modelPath
echo " "
done
echo " "
echo "Finished! Exiting script..."
echo " "