Skip to content

Commit afd3eff

Browse files
committed
initial support for arm_conf/loc structure change
1 parent 11ed993 commit afd3eff

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed

include/caffe/layers/detection_output_layer.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class DetectionOutputLayer : public Layer<Dtype> {
4040

4141
virtual inline const char* type() const { return "DetectionOutput"; }
4242
virtual inline int MinBottomBlobs() const { return 3; }
43-
virtual inline int MaxBottomBlobs() const { return 18; }
44-
// Note: for no concat cases, the input order is conf*6+loc*6+priorbox(*6)
43+
//virtual inline int MaxBottomBlobs() const { return 18; }
44+
// Note: for no concat cases, the input order is conf*n+loc*n+priorbox(*n) (+arm_conf*n+arm_loc*n)
4545
// and only implement for CPU now
4646
virtual inline int ExactNumTopBlobs() const { return 1; }
4747

@@ -118,6 +118,8 @@ class DetectionOutputLayer : public Layer<Dtype> {
118118
bool conf_concat_ = true;
119119
bool loc_concat_ = true;
120120
bool priorbox_concat_ = true;
121+
bool arm_conf_no_concat_;
122+
bool arm_loc_no_concat_;
121123

122124
bool ratio_permute_;
123125
bool no_permute_;
@@ -129,11 +131,12 @@ class DetectionOutputLayer : public Layer<Dtype> {
129131
int ratio5_;
130132
int nbottom_; // bottom count for conf/loc
131133
vector<int> collect_ratios_;
132-
//TFLite_Detection_Postprocess parameters
133-
bool tflite_detection_;
134-
bool tflite_use_regular_nms_;
135-
vector<float> scale_xywh_;
136-
int max_classes_per_detection_;
134+
135+
//TFLite_Detection_Postprocess parameters
136+
bool tflite_detection_;
137+
bool tflite_use_regular_nms_;
138+
vector<float> scale_xywh_;
139+
int max_classes_per_detection_;
137140
};
138141

139142
} // namespace caffe

src/caffe/layers/detection_output_layer.cpp

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ void DetectionOutputLayer<Dtype>::LayerSetUp(
2727
ratio3_ = detection_output_param.ratio3();
2828
ratio4_ = detection_output_param.ratio4();
2929
ratio5_ = detection_output_param.ratio5();
30+
arm_conf_no_concat_ = detection_output_param.arm_conf_no_concat();
31+
arm_loc_no_concat_ = detection_output_param.arm_loc_no_concat();
3032
// TFLite_Detection_PostProcess related params
3133
tflite_detection_ = detection_output_param.tflite_detection();
3234
tflite_use_regular_nms_ = detection_output_param.tflite_use_regular_nms();
@@ -139,32 +141,41 @@ void DetectionOutputLayer<Dtype>::LayerSetUp(
139141
data_transformer_->InitRand();
140142
save_file_ = detection_output_param.save_file();
141143
}
142-
if (bottom.size() < nbottom_) {
143-
conf_concat_ = true;
144-
loc_concat_ = true;
145-
priorbox_concat_ = true;
146-
} else if (bottom.size() >= nbottom_ && bottom.size() < 2 * nbottom_ + 1) {
147-
conf_concat_ = false;
148-
loc_concat_ = true;
149-
priorbox_concat_ = true;
150-
} else if ((bottom.size() >= 2 * nbottom_ + 1 &&
151-
bottom.size() < 3 * nbottom_) || nbottom_ == 1 ) {
152-
conf_concat_ = false;
153-
loc_concat_ = false;
154-
priorbox_concat_ = true;
155-
} else // ==3*nbottom_
144+
if (!arm_conf_no_concat_ && !arm_loc_no_concat_)
156145
{
157-
conf_concat_ = false;
158-
loc_concat_ = false;
159-
priorbox_concat_ = false;
160-
}
146+
if (bottom.size() < nbottom_) {
147+
conf_concat_ = true;
148+
loc_concat_ = true;
149+
priorbox_concat_ = true;
150+
} else if (bottom.size() >= nbottom_ && bottom.size() < 2 * nbottom_ + 1) {
151+
conf_concat_ = false;
152+
loc_concat_ = true;
153+
priorbox_concat_ = true;
154+
} else if ((bottom.size() >= 2 * nbottom_ + 1 &&
155+
bottom.size() < 3 * nbottom_) || nbottom_ == 1 ) {
156+
conf_concat_ = false;
157+
loc_concat_ = false;
158+
priorbox_concat_ = true;
159+
} else // ==3*nbottom_
160+
{
161+
conf_concat_ = false;
162+
loc_concat_ = false;
163+
priorbox_concat_ = false;
164+
}
161165

162-
if (conf_concat_ && loc_concat_) {
163-
bbox_preds_.ReshapeLike(*(bottom[0]));
164-
if (!share_location_) {
165-
bbox_permute_.ReshapeLike(*(bottom[0]));
166+
if (conf_concat_ && loc_concat_) {
167+
bbox_preds_.ReshapeLike(*(bottom[0]));
168+
if (!share_location_) {
169+
bbox_permute_.ReshapeLike(*(bottom[0]));
170+
}
171+
conf_permute_.ReshapeLike(*(bottom[1]));
166172
}
167-
conf_permute_.ReshapeLike(*(bottom[1]));
173+
}
174+
else if (bottom.size() == 4 * nbottom_ + 1) // only consider this situation for mapping with arm_conf/arm_loc
175+
{
176+
conf_concat_ = false;
177+
loc_concat_ = false;
178+
priorbox_concat_ = true;
168179
}
169180
}
170181

src/caffe/proto/caffe.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,8 @@ message DetectionOutputParameter {
16981698
optional bool ratio_permute = 25 [default=false];
16991699
optional bool no_permute = 32 [default=false];
17001700
optional int32 nbottom = 33 [default = 6];
1701+
optional bool arm_conf_no_concat = 38 [default = false];
1702+
optional bool arm_loc_no_concat = 39 [default = false];
17011703
optional int32 ratio0 = 26 [default = 3];
17021704
optional int32 ratio1 = 27 [default = 6];
17031705
optional int32 ratio2 = 28 [default = 6];

0 commit comments

Comments
 (0)