// Copyright 2023 The Deeplab2 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 deeplab2;

// Configure the dataset options.
message DatasetOptions {
  // Set the dataset. See dataset.py for supported datasets.
  optional string dataset = 1;
  // Set the dataset file pattern to be used with glob.
  repeated string file_pattern = 2;
  // Set the number of samples per batch. This must be a multiple of replicas.
  // E.g. batch_size = 8 on 4 GPUs equals a batch size of 2 on each GPU.
  optional int32 batch_size = 3 [default = 32];
  // Set the crop size as a list of [crop_height, crop_width].
  repeated int32 crop_size = 4;
  // Minimum value for resize. Can be 1) empty; or 2) an integer, indicating
  // the desired size of the shorter image side (either height or width); or
  // 3) a 2-tuple of (height, width), indicating the desired minimum value for
  // height and width after resize. Setting values to non-positive indicate
  // no minimum value would be used.
  repeated int32 min_resize_value = 5;
  // Maximum value for resize. Can be 1) empty; or 2) an integer, indicating
  // the maximum allowed size of the longer image side (either height or width);
  // or 3) a 2-tuple of (height, width), indicating the maximum allowed size
  // after resize. Setting values to non-positive indicates no maximum value
  // would be used.
  repeated int32 max_resize_value = 6;
  // Set the resizing factor.
  optional int32 resize_factor = 7;

  /* Augmentation options for panoptic copy-paste.*/
  message PanopticCopyPasteOptions {
    // The scale of the pasted image in panoptic copy-paste.
    optional float panoptic_copy_paste_scale = 1 [default = 0.0];
    // The option of selecting copy-paste targets in panoptic copy-paste. The
    // option is one of ['random', 'none', 'all']. 'random' means the classes of
    // this type will be randomly selected, 'none' means all classes in this
    // type will be discraded, 'all' means all of them will be kept.
    optional string panoptic_copy_paste_thing_option = 2 [default = 'random'];
    // The option of selecting copy-paste targets in panoptic copy-paste. The
    // option is one of ['random', 'none', 'all']. 'random' means the classes of
    // this type will be randomly selected, 'none' means all classes in this
    // type will be discraded, 'all' means all of them will be kept.
    optional string panoptic_copy_paste_stuff_option = 3 [default = 'random'];
    // The option of selecting copy-paste targets in panoptic copy-paste. The
    // option is one of ['random', 'none', 'all']. 'random' means the classes of
    // this type will be randomly selected, 'none' means all classes in this
    // type will be discraded, 'all' means all of them will be kept.
    optional string panoptic_copy_paste_void_option = 4 [default = 'none'];
  }

  /* Augmentation options.*/
  message AugmentationOptions {
    // Set the minimum scale factor for augmentation. Default not to use.
    optional float min_scale_factor = 1 [default = 1.0];
    // Set the maximum scale factor for augmentation. Default not to use.
    optional float max_scale_factor = 2 [default = 1.0];
    // Set the scale factor step size for data augmentation.
    optional float scale_factor_step_size = 3 [default = 0.25];
    // The name of the AutoAugment policy to use.
    optional string autoaugment_policy_name = 4;
    // Set the panoptic copy-paste augmentations.
    optional PanopticCopyPasteOptions panoptic_copy_paste = 5;
  }
  optional AugmentationOptions augmentations = 8;
  // Set the standard deviation used to generate Gaussian center ground-truth.
  optional float sigma = 9 [default = 8.0];
  // Set whether to use increased weights on small instances.
  optional bool increase_small_instance_weights = 10 [default = false];
  // Set the pixel threshold for small instances.
  optional int32 small_instance_threshold = 11 [default = 4096];
  // Set the small instance weight.
  optional float small_instance_weight = 12 [default = 3.0];
  // Set whether to use two frames togetehr (current frame + previous frame) as
  // input for video panoptic segmentation.
  optional bool use_two_frames = 13 [default = false];
  // Whether to decode the groundtruth label. Some dataset splits (e.g., test
  // set) may not contain any groundtruth label. In that case, set this field
  // to false to avoid decoding non-existing groundtruth label.
  optional bool decode_groundtruth_label = 14 [default = true];
  // Whether the model needs thing_id_mask annotations. When True, we will
  // additionally return mask annotation for each `thing` instance, encoded with
  // a unique thing_id. This ground-truth annotation could be used to learn a
  // better segmentation mask for each instance. `thing_id` indicates the number
  // of unique thing-ID to each instance in an image, starting the counting from
  // 0 (default: False).
  optional bool thing_id_mask_annotations = 15 [default = false];
  // Set the maximum number of possible thing instances per image. It is used
  // together when enabling generation of thing_id_mask_annotations (= True),
  // representing the maximum thing ID encoded in the thing_id_mask.
  optional int32 max_thing_id = 16 [default = 128];
  // Set whether to use the next frame together with the current frame for video
  // panoptic segmentation (VPS). This field also controls using two-frame as
  // input for VPS. Note that `use_two_frames` is adopted in Motion-DeepLab,
  // while `use_next_frame` is used in ViP-DeepLab.
  optional bool use_next_frame = 17 [default = false];

  // Used for the multi-camera setting.
  // If empty, keep the `camera_name: camera_value` structure, where each
  // example contains all camera information. Otherwise, use the selected
  // cameras values, but treat them as individual frames. For WOD-PVPS
  // multi-camera variants, we support cameras_to_use with the following string
  // values:
  //  - 'side_left'
  //  - 'front_left'
  //  - 'front'
  //  - 'front_right'
  //  - 'side_right'
  //  - 'panorama'
  repeated string cameras_to_use = 18;
}
