calibration.proto 2.81 KB
Newer Older
pkulzc's avatar
pkulzc committed
1
2
3
4
// These protos contain the calibration parameters necessary for transforming
// a model's original detection scores or logits. The parameters result from
// fitting a calibration function on the model's outputs.

5
6
7
8
syntax = "proto2";

package object_detection.protos;

pkulzc's avatar
pkulzc committed
9
// Message wrapper for various calibration configurations.
10
11
12
message CalibrationConfig {
  oneof calibrator {
    // Class-agnostic calibration via linear interpolation (usually output from
pkulzc's avatar
pkulzc committed
13
    // isotonic regression).
14
15
    FunctionApproximation function_approximation = 1;

pkulzc's avatar
pkulzc committed
16
17
    // Per-class calibration via linear interpolation.
    ClassIdFunctionApproximations class_id_function_approximations = 2;
18

pkulzc's avatar
pkulzc committed
19
    // Class-agnostic sigmoid calibration.
20
21
    SigmoidCalibration sigmoid_calibration = 3;

pkulzc's avatar
pkulzc committed
22
23
    // Per-class sigmoid calibration.
    ClassIdSigmoidCalibrations class_id_sigmoid_calibrations = 4;
24
25
26

    // Temperature scaling calibration.
    TemperatureScalingCalibration temperature_scaling_calibration = 5;
27
28
29
30
  }
}

// Message for class-agnostic domain/range mapping for function
pkulzc's avatar
pkulzc committed
31
// approximations.
32
33
34
35
36
37
message FunctionApproximation {
  // Message mapping class labels to indices
  optional XYPairs x_y_pairs = 1;
}

// Message for class-specific domain/range mapping for function
pkulzc's avatar
pkulzc committed
38
39
40
41
// approximations.
message ClassIdFunctionApproximations {
  // Message mapping class ids to indices.
  map<int32, XYPairs> class_id_xy_pairs_map = 1;
42
43
}

pkulzc's avatar
pkulzc committed
44
// Message for class-agnostic Sigmoid Calibration.
45
46
47
48
49
message SigmoidCalibration {
  // Message mapping class index to Sigmoid Parameters
  optional SigmoidParameters sigmoid_parameters = 1;
}

pkulzc's avatar
pkulzc committed
50
51
52
53
// Message for class-specific Sigmoid Calibration.
message ClassIdSigmoidCalibrations {
  // Message mapping class index to Sigmoid Parameters.
  map<int32, SigmoidParameters> class_id_sigmoid_parameters_map = 1;
54
55
}

56
57
58
59
60
// Message for Temperature Scaling Calibration.
message TemperatureScalingCalibration {
  optional float scaler = 1;
}

pkulzc's avatar
pkulzc committed
61
62
63
64
65
66
67
68
69
70
71
72
// Description of data used to fit the calibration model. CLASS_SPECIFIC
// indicates that the calibration parameters are derived from detections
// pertaining to a single class. ALL_CLASSES indicates that parameters were
// obtained by fitting a model on detections from all classes (including the
// background class).
enum TrainingDataType {
  DATA_TYPE_UNKNOWN = 0;
  ALL_CLASSES = 1;
  CLASS_SPECIFIC = 2;
}

// Message to store a domain/range pair for function to be approximated.
73
74
75
76
77
78
message XYPairs {
  message XYPair {
    optional float x = 1;
    optional float y = 2;
  }

pkulzc's avatar
pkulzc committed
79
  // Sequence of x/y pairs for function approximation.
80
  repeated XYPair x_y_pair = 1;
pkulzc's avatar
pkulzc committed
81
82
83

  // Description of data used to fit the calibration model.
  optional TrainingDataType training_data_type = 2;
84
85
86
87
88
89
90
}

// Message defining parameters for sigmoid calibration.
message SigmoidParameters {
  optional float a = 1 [default = -1.0];
  optional float b = 2 [default = 0.0];
}