use tensorflow trained .h5 model "just for predicting" in c++ on GPU

417 Views Asked by At

I have trained a model with tensorflow-gpu V2.7.0 with custom objects (custom losses and custom Model of voxelmorph). I trained this network on Collab and have an .h5 model.

I just want to use this .h5 model in c++ for testing that will input two images and register (map one image on another) them. I "just" want to use this h5 model to predict, meaning to apply in some data and give me the output! its wired that a model is just a tensor of parameters and some operations on them but using it on multi platforms is such a disaster.

  • one of my challenges is that even in python i cant load the h5 model without passing voxelmorph custom object to keras.models.load_model
  • another challenge is that I couldnt use onnx format that I think its because of my custom objects and complexity of the model
  • I cant also use .ph file in tensorflow v1.x to use OpenCV c++ libraries because voxelmorph is used in tf-V2.x

in general isnt there any way to compress all the custom objects in a ANN model structure that can be used in any other language (in my case c++) just to predict and not train?

0

There are 0 best solutions below