I have posted this issue on both the ‘tensorflow/tensorflow/’ and ‘tensorflow/models’ repositories. Here are the links for both:

  

      github.com/tensorflow/models
  

  
    
  
	  
  

  
    
      exporter_main_v2.py on official TF2 OD checkpoints produces saved_model.pb different than official saved_model.pb #50653 7
    

    
      
        opened 
        
          
        
        Jul 9, 2021
      
      


      
        
          
          ahmadchalhoub
        
      
    

    
        models:research
        type:bug
    
  


  
    <em>Please make sure that this is a bug. As per our
[GitHub Policy](https://git…hub.com/tensorflow/tensorflow/blob/master/ISSUES.md),
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template</em>

**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: -
- TensorFlow installed from (source or binary): pip
- TensorFlow version (use command below): 2.3.0
- Python version: 3.6.9
- Bazel version (if compiling from source): -
- GCC/Compiler version (if compiling from source): -
- CUDA/cuDNN version: CUDA 11.4
- GPU model and memory: GeForce RTX 3090

I am trying to convert a re-trained TF2 object detection SSD MobilenetV2 model to a proprietary framework. I have successfully re-trained the network and it runs properly. However, I am having trouble with converting the saved_model.pb to the other framework. The conversion script from the SDK I am working with performs optimization on the saved_model.pb, using 'meta_optimizer.cc', which returns an empty graph after running through my re-trained model. I used '_exporter_main_v2.py_' to export my re-trained checkpoint to the saved_model.pb which I am having trouble with. 

The issue is not with my training or checkpoints, but with the exporting process from checkpoint to a saved_model.pb using '_exporter_main_v2.py_'. I know this because I downloaded the SSD MobilenetV2 model from the TF2 Zoo to test with it. I have no issue converting the official saved_model.pb file found in the official repo, but when I try to convert the official checkpoints found in the repo to a saved_model.pb using '_exporter_main_v2.py_', I face the same issue trying to convert the newly produced saved_model.pb file to the proprietary framework. This means that something wrong is happening when executing the 'exporter_main_v2.py' script.

**Describe the expected behavior**
The exported saved_model.pb file should not be different than the official saved_model.pb file found in the official repo. 

The following is what I get, showing 0 nodes and 0 edges
![grappler_empty_graph](https://user-images.githubusercontent.com/84783887/124790681-5c42f300-df19-11eb-9201-7c5258e8d59b.png)

**Standalone code to reproduce the issue**
The model I downloaded is: http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_320x320_coco17_tpu-8.tar.gz 

The command I used to export the official checkpoint to a saved_model.pb is: **python ~/models/research/object_detection/exporter_main_v2.py --input_type image_tensor --pipeline_config_path pipeline.config --trained_checkpoint_dir checkpoint/ --output_directory exported_model/**
  

  

  
    
    
  

  


  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      exporter_main_v2.py on official TF2 OD checkpoints produces saved_model.pb different than official saved_model.pb 2
    

    
      
        opened 
        
          
        
        Jul 7, 2021
      
      


      
        
          
          ahmadchalhoub
        
      
    

    
        TF 2.3
        comp:model
        type:bug
        type:others
    
  


  
    <em>Please make sure that this is a bug. As per our
[GitHub Policy](https://git…hub.com/tensorflow/tensorflow/blob/master/ISSUES.md),
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template</em>

**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: -
- TensorFlow installed from (source or binary): pip
- TensorFlow version (use command below): 2.3.0
- Python version: 3.6.9
- Bazel version (if compiling from source): -
- GCC/Compiler version (if compiling from source): -
- CUDA/cuDNN version: CUDA 11.4
- GPU model and memory: GeForce RTX 3090

I am trying to convert a re-trained TF2 object detection SSD MobilenetV2 model to a proprietary framework. I have successfully re-trained the network and it runs properly. However, I am having trouble with converting the saved_model.pb to the other framework. The conversion script from the SDK I am working with performs optimization on the saved_model.pb, using 'meta_optimizer.cc', which returns an empty graph after running through my re-trained model. I used '_exporter_main_v2.py_' to export my re-trained checkpoint to the saved_model.pb which I am having trouble with. 

The issue is not with my training or checkpoints, but with the exporting process from checkpoint to a saved_model.pb using '_exporter_main_v2.py_'. I know this because I downloaded the SSD MobilenetV2 model from the TF2 Zoo to test with it. I have no issue converting the official saved_model.pb file found in the official repo, but when I try to convert the official checkpoints found in the repo to a saved_model.pb using '_exporter_main_v2.py_', I face the same issue trying to convert the newly produced saved_model.pb file to the proprietary framework. This means that something wrong is happening when executing the 'exporter_main_v2.py' script.

**Describe the expected behavior**
The exported saved_model.pb file should not be different than the official saved_model.pb file found in the official repo. 

The following is what I get, showing 0 nodes and 0 edges
![grappler_empty_graph](https://user-images.githubusercontent.com/84783887/124790681-5c42f300-df19-11eb-9201-7c5258e8d59b.png)

**Standalone code to reproduce the issue**
The model I downloaded is: http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_320x320_coco17_tpu-8.tar.gz 

The command I used to export the official checkpoint to a saved_model.pb is: **python ~/models/research/object_detection/exporter_main_v2.py --input_type image_tensor --pipeline_config_path pipeline.config --trained_checkpoint_dir checkpoint/ --output_directory exported_model/**