code: def inference(cls, architecture, model_path, image_path):
      # TODO
      from PIL import Image
      import numpy as np
      from coremltools.models._infer_shapes_nn_mlmodel import (
          infer_shapes,
      )
  
      if cls.sanity_check(architecture):
          func = TestKit.preprocess_func["coreml"][architecture]
  
          import inspect
  
          funcstr = inspect.getsource(func)
  
          if len(funcstr.split(",")) == 3:
              size = int(funcstr.split("path,")[1].split(")")[0])
          else:
              size = int(funcstr.split("path,")[1].split(",")[0])
  
          img = Image.open(image_path)
          img = img.resize((size, size))
  
          # load model
          model = MLModel(model_path)
          spec = model.get_spec()
  
          # TODO: Multiple inputs
          input_name = spec.description.input[0].name
  
          # TODO: Multiple outputs
          output_name = spec.description.output[0].name
  
          # inference
          input_data = img
          coreml_input = {input_name: img}
          coreml_output = model.predict(coreml_input)
  
          prob = coreml_output[output_name]
          if isinstance(prob, dict):
              prob = list(coreml_output[output_name].values())
          prob = np.array(prob).squeeze()
  
          return prob
  
      else:
          return None
  
file_path: MMdnn/mmdnn/conversion/examples/coreml/extractor.py
imports: from __future__ import absolute_import
  import os
  import coremltools
  from coremltools.models import MLModel
  from mmdnn.conversion.examples.imagenet_test import TestKit
  from mmdnn.conversion.examples.extractor import base_extractor
  from mmdnn.conversion.common.utils import download_file
label_desc: Use image node_id 2 for calling the coreml_extractor obj's underlying member method code with example usage: obj.inference(cls, architecture, model_path, image_path) and returns: prob, None