models icon indicating copy to clipboard operation
models copied to clipboard

Data Augmentation Options are altered during training

Open twhitloc opened this issue 8 years ago • 9 comments

System information

  • What is the top-level directory of the model you are using: Object Detection -> model_main
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): The only modifications I have made are adding GPU flags to set cuda_visible_devices.
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 1.10
  • Bazel version (if compiling from source): N/A
  • CUDA/cuDNN version: Unrelated
  • GPU model and memory: Unrelated
  • Exact command to reproduce: Add multiple Data Augmentation Options to preprocess in train_config (I do this in pipeline config). Only 1 will appear in the pipeline config in the model_dir during training. Even altering the pipeline config in the model dir and continuing / transferring will not work as it is altered at run time.

train_config: { batch_size: 1 . . . data_augmentation_options { random_horizontal_flip { #keeping Defaults } random_vertical_flip{ #keeping defaults } random_rotation90{ #keeping defaults } random_adjust_brightness{ max_delta: 0.1 } random_adjust_contrast{ min_delta: 0.001, max_delta: 0.1 } } }

python3 object_detection/model_main.py --pipeline_config_path [...]/defs/2160p/ssd_mobilenet_v1_fpn_shared_box_predictor_2160p.config --model_dir test --num_eval_steps 10 --num_train_steps 100 --gpu 0 (sets os.environ['cuda_visible_devices'])

INFO:tensorflow:Maybe overwriting train_steps: 100 INFO:tensorflow:Maybe overwriting eval_steps: 10 INFO:tensorflow:Maybe overwriting retain_original_images_in_eval: True INFO:tensorflow:Maybe overwriting load_pretrained: True INFO:tensorflow:Ignoring config override key: load_pretrained INFO:tensorflow:create_estimator_and_inputs: use_tpu False INFO:tensorflow:Using config: {'_model_dir': 'test', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f1ee1564a58>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1} WARNING:tensorflow:Estimator's model_fn (<function create_model_fn..model_fn at 0x7f1ee156ec80>) includes params argument, but params are not passed to Estimator. INFO:tensorflow:Writing pipeline config file to test/pipeline.config INFO:tensorflow:Running training and evaluation locally (non-distributed). INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps None or save_checkpoints_secs 600. WARNING:tensorflow:num_readers has been reduced to 54 to match input file shards. WARNING:tensorflow:From /home/ampex/Sandbox/ampex/training/object_detection/builders/dataset_builder.py:146: batch_and_drop_remainder (from tensorflow.contrib.data.python.ops.batching) is deprecated and will be removed in a future version. Instructions for updating: Use tf.data.Dataset.batch(..., drop_remainder=True). INFO:tensorflow:Calling model_fn. INFO:tensorflow:Done calling model_fn. INFO:tensorflow:Create CheckpointSaverHook. INFO:tensorflow:Graph was finalized. 2018-10-05 10:55:22.139639: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2018-10-05 10:55:22.401021: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: name: TITAN V major: 7 minor: 0 memoryClockRate(GHz): 1.455 pciBusID: 0000:0c:00.0 totalMemory: 11.78GiB freeMemory: 11.37GiB 2018-10-05 10:55:22.401054: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0 2018-10-05 10:55:22.668357: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-10-05 10:55:22.668408: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0 2018-10-05 10:55:22.668414: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N 2018-10-05 10:55:22.668667: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10981 MB memory) -> physical GPU (device: 0, name: TITAN V, pci bus id: 0000:0c:00.0, compute capability: 7.0) INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Saving checkpoints for 0 into test/model.ckpt. INFO:tensorflow:loss = 751.9043, step = 0

Starts training okay, but then we look at data_augmentation_options in our new pipeline config at test/pipeline.config

train_config { batch_size: 1 data_augmentation_options { random_adjust_contrast { min_delta: 0.0010000000474974513 max_delta: 0.10000000149011612 } }

Sure enough all of the data augmentation options minus a single one have been removed from the configuration given at training time.

twhitloc avatar Oct 05 '18 17:10 twhitloc

Adding to this, it appears that it adds the num_epochs:1 parameter to eval_input_reader, even when omitted from the model config file. Expected behavior would be to have the default, which is num_epochs:0.

nigelmathes avatar Oct 05 '18 21:10 nigelmathes

I'm pretty sure the correct way to config several augmentation options is repeating the entire data_augmentation_options entry. For example:

train_config {
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    random_image_scale {
    }
  }
  data_augmentation_options {
    random_adjust_brightness {
    }
  }
}

This is due to the fact that in the proto files, the PreprocessingStep data_augmentation_options entry is repeated, while PreprocessingStep is a oneof.

netanel-s avatar Oct 07 '18 07:10 netanel-s

@netanel-s Thank you, that does appear to stay in the config at run-time.

I do find the naming of this field to be counter intuitive though. If only one option can be set this way and it is not a unique field shouldn't it just be called data_augmentation_option?

In either case, I appreciate the help- I was not able to find any such examples in the samples, etc.

twhitloc avatar Oct 08 '18 17:10 twhitloc

I'm pretty sure the correct way to config several augmentation options is repeating the entire data_augmentation_options entry. For example:

train_config {
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    random_image_scale {
    }
  }
  data_augmentation_options {
    random_adjust_brightness {
    }
  }
}

This is due to the fact that in the proto files, the PreprocessingStep data_augmentation_options entry is repeated, while PreprocessingStep is a oneof.

Is it true?

rozeappletree avatar Jan 03 '20 09:01 rozeappletree

Sorry for the very basic question. If we apply data augmentation techniques such as ssd_random_crop and random_horizontal_flip than do we have to take care about ground truth bounding boxes? If we crop or flip image than the corresponding ground truth bounding box doesn't match. Is this managed by the tensorflow object detection API?

@netanel-s and @twhitloc: Could you please guide me?

Thank you!

chauhansaurabhb avatar Mar 10 '20 09:03 chauhansaurabhb

Yes, it is managed by OD API. Sometimes the augmentation functions have parameters related to the bounding boxes to let you control it better. Can you see it in the proto file of preprocessor.

netanel-s avatar Mar 16 '20 11:03 netanel-s

Thank you for sharing your views!

chauhansaurabhb avatar Mar 19 '20 07:03 chauhansaurabhb

I'm pretty sure the correct way to config several augmentation options is repeating the entire data_augmentation_options entry. For example:

train_config {
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    random_image_scale {
    }
  }
  data_augmentation_options {
    random_adjust_brightness {
    }
  }
}

This is due to the fact that in the proto files, the PreprocessingStep data_augmentation_options entry is repeated, while PreprocessingStep is a oneof.

Is it true?

Is it true? Please someone confirm please.

sunilgc7 avatar Jan 28 '21 21:01 sunilgc7

I'm pretty sure the correct way to config several augmentation options is repeating the entire data_augmentation_options entry. For example:

train_config {
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    random_image_scale {
    }
  }
  data_augmentation_options {
    random_adjust_brightness {
    }
  }
}

This is due to the fact that in the proto files, the PreprocessingStep data_augmentation_options entry is repeated, while PreprocessingStep is a oneof.

Is it true?

Is it true? Please someone confirm please.

Config file of ssd uses this format, so i am pretty sure that's how it's supposed to be.

data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    ssd_random_crop {
    }
  }
}

jamal-ansary avatar Mar 25 '21 13:03 jamal-ansary