// Protocol buffer for configuring DELF feature extraction.

syntax = "proto2";

package delf.protos;

message DelfPcaParameters {
  // Path to PCA mean file.
  optional string mean_path = 1; // Required.

  // Path to PCA matrix file.
  optional string projection_matrix_path = 2; // Required.

  // Dimensionality of feature after PCA.
  optional int32 pca_dim = 3; // Required.

  // If whitening is to be used, this must be set to true.
  optional bool use_whitening = 4 [default = false];

  // Path to PCA variances file, used for whitening. This is used only if
  // use_whitening is set to true.
  optional string pca_variances_path = 5;
}

message DelfLocalFeatureConfig {
  // If PCA is to be used, this must be set to true.
  optional bool use_pca = 1 [default = true];

  // Target layer name for DELF model. This is used to obtain receptive field
  // parameters used for localizing features with respect to the input image.
  optional string layer_name = 2 [default = ""];

  // Intersection over union threshold for the non-max suppression (NMS)
  // operation. If two features overlap by at most this amount, both are kept.
  // Otherwise, the one with largest attention score is kept. This should be a
  // number between 0.0 (no region is selected) and 1.0 (all regions are
  // selected and NMS is not performed).
  optional float iou_threshold = 3 [default = 1.0];

  // Maximum number of features that will be selected. The features with largest
  // scores (eg, largest attention score if score_type is "Att") are the
  // selected ones.
  optional int32 max_feature_num = 4 [default = 1000];

  // Threshold to be used for feature selection: no feature with score lower
  // than this number will be selected).
  optional float score_threshold = 5 [default = 100.0];

  // PCA parameters for DELF local feature. This is used only if use_pca is
  // true.
  optional DelfPcaParameters pca_parameters = 6;
}

message DelfConfig {
  // Path to DELF model.
  optional string model_path = 1; // Required.

  // Image scales to be used.
  repeated float image_scales = 2;

  // Configuration used for DELF local features.
  optional DelfLocalFeatureConfig delf_local_config = 3;

}
