code: def _convert(args):
      if args.srcModelFormat == "auto":
          if (
              args.srcModelPath.endswith(".caffemodel")
              or args.caffeProtoTxtPath != ""
          ):
              args.srcModelFormat = "caffe"
          elif (
              args.srcModelPath.endswith(".h5")
              or args.kerasJsonPath != ""
          ):
              args.srcModelFormat = "keras"
          else:
              print(
                  "error: coremlconverter: Unable to auto-detect model format. "
                  "Please specify the model format using the 'srcModelFormat' argument."
              )
              _sys.exit(1)
  
      if args.srcModelFormat == "caffe":
          if args.caffeProtoTxtPath:
              if args.meanImageProtoPath:
                  model = (
                      args.srcModelPath,
                      args.caffeProtoTxtPath,
                      args.meanImageProtoPath,
                  )
              else:
                  model = (args.srcModelPath, args.caffeProtoTxtPath)
          else:
              model = args.srcModelPath
          try:
              model = converters.caffe.convert(
                  model,
                  image_input_names=set(args.imageInputNames),
                  is_bgr=args.isBGR,
                  red_bias=args.redBias,
                  blue_bias=args.blueBias,
                  green_bias=args.greenBias,
                  gray_bias=args.grayBias,
                  image_scale=args.scale,
                  class_labels=args.classInputPath,
                  predicted_feature_name=args.predictedFeatureName,
              )
              model.save(args.dstModelPath)
          except Exception as e:
              print("error: coremlconverter: %s." % str(e))
              return 1  # error
          return 0
  
      elif args.srcModelFormat == "keras":
          try:
              if not args.inputNames:
                  raise TypeError(
                      "Neural network 'inputNames' are required for converting Keras models."
                  )
              if not args.outputNames:
                  raise TypeError(
                      "Neural network 'outputNames' are required for converting Keras models."
                  )
  
              if args.kerasJsonPath:
                  model = (args.kerasJsonPath, args.srcModelPath)
              else:
                  model = args.srcModelPath
  
              model = converters.keras.convert(
                  model,
                  args.inputNames,
                  args.outputNames,
                  image_input_names=set(args.imageInputNames)
                  if args.imageInputNames
                  else None,
                  is_bgr=args.isBGR,
                  red_bias=args.redBias,
                  blue_bias=args.blueBias,
                  green_bias=args.greenBias,
                  gray_bias=args.grayBias,
                  image_scale=args.scale,
                  class_labels=args.classInputPath
                  if args.classInputPath
                  else None,
                  predicted_feature_name=args.predictedFeatureName,
                  respect_trainable=args.respectTrainable,
              )
              model.save(args.dstModelPath)
          except Exception as e:
              print("error: coremlconverter: %s." % str(e))
              return 1  # error
          return 0
      else:
          print(
              "error: coremlconverter: Invalid srcModelFormat specified."
          )
          return 1
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/_scripts/converter.py
imports: import logging
  from six import string_types
  from ..models import utils
  from ..models import neural_network
  from ..models import MLModel
  from ..None import converters
  from ..None import proto
  import sys
label_desc: Use image node_id 1 for calling a global function with example usage: _convert(args) and returns: int, int, int, int, int