diff options
author | Manu Mathew | 2018-06-05 08:43:21 -0500 |
---|---|---|
committer | Manu Mathew | 2018-06-05 08:43:21 -0500 |
commit | 849cd1682216da6b24a6beb6a41e3e91fa617325 (patch) | |
tree | c4d7e9449bbc238f194428740ac31aa08f4f2c46 | |
parent | 2f225e3ca49520e4db9ad5dcfb39454155e53d7b (diff) | |
download | caffe-jacinto-models-849cd1682216da6b24a6beb6a41e3e91fa617325.tar.gz caffe-jacinto-models-849cd1682216da6b24a6beb6a41e3e91fa617325.tar.xz caffe-jacinto-models-849cd1682216da6b24a6beb6a41e3e91fa617325.zip |
Adding MobilenetV2
-rw-r--r-- | scripts/models/image_classification.py | 4 | ||||
-rwxr-xr-x | scripts/train_cifar10_mobilenet_classification.sh | 2 | ||||
-rwxr-xr-x | scripts/train_mobilenet_classification.sh | 117 |
3 files changed, 50 insertions, 73 deletions
diff --git a/scripts/models/image_classification.py b/scripts/models/image_classification.py index bfa24ee..160d0de 100644 --- a/scripts/models/image_classification.py +++ b/scripts/models/image_classification.py | |||
@@ -63,8 +63,8 @@ def main(): | |||
63 | config_param.image_width = 224 | 63 | config_param.image_width = 224 |
64 | config_param.image_height = 224 | 64 | config_param.image_height = 224 |
65 | 65 | ||
66 | config_param.train_data = "/user/a0875091/files/data/datasets/object-detect/other/ilsvrc/2012/lmdb/size256/ilsvrc12_train_lmdb" | 66 | config_param.train_data = "/data/hdd/datasets/object-detect/other/ilsvrc/2012/lmdb/size256/ilsvrc12_train_lmdb" |
67 | config_param.test_data = "/user/a0875091/files/data/datasets/object-detect/other/ilsvrc/2012/lmdb/size256/ilsvrc12_val_lmdb" | 67 | config_param.test_data = "/data/hdd/datasets/object-detect/other/ilsvrc/2012/lmdb/size256/ilsvrc12_val_lmdb" |
68 | 68 | ||
69 | config_param.stride_list = [2,2,2,2,2] | 69 | config_param.stride_list = [2,2,2,2,2] |
70 | config_param.dilation_list = [1,1,1,1,1] | 70 | config_param.dilation_list = [1,1,1,1,1] |
diff --git a/scripts/train_cifar10_mobilenet_classification.sh b/scripts/train_cifar10_mobilenet_classification.sh index 2315455..84a9346 100755 --- a/scripts/train_cifar10_mobilenet_classification.sh +++ b/scripts/train_cifar10_mobilenet_classification.sh | |||
@@ -8,7 +8,7 @@ DATE_TIME=`date +'%Y-%m-%d_%H-%M-%S'` | |||
8 | gpus="0,1,2" #IMPORTANT: change this to "0" if you have only one GPU | 8 | gpus="0,1,2" #IMPORTANT: change this to "0" if you have only one GPU |
9 | 9 | ||
10 | #------------------------------------------------------- | 10 | #------------------------------------------------------- |
11 | model_name=mobilenetv2-1.0 #mobilenet-1.0 #mobileresnet-1.0 #jacintonet11v2 | 11 | model_name=mobilenet-1.0 #mobilenet-1.0 #mobileresnet-1.0 #jacintonet11v2 |
12 | dataset=cifar10 | 12 | dataset=cifar10 |
13 | folder_name=training/"$dataset"_"$model_name"_"$DATE_TIME";mkdir $folder_name | 13 | folder_name=training/"$dataset"_"$model_name"_"$DATE_TIME";mkdir $folder_name |
14 | 14 | ||
diff --git a/scripts/train_mobilenet_classification.sh b/scripts/train_mobilenet_classification.sh index dc7cfd3..a89d5e3 100755 --- a/scripts/train_mobilenet_classification.sh +++ b/scripts/train_mobilenet_classification.sh | |||
@@ -8,7 +8,7 @@ DATE_TIME=`date +'%Y-%m-%d_%H-%M-%S'` | |||
8 | gpus="0,1" #IMPORTANT: change this to "0" if you have only one GPU | 8 | gpus="0,1" #IMPORTANT: change this to "0" if you have only one GPU |
9 | 9 | ||
10 | #------------------------------------------------------- | 10 | #------------------------------------------------------- |
11 | model_name=mobilenet-0.5 #mobilenet-1.0 | 11 | model_name=mobilenet-1.0 #mobilenet-0.5 #mobilenet-1.0 |
12 | dataset=imagenet | 12 | dataset=imagenet |
13 | folder_name=training/"$dataset"_"$model_name"_"$DATE_TIME";mkdir $folder_name | 13 | folder_name=training/"$dataset"_"$model_name"_"$DATE_TIME";mkdir $folder_name |
14 | 14 | ||
@@ -54,77 +54,54 @@ python ./models/image_classification.py --config_param="$config_param" --solver_ | |||
54 | echo "python cmd completed" | 54 | echo "python cmd completed" |
55 | config_name_prev=$config_name | 55 | config_name_prev=$config_name |
56 | 56 | ||
57 | |||
58 | |||
57 | #------------------------------------------------------- | 59 | #------------------------------------------------------- |
58 | #incremental sparsification and finetuning | 60 | #test |
59 | #stage="sparse" | 61 | stage="test" |
60 | #Using more than one GPU for this step gives strange results. Imbalanced accuracy between the GPUs. | 62 | weights=$config_name_prev/"$dataset"_"$model_name"_iter_$max_iter.caffemodel |
61 | #gpus="0" #"0,1,2" | 63 | |
62 | #weights=$config_name_prev/"$dataset"_"$model_name"_iter_$max_iter.caffemodel | 64 | test_solver_param="{'type':'$type','base_lr':$base_lr,'max_iter':$max_iter,\ |
63 | # | 65 | 'regularization_type':'L1','weight_decay':1e-5,\ |
64 | #max_iter=160000 #320000 | 66 | 'sparse_mode':1,'display_sparsity':1000}" |
65 | #type=SGD | 67 | |
66 | #base_lr=0.01 #use a lower lr for fine tuning | 68 | config_name="$folder_name"/$stage; echo $config_name; mkdir $config_name |
67 | #sparsity_start_iter=20000 | 69 | config_param="{'config_name':'$config_name','model_name':'$model_name','dataset':'$dataset','gpus':'$gpus','batch_size':$batch_size,\ |
68 | #sparse_solver_param="{'type':'$type','base_lr':$base_lr,'max_iter':$max_iter,\ | 70 | 'pretrain_model':'$weights','mean_value':0,'train_transform_param':$train_transform_param,'test_transform_param':$test_transform_param,\ |
69 | #'regularization_type':'L1','weight_decay':1e-5,\ | 71 | 'num_output':1000,'image_width':224,'image_height':224,'crop_size':224,\ |
70 | #'sparse_mode':1,'display_sparsity':1000,\ | 72 | 'caffe':'$caffe test'}" |
71 | #'sparsity_target':0.8,'sparsity_start_iter':$sparsity_start_iter,'sparsity_start_factor':0.0,\ | 73 | |
72 | #'sparsity_step_iter':1000,'sparsity_step_factor':0.01}" | 74 | python ./models/image_classification.py --config_param="$config_param" --solver_param=$test_solver_param |
73 | # | ||
74 | #config_name="$folder_name"/$stage; echo $config_name; mkdir $config_name | ||
75 | #config_param="{'config_name':'$config_name','model_name':'$model_name','dataset':'$dataset','gpus':'$gpus','batch_size':$batch_size,\ | ||
76 | #'pretrain_model':'$weights','mean_value':0,'train_transform_param':$train_transform_param,'test_transform_param':$test_transform_param}" | ||
77 | #python ./models/image_classification.py --config_param="$config_param" --solver_param=$sparse_solver_param | ||
78 | #config_name_prev=$config_name | 75 | #config_name_prev=$config_name |
79 | # | 76 | |
80 | # | 77 | |
81 | ##------------------------------------------------------- | 78 | #------------------------------------------------------- |
82 | ##test | 79 | #test_quantize |
83 | #stage="test" | 80 | stage="test_quantize" |
84 | #weights=$config_name_prev/"$dataset"_"$model_name"_iter_$max_iter.caffemodel | 81 | weights=$config_name_prev/"$dataset"_"$model_name"_iter_$max_iter.caffemodel |
85 | # | 82 | |
86 | #test_solver_param="{'type':'$type','base_lr':$base_lr,'max_iter':$max_iter,\ | 83 | test_solver_param="{'type':'$type','base_lr':$base_lr,'max_iter':$max_iter,\ |
87 | #'regularization_type':'L1','weight_decay':1e-5,\ | 84 | 'regularization_type':'L1','weight_decay':1e-5,\ |
88 | #'sparse_mode':1,'display_sparsity':1000}" | 85 | 'sparse_mode':1,'display_sparsity':1000}" |
89 | # | 86 | |
90 | #config_name="$folder_name"/$stage; echo $config_name; mkdir $config_name | 87 | config_name="$folder_name"/$stage; echo $config_name; mkdir $config_name |
91 | #config_param="{'config_name':'$config_name','model_name':'$model_name','dataset':'$dataset','gpus':'$gpus','batch_size':$batch_size,\ | 88 | config_param="{'config_name':'$config_name','model_name':'$model_name','dataset':'$dataset','gpus':'$gpus','batch_size':$batch_size,\ |
92 | #'pretrain_model':'$weights','mean_value':0,'train_transform_param':$train_transform_param,'test_transform_param':$test_transform_param,\ | 89 | 'pretrain_model':'$weights','mean_value':0,'train_transform_param':$train_transform_param,'test_transform_param':$test_transform_param,\ |
93 | #'num_output':1000,'image_width':224,'image_height':224,'crop_size':224,\ | 90 | 'num_output':1000,'image_width':224,'image_height':224,'crop_size':224,\ |
94 | #'caffe':'$caffe test'}" | 91 | 'caffe':'$caffe test'}" |
95 | # | 92 | |
96 | #python ./models/image_classification.py --config_param="$config_param" --solver_param=$test_solver_param | 93 | python ./models/image_classification.py --config_param="$config_param" --solver_param=$test_solver_param |
97 | ##config_name_prev=$config_name | 94 | |
98 | # | 95 | echo "quantize: true" > $config_name/deploy_new.prototxt |
99 | # | 96 | cat $config_name/deploy.prototxt >> $config_name/deploy_new.prototxt |
100 | ##------------------------------------------------------- | 97 | mv --force $config_name/deploy_new.prototxt $config_name/deploy.prototxt |
101 | ##test_quantize | 98 | |
102 | #stage="test_quantize" | 99 | echo "quantize: true" > $config_name/test_new.prototxt |
103 | #weights=$config_name_prev/"$dataset"_"$model_name"_iter_$max_iter.caffemodel | 100 | cat $config_name/test.prototxt >> $config_name/test_new.prototxt |
104 | # | 101 | mv --force $config_name/test_new.prototxt $config_name/test.prototxt |
105 | #test_solver_param="{'type':'$type','base_lr':$base_lr,'max_iter':$max_iter,\ | 102 | #config_name_prev=$config_name |
106 | #'regularization_type':'L1','weight_decay':1e-5,\ | 103 | |
107 | #'sparse_mode':1,'display_sparsity':1000}" | 104 | |
108 | # | ||
109 | #config_name="$folder_name"/$stage; echo $config_name; mkdir $config_name | ||
110 | #config_param="{'config_name':'$config_name','model_name':'$model_name','dataset':'$dataset','gpus':'$gpus','batch_size':$batch_size,\ | ||
111 | #'pretrain_model':'$weights','mean_value':0,'train_transform_param':$train_transform_param,'test_transform_param':$test_transform_param,\ | ||
112 | #'num_output':1000,'image_width':224,'image_height':224,'crop_size':224,\ | ||
113 | #'caffe':'$caffe test'}" | ||
114 | # | ||
115 | #python ./models/image_classification.py --config_param="$config_param" --solver_param=$test_solver_param | ||
116 | # | ||
117 | #echo "quantize: true" > $config_name/deploy_new.prototxt | ||
118 | #cat $config_name/deploy.prototxt >> $config_name/deploy_new.prototxt | ||
119 | #mv --force $config_name/deploy_new.prototxt $config_name/deploy.prototxt | ||
120 | # | ||
121 | #echo "quantize: true" > $config_name/test_new.prototxt | ||
122 | #cat $config_name/test.prototxt >> $config_name/test_new.prototxt | ||
123 | #mv --force $config_name/test_new.prototxt $config_name/test.prototxt | ||
124 | # | ||
125 | ##config_name_prev=$config_name | ||
126 | # | ||
127 | # | ||
128 | ##------------------------------------------------------- | 105 | ##------------------------------------------------------- |
129 | #run | 106 | #run |
130 | list_dirs=`command ls -d1 "$folder_name"/*/ | command cut -f3 -d/` | 107 | list_dirs=`command ls -d1 "$folder_name"/*/ | command cut -f3 -d/` |