1/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14==============================================================================*/ 15 16syntax = "proto2"; 17 18package tflite.evaluation; 19 20option cc_enable_arenas = true; 21option java_multiple_files = true; 22option java_package = "tflite.evaluation"; 23 24// Defines the preprocesing steps available. 25// 26// Next ID: 5 27message ImagePreprocessingStepParams { 28 oneof params { 29 CroppingParams cropping_params = 1; 30 ResizingParams resizing_params = 2; 31 PaddingParams padding_params = 3; 32 NormalizationParams normalization_params = 4; 33 } 34} 35 36// Defines the size of an image. 37// 38// Next ID: 3 39message ImageSize { 40 // Width of the image. 41 required uint32 width = 1; 42 // Height of the image. 43 required uint32 height = 2; 44} 45 46// Defines parameters for central-cropping. 47// 48// Next ID: 4 49message CroppingParams { 50 oneof params { 51 // Fraction for central-cropping. 52 // A central cropping-fraction of 0.875 is considered best for Inception 53 // models, hence the default value. See: 54 // https://github.com/tensorflow/tpu/blob/master/models/experimental/inception/inception_preprocessing.py#L296 55 // Set to 0 to disable cropping. 56 float cropping_fraction = 1 [default = 0.875]; 57 // The target size after cropping. 58 ImageSize target_size = 2; 59 } 60 // Crops to a square image. 61 optional bool square_cropping = 3; 62} 63 64// Defines parameters for bilinear central-resizing. 65// 66// Next ID: 3 67message ResizingParams { 68 // Size of the image after resizing. 69 required ImageSize target_size = 1; 70 // If this flag is true, the resize function will preserve the image's aspect 71 // ratio. Note that in this case, the size of output image may not equal to 72 // the target size defined above. 73 required bool aspect_preserving = 2; 74} 75 76// Defines parameters for central-padding. 77// 78// Next ID: 4 79message PaddingParams { 80 oneof params { 81 // Size of the image after padding. 82 ImageSize target_size = 1; 83 // Pads to a square image. 84 bool square_padding = 2; 85 } 86 // Padding value. 87 required int32 padding_value = 3; 88} 89 90// Defines parameters for normalization. 91// The normalization formula is: output = (input - mean) * scale. 92// 93// Next ID: 4 94message NormalizationParams { 95 message PerChannelMeanValues { 96 // The mean values of r channel. 97 required float r_mean = 1; 98 // The mean values of g channel. 99 required float g_mean = 2; 100 // The mean values of b channel. 101 required float b_mean = 3; 102 } 103 oneof mean { 104 // Channelwise mean value. 105 float channelwise_mean = 1; 106 // Per-Channel mean values. 107 PerChannelMeanValues means = 2; 108 } 109 // Scale value in the normalization. 110 required float scale = 3 [default = 1.0]; 111} 112