-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextract_image_features.sh
98 lines (80 loc) · 2.24 KB
/
extract_image_features.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
#!/bin/bash
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -p gpu
#SBATCH -t 01:00:00
#SBATCH -J gpu_job
#SBATCH --gres=gpu:p100:1
#SBATCH --mem-per-cpu=32000
#SBATCH
date
printf "\n"
environment=$1
images_location=$2
features_location=$3
resized=$4
if [ -z "$1" ]; then
echo "environment not specified, exiting now!"
exit 0
fi
if [[ ${environment} = *"triton"* ]]; then
echo "setting things for Triton!"
module purge
module load anaconda3/5.1.0-gpu CUDA/9.0.176 cuDNN/6.0-CUDA-8.0.61
if [ -z "$2" ]; then
echo "No images location, defaulting to COCO train-2014 images"
images_location="/scratch/cs/imagedb/picsom/databases/COCO/download/images/train2014"
fi
elif [[ ${environment} = *"taito"* ]]; then
echo "setting things for Taito!"
module load intelconda/python3.6-2018.3
cd /proj/memad/COCO/image_captioning/
if [ -z "$2" ]; then
echo "No images location, defaulting to COCO train-2014 images"
images_location="/proj/memad/COCO/train2014"
fi
elif [[ ${environment} = *"MacbookPro"* ]]; then
echo "testing locally :)"
if [ -z "$2" ]; then
echo "No images location, defaulting to some imageset"
images_location="~/images/train"
fi
else
echo "haunted house, getting outta here!"
exit 0
fi
echo "Images location: $images_location"
if [ -z "$3" ]; then
${features_location}="./features/"
fi
if [ ! -d "$features_location" ]; then
echo "creating output directory"
mkdir ${features_location}
fi
echo "Features location: $features_location"
if [ -z "$4" ]; then
echo "Images will be resized"
srun python resize.py --image_dir ${images_location} --output_dir "./resized_temp" --image_size 224
OUT=$?
if [ ${OUT} -eq 0 ];then
echo "end: resizing complete"
images_location="./resized_temp/"
else
echo "something broke: resizing"
exit 42
fi
else
echo "Image resizing will be skipped"
fi
srun python feature_extractor.py --image_dir ${images_location} --output_dir ${features_location}
OUT=$?
if [ ${OUT} -eq 0 ];then
echo "end: feature extraction complete"
else
echo "something broke: extracting features"
exit 42
fi
# optional (could be modified to move elsewhere)
rm -rf ./resized_temp/
printf "\n"
date