菜鸟教程小白 发表于 2022-12-13 03:45:29

ios - 在 iOS 上使用 TensorFlow 音频识别模型


                                            <p><p>我正在尝试在 iOS 上使用 TensorFlow 音频识别模型(<code>my_frozen_graph.pb</code>,在此处生成:<a href="https://www.tensorflow.org/tutorials/audio_recognition" rel="noreferrer noopener nofollow">https://www.tensorflow.org/tutorials/audio_recognition</a>)。 </p>

<p>但是 TensorFlow Mobile 的 <code>tf_simple_example</code> 项目中的 iOS 代码 <code>NSString* network_path = FilePathForResourceName(@"my_frozen_graph", @"pb");</code> 输出了这个错误信息:<code>无法创建 TensorFlow Graph:未找到:操作类型未注册“DecodeWav”</code>。 </p>

<p>有人知道我该如何解决这个问题吗?谢谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我相信您使用的是 Cocopods 的预构建 Tensorflow?它可能没有那种 op 类型,所以你应该从最新的源代码自己构建它。</p>

<p>来自 <a href="https://www.tensorflow.org/mobile/ios_build#building_the_tensorflow_ios_libraries_from_source" rel="noreferrer noopener nofollow">documentation</a> :</p>

<blockquote>
<p>While Cocapods is the quickest and easiest way of getting started, you
sometimes need more flexibility to determine which parts of TensorFlow
your app should be shipped with. For such cases, you can build the iOS
libraries from the sources. <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/ios#building-the-tensorflow-ios-libraries-from-source" rel="noreferrer noopener nofollow">This guide</a> contains detailed instructions
on how to do that.</p>
</blockquote>

<p>这也可能有帮助:<a href="https://github.com/tensorflow/tensorflow/pull/14421" rel="noreferrer noopener nofollow"> Add optional Selective Registration of Ops #14421</a> </p>

<blockquote>
<p><strong>Optimization</strong></p>

<p>The <code>build_all_ios.sh</code> script can take optional
command-line arguments to selectively register only for the operators
used in your graph.</p>

<p><code>tensorflow/contrib/makefile/build_all_ios.sh -a arm64 -g $HOME/graphs/inception/tensorflow_inception_graph.pb</code></p>

<p>Please note this
is an aggresive optimization of the operators and the resulting
library may not work with other graphs but will reduce the size of the
final library.</p>
</blockquote>

<p>构建完成后,您可以检查 <code>/tensorflow/tensorflow/core/framework/ops_to_register.h</code> 以了解已注册的操作。 (在构建过程中使用 -g 标志自动生成)</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 iOS 上使用 TensorFlow 音频识别模型,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/47878659/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/47878659/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 iOS 上使用 TensorFlow 音频识别模型