Caffe2 - C++ API
A deep learning, cross platform ML framework
bbox_transform_op.h
1 // Copyright 2004-present Facebook. All Rights Reserved.
2 
3 #ifndef BBOX_TRANSFORM_OP_H_
4 #define BBOX_TRANSFORM_OP_H_
5 
6 #include "caffe2/core/context.h"
7 #include "caffe2/core/logging.h"
8 #include "caffe2/core/operator.h"
9 #include "caffe2/utils/math.h"
10 
11 namespace caffe2 {
12 
13 template <typename T, class Context>
14 class BBoxTransformOp final : public Operator<Context> {
15  public:
16  BBoxTransformOp(const OperatorDef& operator_def, Workspace* ws)
17  : Operator<Context>(operator_def, ws),
18  weights_(OperatorBase::GetRepeatedArgument<T>(
19  "weights",
20  vector<T>{1.0f, 1.0f, 1.0f, 1.0f})),
21  apply_scale_(
22  OperatorBase::GetSingleArgument<bool>("apply_scale", true)),
23  correct_transform_coords_(OperatorBase::GetSingleArgument<bool>(
24  "correct_transform_coords",
25  false)) {
26  CAFFE_ENFORCE_EQ(
27  weights_.size(),
28  4,
29  "weights size " + caffe2::to_string(weights_.size()) + "must be 4.");
30  }
31  USE_OPERATOR_CONTEXT_FUNCTIONS;
32 
33  bool RunOnDevice() override;
34 
35  protected:
36  // weights [wx, wy, ww, wh] to apply to the regression target
37  vector<T> weights_;
38  // Transform the boxes to the scaled image space after applying the bbox
39  // deltas.
40  // Set to false to match the detectron code, set to true for the keypoint
41  // model and for backward compatibility
42  bool apply_scale_{true};
43  // Correct bounding box transform coordates, see bbox_transform() in boxes.py
44  // Set to true to match the detectron code, set to false for backward
45  // compatibility
46  bool correct_transform_coords_{false};
47 };
48 
49 } // namespace caffe2
50 
51 #endif // BBOX_TRANSFORM_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:63
Copyright (c) 2016-present, Facebook, Inc.