<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックRe: Run a TensorFlow model on i.MX 8M Plus</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1278253#M174213</link>
    <description>&lt;DIV class="s-prose js-post-body"&gt;
&lt;P&gt;You need change the dtype from np.float32 to np.uint8:&lt;/P&gt;
&lt;PRE class="lang-py s-code-block hljs python"&gt;&lt;CODE&gt;input_data = np.array(np.random.random_sample(input_shape), dtype=np.uint8)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can always check with&lt;/P&gt;
&lt;PRE class="lang-py s-code-block hljs python"&gt;&lt;CODE&gt;&lt;SPAN class="hljs-built_in"&gt;print&lt;/SPAN&gt;(interpreter.get_input_details())
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which dtype is required&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 18 May 2021 13:13:00 GMT</pubDate>
    <dc:creator>Bio_TICFSL</dc:creator>
    <dc:date>2021-05-18T13:13:00Z</dc:date>
    <item>
      <title>Run a TensorFlow model on i.MX 8M Plus</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1272957#M173674</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to test a TensorFlow custom model on the&amp;nbsp;i.MX 8M Plus processor. I have generated the "saved_model.pb" file, how could I run it on the processor?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Pablo.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 10:39:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1272957#M173674</guid>
      <dc:creator>pablomoreno555</dc:creator>
      <dc:date>2021-05-06T10:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Run a TensorFlow model on i.MX 8M Plus</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1273031#M173683</link>
      <description>&lt;P&gt;Hello pablomoreno555,&lt;/P&gt;
&lt;P&gt;You can start reading the machine learning guide document in your yocto documentation, it has example of how to upload&amp;nbsp; a different models.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 13:04:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1273031#M173683</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2021-05-06T13:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Run a TensorFlow model on i.MX 8M Plus</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1275605#M173929</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Following the documentation, I have converted my TensorFlow model into ".tflite". Then, I have performed the benchmark with this command:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# ./benchmark_model --graph=&amp;lt;name_of_the_model.tflite&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;and everything is OK. However, when I try&amp;nbsp;to run the model using PyeIQ, with the following command:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# pyeiq --run object_detection_ tflite --model &amp;lt;name_of_the_model.tflite&amp;gt; -- labels &amp;lt;name_of_the_labelmap.txt&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INFO: Created TensorFlow Lite delegate for NNAPI.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Failed to apply NNAPI delegate.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/bin/pyeiq", line 144, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;PyeIQ().main()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/bin/pyeiq", line 138, in main&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;self.run(self.args.run)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/bin/pyeiq", line 119, in run&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;self.pyeiq_set[target]().run()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/lib/python3.7/site-packages/eiq/modules/detection/object_detection_ssd.py", line 133, in run&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;self.start()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/lib/python3.7/site-packages/eiq/modules/detection/object_detection_ssd.py", line 129, in start&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;self.labels = self.load_labels(self.labels)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/lib/python3.7/site-packages/eiq/modules/utils.py", line 133, in load_labels&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return {int(num): text.strip() for num, text in lines}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/lib/python3.7/site-packages/eiq/modules/utils.py", line 133, in &amp;lt;dictcomp&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return {int(num): text.strip() for num, text in lines}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;File "/usr/lib/python3.7/site-packages/eiq/modules/utils.py", line 132, in &amp;lt;genexpr&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;lines = (p.match(line).groups() for line in f.readlines())&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;AttributeError: 'NoneType' object has no attribute 'groups'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I wanted to know how could I solve it.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 11:38:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1275605#M173929</guid>
      <dc:creator>pablomoreno555</dc:creator>
      <dc:date>2021-05-12T11:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Run a TensorFlow model on i.MX 8M Plus</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1278173#M174209</link>
      <description>&lt;P&gt;I have converted the TensorFlow model into &lt;EM&gt;*.tflite&lt;/EM&gt; using the following script:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;import&amp;nbsp;tensorflow&amp;nbsp;as&amp;nbsp;tf&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;converter&amp;nbsp;=&amp;nbsp;tf.lite.TFLiteConverter.from_saved_model('saved_model')&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;converter.optimizations&amp;nbsp;=&amp;nbsp;[tf.lite.Optimize.DEFAULT]&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;converter.target_spec.supported_ops&amp;nbsp;=&amp;nbsp;[tf.lite.OpsSet.TFLITE_BUILTINS_INT8]&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;converter.experimental_new_converter&amp;nbsp;=&amp;nbsp;True&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;converter.target_spec.supported_types&amp;nbsp;=&amp;nbsp;[tf.int8]&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;converter.inference_input_type&amp;nbsp;=&amp;nbsp;tf.int8&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;converter.inference_output_type&amp;nbsp;=&amp;nbsp;tf.int8&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;quantized_tflite_model&amp;nbsp;=&amp;nbsp;converter.convert()&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;open('quant_model.tflite'&amp;nbsp;,&amp;nbsp;"wb").write(quantized_tflite_model)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I run this model with the image classification example:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;# ./label_image -m &amp;lt;converted_model.tflite&amp;gt; -i grace_hopper.bmp -l &amp;lt;labelmap.TXT&amp;gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I get a proper output, but when I run it with pyeiq, using the command:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;# pyeiq --run object_detection_tflite --model converted_model.tflite --labels labelmap.TXT&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I get the following error:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;ValueError: Cannot set tensor: Got value of type UINT8 but expected type FLOAT32 for input 0, name: serving_default_input:0&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Could anyone help me, please?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 May 2021 10:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1278173#M174209</guid>
      <dc:creator>pablomoreno555</dc:creator>
      <dc:date>2021-05-18T10:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run a TensorFlow model on i.MX 8M Plus</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1278253#M174213</link>
      <description>&lt;DIV class="s-prose js-post-body"&gt;
&lt;P&gt;You need change the dtype from np.float32 to np.uint8:&lt;/P&gt;
&lt;PRE class="lang-py s-code-block hljs python"&gt;&lt;CODE&gt;input_data = np.array(np.random.random_sample(input_shape), dtype=np.uint8)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can always check with&lt;/P&gt;
&lt;PRE class="lang-py s-code-block hljs python"&gt;&lt;CODE&gt;&lt;SPAN class="hljs-built_in"&gt;print&lt;/SPAN&gt;(interpreter.get_input_details())
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which dtype is required&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 May 2021 13:13:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-a-TensorFlow-model-on-i-MX-8M-Plus/m-p/1278253#M174213</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2021-05-18T13:13:00Z</dc:date>
    </item>
  </channel>
</rss>

