无法将模型从 tf hub 转换为 tensorflowjs

Cannot convert model to tensorflowjs from tf hub

我正在使用 tensorflowjs_converter 将 tflite 模型转换为 tensorflowjs 模型。 可以使用 Web 浏览器下载存储库,但使用 tensorflowjs_converter.

时失败
tensorflowjs_converter --input_format=tf_hub 'https://tfhub.dev/sayakpaul/lite-model/arbitrary-image-stylization-inceptionv3/dr/predict/1' ./web_model

它输出一个 Http 404,但我的连接很好。当我 运行 示例代码工作正常时,我下载了它。

tensorflowjs_converter --input_format=tf_hub 'https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1' ./web_model  

如果你能告诉我原因或者你能从以下网址成功转换tflite模型,我将不胜感激。非常感谢。

https://tfhub.dev/sayakpaul/lite-model/arbitrary-image-stylization-inceptionv3/dr/predict/1

https://tfhub.dev/sayakpaul/lite-model/cartoongan/dr/1

Here 它说您只能使用转换器将“TensorFlow SavedModel、TensorFlow Hub 模块、Keras HDF5 或 tf.keras SavedModel”转换为 TF.js 模型,但不能使用 TFLite型号。

所以您要么需要向转换器提供这样的模型,要么您可以通过加载 https://storage.googleapis.com/tfhub-lite-models/sayakpaul/lite-model/cartoongan/dr/1.tflite 并将所有出现的 224 替换为 [=12] 来使用新的 tfjs-tflite API to run inference on a TFLite model in the browser. From here, you can modify Demo 2 =] 因为 CartoonGAN 模型消耗并生成尺寸为 512x512 的图像。该演示随后在浏览器中加载 TFLite 模型并对输入图像运行推理。同样的方法适用于 arbitrary-image-stylization-inceptionv3 模型(减去它不输出图像但输出嵌入向量)。

遗憾的是,还无法将加载的 TFLite 模型导出为 TF.js 模型。