chromium/third_party/mediapipe/src/mediapipe/calculators/tflite/ssd_anchors_calculator.proto

// Copyright 2019 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto2";

package mediapipe;

import "mediapipe/framework/calculator.proto";
import "mediapipe/framework/formats/object_detection/anchor.proto";

// Options to generate anchors for SSD object detection models.
message SsdAnchorsCalculatorOptions {
  extend mediapipe.CalculatorOptions {
    optional SsdAnchorsCalculatorOptions ext = 247258239;
  }
  // Size of input images.
  optional int32 input_size_width = 1;   // required for generating anchors.
  optional int32 input_size_height = 2;  // required for generating anchros.

  // Min and max scales for generating anchor boxes on feature maps.
  optional float min_scale = 3;  // required for generating anchors.
  optional float max_scale = 4;  // required for generating anchors.

  // The offset for the center of anchors. The value is in the scale of stride.
  // E.g. 0.5 meaning 0.5 * |current_stride| in pixels.
  optional float anchor_offset_x = 5
      [default = 0.5];  // required for generating anchors.
  optional float anchor_offset_y = 6
      [default = 0.5];  // required for generating anchors.

  // Number of output feature maps to generate the anchors on.
  optional int32 num_layers = 7;  // required for generating anchors.
  // Sizes of output feature maps to create anchors. Either feature_map size or
  // stride should be provided.
  repeated int32 feature_map_width = 8;
  repeated int32 feature_map_height = 9;
  // Strides of each output feature maps.
  repeated int32 strides = 10;

  // List of different aspect ratio to generate anchors.
  repeated float aspect_ratios = 11;

  // A boolean to indicate whether the fixed 3 boxes per location is used in the
  // lowest layer.
  optional bool reduce_boxes_in_lowest_layer = 12 [default = false];
  // An additional anchor is added with this aspect ratio and a scale
  // interpolated between the scale for a layer and the scale for the next layer
  // (1.0 for the last layer). This anchor is not included if this value is 0.
  optional float interpolated_scale_aspect_ratio = 13 [default = 1.0];

  // Whether use fixed width and height (e.g. both 1.0f) for each anchor.
  // This option can be used when the predicted anchor width and height are in
  // pixels.
  optional bool fixed_anchor_size = 14 [default = false];

  // Generates grid anchors on the fly corresponding to multiple CNN layers as
  // described in:
  // "Focal Loss for Dense Object Detection" (https://arxiv.org/abs/1708.02002)
  //  T.-Y. Lin, P. Goyal, R. Girshick, K. He, P. Dollar
  optional bool multiscale_anchor_generation = 15 [default = false];

  // minimum level in feature pyramid
  // for multiscale_anchor_generation only!
  optional int32 min_level = 16 [default = 3];

  // maximum level in feature pyramid
  // for multiscale_anchor_generation only!
  optional int32 max_level = 17 [default = 7];

  // Scale of anchor to feature stride
  // for multiscale_anchor_generation only!
  optional float anchor_scale = 18 [default = 4.0];

  // Number of intermediate scale each scale octave
  // for multiscale_anchor_generation only!
  optional int32 scales_per_octave = 19 [default = 2];

  // Whether to produce anchors in normalized coordinates.
  // for multiscale_anchor_generation only!
  optional bool normalize_coordinates = 20 [default = true];

  // Fixed list of anchors. If set, all the other options to generate anchors
  // are ignored.
  repeated Anchor fixed_anchors = 21;
}