title: How to seamlesly load different ML models in python?
body: <p>Let's say I have my original <code>.pt</code> weights and I export them to <code>ONNX</code>, <code>OpenVINO</code> and <code>TFLite</code>. Is there a way of loading these models without needing to write a custom class that checks its type of instance and loads it accordingly?</p>
  <p>OpenVINO model loading example:</p>
  <pre class="lang-py prettyprint-override"><code>from openvino.runtime import Core
  
  ie = Core()
  classification_model_xml = &quot;model/classification.xml&quot;
  
  model = ie.read_model(model=classification_model_xml)
  compiled_model = ie.compile_model(model=model, device_name=&quot;CPU&quot;)
  </code></pre>
  <p>TFlite model loading example:</p>
  <pre class="lang-py prettyprint-override"><code>class TestModel(tf.Module):
    def __init__(self):
      super(TestModel, self).__init__()
  
    @tf.function(input_signature=[tf.TensorSpec(shape=[1, 10], dtype=tf.float32)])
    def add(self, x):
      '''
      Simple method that accepts single input 'x' and returns 'x' + 4.
      '''
      # Name the output 'result' for convenience.
      return {'result' : x + 4}
  
  
  SAVED_MODEL_PATH = 'content/saved_models/test_variable'
  TFLITE_FILE_PATH = 'content/test_variable.tflite'
  
  # Save the model
  module = TestModel()
  # You can omit the signatures argument and a default signature name will be
  # created with name 'serving_default'.
  tf.saved_model.save(
      module, SAVED_MODEL_PATH,
      signatures={'my_signature':module.add.get_concrete_function()})
  
  # Convert the model using TFLiteConverter
  converter = tf.lite.TFLiteConverter.from_saved_model(SAVED_MODEL_PATH)
  tflite_model = converter.convert()
  with open(TFLITE_FILE_PATH, 'wb') as f:
    f.write(tflite_model)
  
  # Load the TFLite model in TFLite Interpreter
  interpreter = tf.lite.Interpreter(TFLITE_FILE_PATH)
  # There is only 1 signature defined in the model,
  # so it will return it by default.
  # If there are multiple signatures then we can pass the name.
  my_signature = interpreter.get_signature_runner()
  
  # my_signature is callable with input as arguments.
  output = my_signature(x=tf.constant([1.0], shape=(1,10), dtype=tf.float32))
  # 'output' is dictionary with all outputs from the inference.
  # In this case we have single output 'result'.
  print(output['result'])
  </code></pre>
  <p>pt model loading example:</p>
  <pre class="lang-py prettyprint-override"><code>model = TheModelClass(*args, **kwargs)
  model.load_state_dict(torch.load(PATH))
  </code></pre>