code: def inference(image_path, model_path, batch_size, sc):
      imageDF = NNImageReader.readImages(
          image_path, sc, resizeH=300, resizeW=300, image_codec=1
      )
      getName = udf(lambda row: row[0], StringType())
      transformer = ChainedPreprocessing(
          [
              RowToImageFeature(),
              ImageResize(256, 256),
              ImageCenterCrop(224, 224),
              ImageChannelNormalize(123.0, 117.0, 104.0),
              ImageMatToTensor(),
              ImageFeatureToTensor(),
          ]
      )
  
      model = Model.loadModel(model_path)
      classifier_model = (
          NNClassifierModel(model, transformer)
          .setFeaturesCol("image")
          .setBatchSize(batch_size)
      )
      predictionDF = classifier_model.transform(imageDF).withColumn(
          "name", getName(col("image"))
      )
      return predictionDF
  
file_path: BigDL/python/dllib/examples/nnframes/imageInference/ImageInferenceExample.py
imports: from bigdl.dllib.nn.layer import Model
  from pyspark.sql.functions import col, udf
  from pyspark.sql.types import StringType
  from bigdl.dllib.nncontext import *
  from bigdl.dllib.feature.image import *
  from bigdl.dllib.nnframes import *
  from optparse import OptionParser
  import sys
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 1 for calling a global function with example usage: inference(image_path, model_path, batch_size, sc) and returns: predictionDF