簡體   English   中英

我可以將在 Google Colab 的 Tensorflow 上創建的“.py”或“.ipynb”模型/文件轉換為 coreML 模型/文件嗎?

[英]Can I convert a “.py” or “.ipynb” model/file created on Google Colab's Tensorflow to a coreML model/ file?

我在 Google Colab 的 Tensorflow 上創建了一個 CNN model 並將文件下載為“.py”文件。 如何將此文件轉換為“.coreml”文件?

非常感謝任何建議!

謝謝!

有關如何轉換為 Core ML 的.mlmodel的文檔: https://developer.apple.com/documentation/coreml/converting_trained_models_to_core_ml

對於 TensorFlow 模型,您需要將其轉換為frozen.pb model 作為轉換 function 的輸入。 以下是一些示例: https://github.com/tf-coreml/tf-coreml/tree/master/examples

如果您下載了.py文件,則您還沒有下載 model,而是整個 Python 腳本。

When you have your model compiled, you can use the python package coremltools to convert the TensorFlow/Keras model into a .mlmodel file.

import coremltools

core_mlmodel = coremltools.converters.keras.convert(your_keras_model, respect_trainable=True)
core_mlmodel.save("YourModel.mlmodel")

然后你會在Files的左邊找到你的 model。

@塞巴斯蒂安·J·沃格特。 這是我的轉換代碼。 這是對的嗎? 謝謝!

import coremltools

category_output_labels = ['dress', 'shirt', 'trousers']
color_output_labels = ['black', 'blue', 'green', 'pink', 'red', 
'white']

coreml_model = coremltools.converters.keras.convert('./fashion_multi_output_v02.h5',

input_names='image', image_input_names='image', class_labels=['category_output_labels', 'color_output_labels'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM