当前位置: 首页>>代码示例>>Python>>正文


Python tfcoreml.convert方法代码示例

本文整理汇总了Python中tfcoreml.convert方法的典型用法代码示例。如果您正苦于以下问题:Python tfcoreml.convert方法的具体用法?Python tfcoreml.convert怎么用?Python tfcoreml.convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tfcoreml的用法示例。


在下文中一共展示了tfcoreml.convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_googlenet_resnet_v2

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_resnet_v2(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_resnet_v2_2016_08_30_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_resnet_v2_2016_08_30_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_resnet_v2_2016_08_30_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionResnetV2/Logits/Predictions:0'],
        input_name_shape_dict = {'input:0':[1,299,299,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionResnetV2/Logits/Predictions:0',
        img_size = 299) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例2: test_googlenet_v1_slim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v1_slim(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v1_2016_08_28_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,244,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV1/Logits/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例3: test_googlenet_v2_slim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v2_slim(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v2_2016_08_28_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v2_2016_08_28_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v2_2016_08_28_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV2/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,244,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV2/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例4: test_mobilenet_v1_100_224

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_mobilenet_v1_100_224(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_1.0_224/frozen_graph.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_1.0_224.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['MobilenetV1/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,224,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'MobilenetV1/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例5: test_mobilenet_v2_100_224

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_mobilenet_v2_100_224(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_1.0_224/frozen_graph.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_1.0_224.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['MobilenetV1/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,224,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'MobilenetV1/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例6: test_mobilenet_v1_75_192

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_mobilenet_v1_75_192(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_0.75_192_frozen.tgz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_0.75_192/frozen_graph.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_0.75_192.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['MobilenetV1/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,192,192,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'MobilenetV1/Predictions/Softmax:0',
        img_size = 192) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:26,代码来源:test_tfcoreml.py

示例7: test_googlenet_v1_slim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v1_slim(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v1_2016_08_28_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,224,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV1/Logits/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:tf-coreml,项目名称:tf-coreml,代码行数:26,代码来源:test_pretrained_models.py

示例8: test_googlenet_v1_slim_with_img_format

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v1_slim_with_img_format(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v1_2016_08_28_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v1_2016_08_28_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,224,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0,
        tf_image_format='NHWC')

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV1/Logits/Predictions/Softmax:0',
        img_size = 224) 
开发者ID:tf-coreml,项目名称:tf-coreml,代码行数:27,代码来源:test_pretrained_models.py

示例9: test_googlenet_v4_slim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v4_slim(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v4_2016_09_09_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v4_2016_09_09_frozen.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v4_2016_09_09_frozen.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV4/Logits/Predictions:0'],
        input_name_shape_dict = {'input:0':[1,299,299,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV4/Logits/Predictions:0',
        img_size = 299) 
开发者ID:tf-coreml,项目名称:tf-coreml,代码行数:26,代码来源:test_pretrained_models.py

示例10: _convert_to_coreml

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def _convert_to_coreml(tf_model_path, mlmodel_path, input_name_shape_dict,
    output_names, add_custom_layers=False, custom_conversion_functions={},
    minimum_ios_deployment_target='12',
    image_input_names=None,is_bgr=False, image_scale=1., red_bias=0.,
    blue_bias=0., green_bias=0., gray_bias=0.):
  """ Convert and return the coreml model from the Tensorflow
  """
  model = tf_converter.convert(tf_model_path=tf_model_path,
                                mlmodel_path=mlmodel_path,
                                output_feature_names=output_names,
                                input_name_shape_dict=input_name_shape_dict,
                                add_custom_layers=add_custom_layers,
                                custom_conversion_functions=custom_conversion_functions,
                                minimum_ios_deployment_target=minimum_ios_deployment_target,
                                image_input_names=image_input_names,
                                image_scale=image_scale,
                                is_bgr=is_bgr,
                                red_bias=red_bias,
                                blue_bias=blue_bias,
                                green_bias=green_bias,
                                gray_bias=gray_bias)
  return model 
开发者ID:tf-coreml,项目名称:tf-coreml,代码行数:24,代码来源:test_tf_converter.py

示例11: convert_to_coreml

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def convert_to_coreml(inference_graph_path, output_path):
    """Convert a tensorflow inference graph to Core ML model.
    This assumes mobilenet preprocessing.
    Args:
        inference_graph_path (str): path to a tensorflow frozen graph .pb file
        output_path (str): output path for .mlmodel file
    """
    tfcoreml.convert(
        tf_model_path=inference_graph_path,
        mlmodel_path=output_path,
        output_feature_names=['concat:0', 'concat_1:0'],
        input_name_shape_dict={'Preprocessor/sub:0': [1, 300, 300, 3]},
        image_input_names='Preprocessor/sub:0',
        image_scale=2.0 / 255.0,
        red_bias=-1.0,
        green_bias=-1.0,
        blue_bias=-1.0
    ) 
开发者ID:fritzlabs,项目名称:fritz-models,代码行数:20,代码来源:convert_to_coreml.py

示例12: test_inception_v3_slim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_inception_v3_slim(self):
    #Download model
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'inception_v3_2016_08_28_frozen.pb')

    #Convert to coreml
    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'inception_v3_2016_08_28.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['InceptionV3/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,299,299,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'InceptionV3/Predictions/Softmax:0',
        img_size = 299) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:28,代码来源:test_tfcoreml.py

示例13: test_googlenet_v1_nonslim

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_googlenet_v1_nonslim(self):
    #Download model
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'tensorflow_inception_graph.pb')

    #Convert to coreml
    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'googlenet_v1_nonslim.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['softmax2:0'],
        input_name_shape_dict = {'input:0':[1,224,224,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'softmax2:0',
        img_size = 224) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:28,代码来源:test_tfcoreml.py

示例14: test_mobilenet_v1_50_160

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_mobilenet_v1_50_160(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_0.50_160_frozen.tgz'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_0.50_160/frozen_graph.pb')

    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'mobilenet_v1_0.50_160.mlmodel')
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['MobilenetV1/Predictions/Softmax:0'],
        input_name_shape_dict = {'input:0':[1,160,160,3]},
        image_input_names = ['input:0'],
        red_bias = -1,
        green_bias = -1,
        blue_bias = -1,
        image_scale = 2.0/255.0)

    #Test predictions on an image
    self._test_coreml_model_image_input(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensor_name = 'input:0',
        output_tensor_name = 'MobilenetV1/Predictions/Softmax:0',
        img_size = 160)

  #@unittest.skip("Failing GPU backend: related to https://github.com/tf-coreml/tf-coreml/issues/26") 
开发者ID:microsoft,项目名称:MMdnn,代码行数:28,代码来源:test_tfcoreml.py

示例15: test_style_transfer

# 需要导入模块: import tfcoreml [as 别名]
# 或者: from tfcoreml import convert [as 别名]
def test_style_transfer(self):
    url = 'https://storage.googleapis.com/download.tensorflow.org/models/stylize_v1.zip'
    tf_model_dir = _download_file(url = url)
    tf_model_path = os.path.join(TMP_MODEL_DIR, 'stylize_quantized.pb')
    mlmodel_path = os.path.join(TMP_MODEL_DIR, 'stylize_quantized.mlmodel')
    # ? style transfer image size and style number?
    mlmodel = tf_converter.convert(
        tf_model_path = tf_model_path,
        mlmodel_path = mlmodel_path,
        output_feature_names = ['Squeeze:0'],
        input_name_shape_dict = {'input:0':[1,256,256,3], 'style_num:0':[26]})

    # Test predictions on an image
    input_tensors = [('input:0',[1,256,256,3]),
                     ('style_num:0',[26])]

    self.err_thresh = 0.5
    self._test_tf_model(
        tf_model_path = tf_model_path,
        coreml_model = mlmodel,
        input_tensors = input_tensors,
        output_tensor_names = ['Squeeze:0'],
        data_modes = ['image', 'onehot_0'],
        delta = 1e-2,
        use_cpu_only = True,
        scale = 1,
        bias = 0,
        img_size = 256,
        sequence_inputs = {'style_num:0'}) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:31,代码来源:test_tfcoreml.py


注:本文中的tfcoreml.convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。