Skip to content

Commit

Permalink
mxnet-ssd done
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Dec 3, 2018
1 parent ed2a24c commit 65be036
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/layer/detectionoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,14 @@ int DetectionOutput::forward(const std::vector<Mat>& bottom_blobs, std::vector<M
const Mat& confidence = bottom_blobs[1];
const Mat& priorbox = bottom_blobs[2];

const int num_prior = priorbox.w / 4;
bool mxnet_ssd_style = priorbox.dims == 2;

// mxnet-ssd _contrib_MultiBoxDetection
const int num_prior = mxnet_ssd_style ? priorbox.h : priorbox.w / 4;

int num_class_copy = num_class;
if (num_class_copy == -233)
num_class_copy = priorbox.w / num_prior;
num_class_copy = confidence.h;

// apply location with priorbox
Mat bboxes;
Expand Down Expand Up @@ -209,7 +212,10 @@ int DetectionOutput::forward(const std::vector<Mat>& bottom_blobs, std::vector<M

for (int j = 0; j < num_prior; j++)
{
float score = confidence[j * num_class_copy + i];
// prob data layout
// caffe-ssd = num_class x num_prior
// mxnet-ssd = num_prior x num_class
float score = mxnet_ssd_style ? confidence[i * num_prior + j] : confidence[j * num_class_copy + i];

if (score > confidence_threshold)
{
Expand Down
2 changes: 0 additions & 2 deletions src/layer/priorbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ int PriorBox::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& to
if (bottom_blobs.size() == 1 && image_width == -233 && image_height == -233 && max_sizes.empty())
{
// mxnet style _contrib_MultiBoxPrior
fprintf(stderr, "mxnet style _contrib_MultiBoxPrior\n");

float step_w = step_width;
float step_h = step_height;
if (step_w == -233)
Expand Down

0 comments on commit 65be036

Please sign in to comment.