i followed the instructions on tensorflow-object-detection-api-tutorial to train my custom Object Detector. The custom Object Detection just works as it sould but after exporting and reloading the model, it suddenly detects nothing.
I used the exporter_main_v2.py function to export the model. (Just like in the tutorial)
python .\exporter_main_v2.py --input_type image_tensor --pipeline_config_path={filepaths['pipeline_config_path']} --trained_checkpoint_dir={filepaths['trained_checkpoint_path']} --output_directory={filepaths['exported_models_path']}
Then i loaded the model into tensorflow:
detection_model = tf.saved_model.load(os.path.join(filepaths['exported_models_path'], 'saved_model'))
And when i make a prediction an a test image, the model detects nothing:
prediction = detection_model(test_image)
I tried the model_builder.build function to build the model based on my pipeline.config file, and loaded the latest training checkpoint. This works fine and the detection works. My exported model takes tf.uint8 as input signature, the build function however returns a model which expects a tf.float32 input.
# build model
configs = config_util.get_configs_from_pipeline_file(filepaths['pipeline_config_path'])
model_config = configs['model']
detection_model = model_builder.build(model_config=model_config, is_training=False)
# load checkpoint
ckpt = tf.train.Checkpoint(model=detection_model)
ckpt.restore(os.path.join(filepaths['trained_checkpoint_path'], 'ckpt-15')).expect_partial()
Then i tried to use tf.saved_model.load and restore the checkpoint manually:
detection_model = tf.saved_model.load(os.path.join(filepaths['exported_models_path'], 'saved_model'))
# load checkpoint
ckpt = tf.train.Checkpoint(model=detection_model)
ckpt.restore(os.path.join(filepaths['trained_checkpoint_path'], 'ckpt-15')).expect_partial()
This doesn't work as well.
When i build the model with the bild function, as mentioned before, and try to load the checkpoints which got exported by the exporter_main_v2.py function, the detection doesn't work as well. So i think that there is a problem with the export.
Any ideas what's going wrong? Why does the model returned by the build function expects float32 while the default signature of the saved model is uint8?
Thanks in advance!