- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在努力实现 Tensorflow's simple audio recognition到 iphone 应用程序。经过一些研究,我发现我需要将 Tensorflow 的卡住图 .pb 文件转换为核心 ML 模型,然后在 iOS 应用程序中使用它。所以我尝试关注 this sample 和引用 this转换器。但看起来转换器主要是为了转换将图像作为输入的模型而编写的。但是我的模型应该能够将音频 .wav 文件作为输入。 `
import tfcoreml as tf_converter
tf_converter.convert(tf_model_path = 'my_frozen_graph.pb',
mlmodel_path = 'my_model.mlmodel',
output_feature_names = ['labels_softmax:0'],
class_labels = 'classes.txt'
)
当我尝试使用上述代码将我的图表转换为核心 ML 模型时,我收到以下错误响应。
(env3) minimaci73$ python model.py
WARNING:root:Keras version 2.2.0 detected. Last version known to be fully compatible of Keras is 2.1.6 .
WARNING:root:TensorFlow version 1.8.0 detected. Last version known to be fully compatible is 1.5.0 .
Loading the TF graph...
Graph Loaded.
Traceback (most recent call last):
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 204, in _convert_pb_to_mlmodel
shape_list = shape.as_list()
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 900, in as_list
raise ValueError("as_list() is not defined on an unknown TensorShape.")
ValueError: as_list() is not defined on an unknown TensorShape.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "model.py", line 6, in <module>
class_labels = 'conv_labels.txt'
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
custom_conversion_functions=custom_conversion_functions)
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 206, in _convert_pb_to_mlmodel
raise ValueError('Please provide the shape for the input {} through the argument \'input_name_shape_dict\''.format(input_name))
ValueError: Please provide the shape for the input wav_data:0 through the argument 'input_name_shape_dict'
(env3) minimaci73$
根据上一条错误消息,我需要输入 input wav_data:0
的输入形状.所以我创建了教程中提到的卡住图的文本摘要,并查找了 wav_data
输入形状。但是输入形状是<unknown>
为了这。
我想知道是否有其他方法可以将此文件转换为核心 ML 模型?或者有没有办法直接在 ios swift 应用程序中使用卡住图 .pb 文件?
Tensorflow-experimental Swift 框架的文档也很少。如果你们有这方面的好资源,请分享。
Update
根据控制台日志,我降级了 keras
和 tensorflow
版本以及根据 Matthijs 的回答,我添加了 input_name_shape_dict = { "import/wav_data:0" : [1, 16, 44100, 1]
现在控制台以不同的方式显示错误
(env3) minimaci73$ python model.py
Loading the TF graph...
Traceback (most recent call last):
File "model.py", line 7, in <module>
class_labels = 'conv_labels.txt'
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
custom_conversion_functions=custom_conversion_functions)
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 153, in _convert_pb_to_mlmodel
tf.import_graph_def(gdef, name='')
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
return func(*args, **kwargs)
File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 541, in import_graph_def
raise ValueError('No op named %s in defined operations.' % node.op)
ValueError: No op named DecodeWav in defined operations.
(env3) minimaci73$ python model.py
最佳答案
您可以向转换器提供输入形状:
input_name_shape_dict={ "import/wav_data:0" : [1, input_height, input_width, channels] })
如果您的数据是一维的,则高度和宽度应为 1, channel 应为数据的长度。
您可能还会遇到其他转换错误,但这是第一步。 :-)(tfcoreml 需要知道输入形状,以便它可以使用一些假数据运行模型。)
关于python - 如何将 Tensorflow Simple Audio Recognition frozen graph(.pb) 转换为 Core ML 模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53626504/
我有一个经过训练的模型 (Faster R-CNN),我使用 export_inference_graph.py 将其导出以用于推理。我试图了解创建的 frozen_inference_graph.p
我正在开发一个使用Google Protocol Buffer (protobuf)和CMake的库。该项目具有以下目录树。 MyProject/ MyProject/include/myprojec
我有一个旧的训练有素的 tf1.x 模型(让它成为 Model1 ),用占位符、tf.contrib 等构建。我可以通过从 tf.Session(在 tf1.x 中)中的 .ckpt 检查点恢复图形来
我想预先执行查询并将结果存储在@query中: BEGIN DECLARE @query VARCHAR(50); SET @table = 'top20-img-link'; SET @query
有了这个玩具数据:: df = pd.DataFrame(pd.np.random.randint(2, 9, size=(8, 3))) df.index = pd.date_range(start
我使用的是 Twisted 16.1.1 和 python 3.4。在 twisted 的 16.1.1 版文档中,there is a tutorial上面写着“from twisted.sprea
最近尝试将模型(tf1.x)转换为saved_model,关注官方migrate document .但是在我的用例中,我手中的大部分模型或 tensorflow 模型动物园通常是 pb 文件,根据
有谁知道tensorflow_inception_graph.pb的原始源代码。 真不想知道示例项目中的操作 tensorflow/example/android - 读我。 Tensorflow A
完整的错误说: cv2.error:OpenCV(4.1.0)C:\ projects \ opencv-python \ opencv \ modules \ dnn \ src \ caffe \
我已将模型保存在图表(.pb 文件)中。但现在这个模型不准确,我想开发它。我有其他数据的图片需要学习,但我不知道是否可能或如何做到这一点?结果必须是新数据pb图的修改。 最佳答案 这是个好问题。实际上
假设我有模型(tf.keras.Model): class ContextExtractor(tf.keras.Model): def __init__(self): supe
我正在尝试加载取自 https://github.com/tensorflow/models/tree/master/official/resnet 的已训练模型,但是当我尝试加载 .pb 时,我在
我计划将 .aab 上传到 Play 商店进行发布,在发布之前,我正在尝试反编译以查看在逆向工程过程中哪些数据可能会暴露给用户。 在 .aab_FILES/base/中,我看到了 assets.pb
libphonenumber 中没有phonenumber.pb.h 和phonemetadata.pb.h (CPP) 库 那么有什么办法可以找出来吗? 谢谢! 最佳答案 这些是由 Google p
我需要在 CSV 甲酸盐文件中搜索超过 PB 的数据。使用 LUCENE 建立索引后,索引文件的大小是原始文件的两倍。是否可以减少索引文件的大小??? HADOOP中如何分发LUCENE索引文
我公司的产品每年将在我们的客户站点产生数 PB 的数据。我想填满一个多 PB 的 NAS 来模拟一个已经运行了很长时间(3 个月、6 个月、一年等)的系统。我们希望在我们的软件在负载下的存储系统上运行
我在 Windows 10 机器上创建了一个 tensorflow 模型并使用以下方法保存它: model.save('myfolder') 文件夹内myfolder我得到: - saved_mode
我使用 Pytorch 创建了一个对象检测模型然后从 .pth 转换而来至 .onnx然后 .pb , 但现在我需要将其转换为 .tflite对于安卓应用程序!怎么做?这是我的第一次。 input_a
在这种情况下,大文件会发生什么? 1)Spark从NameNode获取数据位置。 Spark是否会在同一时间停止,因为根据NameNode的信息,数据大小太长? 2)Spark根据数据节点块大小对数据
我在对象检测 API 中使用 ssd_mobilenets 来训练我自己的模型,并获取 .ckpt 文件。它在我的电脑上运行良好,但现在我想在我的手机上使用该模型。所以,我需要将它转换为 .pb 文件
我是一名优秀的程序员,十分优秀!