Training ssd inception_v3 using pretrained model from slim











up vote
2
down vote

favorite












I want to train ssd inception_v3 model using object detection API with pretrained model from SLIM (link)
I try to train object detection ssd inception v3 model using config:



model {
ssd {
num_classes: 1
image_resizer {
fixed_shape_resizer {
height: 240
width: 320
}
}
feature_extractor {
type: "ssd_inception_v3"
depth_multiplier: 1.0
min_depth: 16
conv_hyperparams {
regularizer {
l2_regularizer {
weight: 3.99999989895e-05
}
}
initializer {
truncated_normal_initializer {
mean: 0.0
stddev: 0.0299999993294
}
}
activation: RELU_6
batch_norm {
decay: 0.999700009823
center: true
scale: true
epsilon: 0.0010000000475
train: true
}
}
override_base_feature_extractor_hyperparams: true
}
...


I stopped procces after creating files model.ckpt-0.*, loaded and printed all tensors' names.



After that I loaded pretrained model from https://github.com/tensorflow/models/tree/master/research/slim using



reader = pywrap_tensorflow.NewCheckpointReader(os.path.join(folder, 'model.ckpt'))
var_to_shape_map = reader.get_variable_to_shape_map()


When I compared output I didn't see a lot layers for ssd incpetion v3 model. For example:




InceptionV3/AuxLogits/Conv2d_2a_5x5/weights
InceptionV3/Mixed_7c/Branch_3/Conv2d_0b_1x1/weight




In model from ssd_inception_v3 I saw mixed layers before 5c.



What are the differences of Feature Extractor in SSD_inception and SLIM models? In general, is it possible to load weights from SLIM for the classifier in the Object detection API for detection.










share|improve this question


























    up vote
    2
    down vote

    favorite












    I want to train ssd inception_v3 model using object detection API with pretrained model from SLIM (link)
    I try to train object detection ssd inception v3 model using config:



    model {
    ssd {
    num_classes: 1
    image_resizer {
    fixed_shape_resizer {
    height: 240
    width: 320
    }
    }
    feature_extractor {
    type: "ssd_inception_v3"
    depth_multiplier: 1.0
    min_depth: 16
    conv_hyperparams {
    regularizer {
    l2_regularizer {
    weight: 3.99999989895e-05
    }
    }
    initializer {
    truncated_normal_initializer {
    mean: 0.0
    stddev: 0.0299999993294
    }
    }
    activation: RELU_6
    batch_norm {
    decay: 0.999700009823
    center: true
    scale: true
    epsilon: 0.0010000000475
    train: true
    }
    }
    override_base_feature_extractor_hyperparams: true
    }
    ...


    I stopped procces after creating files model.ckpt-0.*, loaded and printed all tensors' names.



    After that I loaded pretrained model from https://github.com/tensorflow/models/tree/master/research/slim using



    reader = pywrap_tensorflow.NewCheckpointReader(os.path.join(folder, 'model.ckpt'))
    var_to_shape_map = reader.get_variable_to_shape_map()


    When I compared output I didn't see a lot layers for ssd incpetion v3 model. For example:




    InceptionV3/AuxLogits/Conv2d_2a_5x5/weights
    InceptionV3/Mixed_7c/Branch_3/Conv2d_0b_1x1/weight




    In model from ssd_inception_v3 I saw mixed layers before 5c.



    What are the differences of Feature Extractor in SSD_inception and SLIM models? In general, is it possible to load weights from SLIM for the classifier in the Object detection API for detection.










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I want to train ssd inception_v3 model using object detection API with pretrained model from SLIM (link)
      I try to train object detection ssd inception v3 model using config:



      model {
      ssd {
      num_classes: 1
      image_resizer {
      fixed_shape_resizer {
      height: 240
      width: 320
      }
      }
      feature_extractor {
      type: "ssd_inception_v3"
      depth_multiplier: 1.0
      min_depth: 16
      conv_hyperparams {
      regularizer {
      l2_regularizer {
      weight: 3.99999989895e-05
      }
      }
      initializer {
      truncated_normal_initializer {
      mean: 0.0
      stddev: 0.0299999993294
      }
      }
      activation: RELU_6
      batch_norm {
      decay: 0.999700009823
      center: true
      scale: true
      epsilon: 0.0010000000475
      train: true
      }
      }
      override_base_feature_extractor_hyperparams: true
      }
      ...


      I stopped procces after creating files model.ckpt-0.*, loaded and printed all tensors' names.



      After that I loaded pretrained model from https://github.com/tensorflow/models/tree/master/research/slim using



      reader = pywrap_tensorflow.NewCheckpointReader(os.path.join(folder, 'model.ckpt'))
      var_to_shape_map = reader.get_variable_to_shape_map()


      When I compared output I didn't see a lot layers for ssd incpetion v3 model. For example:




      InceptionV3/AuxLogits/Conv2d_2a_5x5/weights
      InceptionV3/Mixed_7c/Branch_3/Conv2d_0b_1x1/weight




      In model from ssd_inception_v3 I saw mixed layers before 5c.



      What are the differences of Feature Extractor in SSD_inception and SLIM models? In general, is it possible to load weights from SLIM for the classifier in the Object detection API for detection.










      share|improve this question













      I want to train ssd inception_v3 model using object detection API with pretrained model from SLIM (link)
      I try to train object detection ssd inception v3 model using config:



      model {
      ssd {
      num_classes: 1
      image_resizer {
      fixed_shape_resizer {
      height: 240
      width: 320
      }
      }
      feature_extractor {
      type: "ssd_inception_v3"
      depth_multiplier: 1.0
      min_depth: 16
      conv_hyperparams {
      regularizer {
      l2_regularizer {
      weight: 3.99999989895e-05
      }
      }
      initializer {
      truncated_normal_initializer {
      mean: 0.0
      stddev: 0.0299999993294
      }
      }
      activation: RELU_6
      batch_norm {
      decay: 0.999700009823
      center: true
      scale: true
      epsilon: 0.0010000000475
      train: true
      }
      }
      override_base_feature_extractor_hyperparams: true
      }
      ...


      I stopped procces after creating files model.ckpt-0.*, loaded and printed all tensors' names.



      After that I loaded pretrained model from https://github.com/tensorflow/models/tree/master/research/slim using



      reader = pywrap_tensorflow.NewCheckpointReader(os.path.join(folder, 'model.ckpt'))
      var_to_shape_map = reader.get_variable_to_shape_map()


      When I compared output I didn't see a lot layers for ssd incpetion v3 model. For example:




      InceptionV3/AuxLogits/Conv2d_2a_5x5/weights
      InceptionV3/Mixed_7c/Branch_3/Conv2d_0b_1x1/weight




      In model from ssd_inception_v3 I saw mixed layers before 5c.



      What are the differences of Feature Extractor in SSD_inception and SLIM models? In general, is it possible to load weights from SLIM for the classifier in the Object detection API for detection.







      python tensorflow






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 4:05









      Viktor Nikolaev

      132




      132
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You can see what happens in ssd_inception_v3_feature_extractor.
          It uses the outputs of 'Mixed_5d', 'Mixed_6e', 'Mixed_7c' of InceptionV3 from inception_v3.inception_v3_base (Note the _base) and creating 3 additional feature maps with 512, 256, 128 number of channels (this happens in feature_map_generators.multi_resolution_feature_maps by feature_map_layout).
          Loading the weights of the classifier for the detection model can be done by configuration:



          train_config{
          ...
          fine_tune_checkpoint: <path_to_inception_checkpoint>
          fine_tune_checkpoint_type: "classification"
          }


          Of course that the checkpoint has to match the model you're using, e.g. ssd_inception_v3.






          share|improve this answer





















          • Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
            – Viktor Nikolaev
            Nov 8 at 4:30










          • fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
            – netanel-sam
            Nov 8 at 8:02












          • thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
            – Viktor Nikolaev
            Nov 12 at 5:40











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183424%2ftraining-ssd-inception-v3-using-pretrained-model-from-slim%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          You can see what happens in ssd_inception_v3_feature_extractor.
          It uses the outputs of 'Mixed_5d', 'Mixed_6e', 'Mixed_7c' of InceptionV3 from inception_v3.inception_v3_base (Note the _base) and creating 3 additional feature maps with 512, 256, 128 number of channels (this happens in feature_map_generators.multi_resolution_feature_maps by feature_map_layout).
          Loading the weights of the classifier for the detection model can be done by configuration:



          train_config{
          ...
          fine_tune_checkpoint: <path_to_inception_checkpoint>
          fine_tune_checkpoint_type: "classification"
          }


          Of course that the checkpoint has to match the model you're using, e.g. ssd_inception_v3.






          share|improve this answer





















          • Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
            – Viktor Nikolaev
            Nov 8 at 4:30










          • fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
            – netanel-sam
            Nov 8 at 8:02












          • thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
            – Viktor Nikolaev
            Nov 12 at 5:40















          up vote
          0
          down vote



          accepted










          You can see what happens in ssd_inception_v3_feature_extractor.
          It uses the outputs of 'Mixed_5d', 'Mixed_6e', 'Mixed_7c' of InceptionV3 from inception_v3.inception_v3_base (Note the _base) and creating 3 additional feature maps with 512, 256, 128 number of channels (this happens in feature_map_generators.multi_resolution_feature_maps by feature_map_layout).
          Loading the weights of the classifier for the detection model can be done by configuration:



          train_config{
          ...
          fine_tune_checkpoint: <path_to_inception_checkpoint>
          fine_tune_checkpoint_type: "classification"
          }


          Of course that the checkpoint has to match the model you're using, e.g. ssd_inception_v3.






          share|improve this answer





















          • Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
            – Viktor Nikolaev
            Nov 8 at 4:30










          • fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
            – netanel-sam
            Nov 8 at 8:02












          • thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
            – Viktor Nikolaev
            Nov 12 at 5:40













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          You can see what happens in ssd_inception_v3_feature_extractor.
          It uses the outputs of 'Mixed_5d', 'Mixed_6e', 'Mixed_7c' of InceptionV3 from inception_v3.inception_v3_base (Note the _base) and creating 3 additional feature maps with 512, 256, 128 number of channels (this happens in feature_map_generators.multi_resolution_feature_maps by feature_map_layout).
          Loading the weights of the classifier for the detection model can be done by configuration:



          train_config{
          ...
          fine_tune_checkpoint: <path_to_inception_checkpoint>
          fine_tune_checkpoint_type: "classification"
          }


          Of course that the checkpoint has to match the model you're using, e.g. ssd_inception_v3.






          share|improve this answer












          You can see what happens in ssd_inception_v3_feature_extractor.
          It uses the outputs of 'Mixed_5d', 'Mixed_6e', 'Mixed_7c' of InceptionV3 from inception_v3.inception_v3_base (Note the _base) and creating 3 additional feature maps with 512, 256, 128 number of channels (this happens in feature_map_generators.multi_resolution_feature_maps by feature_map_layout).
          Loading the weights of the classifier for the detection model can be done by configuration:



          train_config{
          ...
          fine_tune_checkpoint: <path_to_inception_checkpoint>
          fine_tune_checkpoint_type: "classification"
          }


          Of course that the checkpoint has to match the model you're using, e.g. ssd_inception_v3.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 9:06









          netanel-sam

          2016




          2016












          • Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
            – Viktor Nikolaev
            Nov 8 at 4:30










          • fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
            – netanel-sam
            Nov 8 at 8:02












          • thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
            – Viktor Nikolaev
            Nov 12 at 5:40


















          • Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
            – Viktor Nikolaev
            Nov 8 at 4:30










          • fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
            – netanel-sam
            Nov 8 at 8:02












          • thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
            – Viktor Nikolaev
            Nov 12 at 5:40
















          Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
          – Viktor Nikolaev
          Nov 8 at 4:30




          Thanks you for advices! When I start with the parameter fine_tune_checkpoint_type: "classification" I see no difference with the fact that I get without this parameter. If I understand correctly, I do not need the weight responsible for the classification becouse I want to train detector. If I use the pre-learned model, as I already said, warning drops out, although in a checkpoint these weights should be required, even considering your comment, layer 7c is used when building the feature. [InceptionV3/Mixed_7c_1_Conv2d_3_1x1_256/BatchNorm/beta] is not available in checkpoint ...
          – Viktor Nikolaev
          Nov 8 at 4:30












          fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
          – netanel-sam
          Nov 8 at 8:02






          fine_tune_checkpoint_type: "classification" is indeed the default, so it is in fact not required in your case. This means that you're loading a checkpoint which was trained for classification, but you're fine-tuning it for detection, so most layers are restored (the feature extraction layers), except final ones which are responsible for the classification based on the feature map(s). Regarding the warning you're receiving, it's standard. See for example in here: github.com/tensorflow/models/issues/4862#issuecomment-408394971
          – netanel-sam
          Nov 8 at 8:02














          thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
          – Viktor Nikolaev
          Nov 12 at 5:40




          thanks for the advices. They are really help a lot! Now I a little bit confused. I obtained very strange results. I compared three inicialization: 1. Start training from scratch. 2. Start training from a pre-trained model (from_detection_checkpoint: false because I do not have a checkpoint for the detector.). 3. Start training by loading weights manually (to do this, you first started manual training to create the 0th step, then interrupt training and manually replace weights from the pre-trained model) As a result of comparing weights, all three models have different weights.
          – Viktor Nikolaev
          Nov 12 at 5:40


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183424%2ftraining-ssd-inception-v3-using-pretrained-model-from-slim%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()