<?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>topic Re: Model Size is too large in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2009907#M2138</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to train a model trough your dataset. I downloaded your dataset and train.py.&lt;/P&gt;
&lt;P&gt;How do you process the data?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 09:10:21 GMT</pubDate>
    <dc:creator>Harry_Zhang</dc:creator>
    <dc:date>2024-12-09T09:10:21Z</dc:date>
    <item>
      <title>Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1992405#M1960</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I came across a strange problem. I manually trained a small object detection CNN and successfully created the .tflite file. Then I use the eIQ toolkit to convert it into NPU-supported version (shown below).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_0-1731381228281.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/309898i5FC0124614EFBE27/image-size/large?v=v2&amp;amp;px=999" role="button" title="wklee_0-1731381228281.png" alt="wklee_0-1731381228281.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We can see that the input and output are in int8, which is great. The total size of this model is just 68KB.&lt;/P&gt;&lt;P&gt;However, when I loaded it to the MCXN947 board, I found that it was bloated up to 512KB!!!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_1-1731381409249.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/309901iD4F2B070EFA52963/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_1-1731381409249.png" alt="wklee_1-1731381409249.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was using the face detection example (dm-multiple-face-detection-on-mcxn947) from Application Code Hub, with small modifications on the &lt;SPAN&gt;MODEL_GetOpsResolver&lt;/SPAN&gt; so that it loads the necessary operations.&lt;/P&gt;&lt;P&gt;Anyone sees this problem before? Did I miss out anything else?&lt;/P&gt;&lt;P&gt;*When I tried with other CNN models, it does not have such a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 03:21:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1992405#M1960</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-11-12T03:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1993477#M1971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you export the model, do you select the "Export Quantized Model"?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image (5).png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310223i486EF545BCD06273/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image (5).png" alt="image (5).png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Hang&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 08:18:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1993477#M1971</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-11-13T08:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1993523#M1973</link>
      <description>&lt;P&gt;Dear Hang,&lt;/P&gt;&lt;P&gt;Yes, you can check both the attached file.&lt;/P&gt;&lt;P&gt;helmet_quantized.tflite --&amp;gt; Trained and quantized to 8-bit using python code on my host PC. I did not use the eIQ toolkit to train it.&lt;/P&gt;&lt;P&gt;helmet_quantized_converted.tflite --&amp;gt; This is the converted file using eIQv1.13. I use the eIQ Model Tool to open the helmet_quantized.tflite, then convert to NPU file.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_0-1731488416427.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310233iE2581355B347925E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_0-1731488416427.png" alt="wklee_0-1731488416427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_1-1731488444594.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310234i63D0A35CF2F35079/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_1-1731488444594.png" alt="wklee_1-1731488444594.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am using FRDM-MCXN947 board.&lt;/P&gt;&lt;P&gt;No quantization was selected because it was already quantized. You can see that the converted version also have 8-bit input and output. It is only ~67KB in size.&lt;/P&gt;&lt;P&gt;However, when I download the latest face detection demo and replace the original model with my helmet_quantized_converted.tflite , the size is much larger than expected.&lt;/P&gt;&lt;P&gt;*You may try converting my helmet_quantized.tflite, see if you get the same problem.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 09:01:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1993523#M1973</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-11-13T09:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1994210#M1981</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the compilation size of the &lt;SPAN&gt;face_detect.tflite&lt;/SPAN&gt; model.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Harry_Zhang_2-1731556305096.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310417iF40FE9CAC84E2FF8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Harry_Zhang_2-1731556305096.png" alt="Harry_Zhang_2-1731556305096.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the compilation size of the helmet_quantized_converted1.tflite model.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Harry_Zhang_1-1731556239852.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310416i72AEF715ADE94440/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Harry_Zhang_1-1731556239852.png" alt="Harry_Zhang_1-1731556239852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Hang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 03:53:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1994210#M1981</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-11-14T03:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1994291#M1982</link>
      <description>&lt;P&gt;Dear Hang,&lt;/P&gt;&lt;P&gt;The file size for helmet_quantized_converted is 68KB:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_1-1731563124363.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310453i290FAB868C4517B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_1-1731563124363.png" alt="wklee_1-1731563124363.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the compile size becomes 406.5KB, what could be the problem?&lt;/P&gt;&lt;P&gt;There are only ~70K parameters in this model.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_0-1731563083532.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310451iFD21B641BFD1D2E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_0-1731563083532.png" alt="wklee_0-1731563083532.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 05:46:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1994291#M1982</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-11-14T05:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1995333#M1990</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Harry_Zhang_0-1731662233218.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/310768iF86D3B8BBA076794/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Harry_Zhang_0-1731662233218.png" alt="Harry_Zhang_0-1731662233218.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can check the liker script.&lt;/P&gt;
&lt;P&gt;It includes the *(.ezh_code) and *(.model_input_buffer).&lt;/P&gt;
&lt;P&gt;So&amp;nbsp;the compile size becomes 406.5KB.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 09:19:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/1995333#M1990</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-11-15T09:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2003495#M2059</link>
      <description>&lt;P&gt;I don't think that's the reason.&lt;/P&gt;&lt;P&gt;The ezh_code is very small, only 512*4=2KB.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_1-1732780150006.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/313042i528E8AA1F4681DE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_1-1732780150006.png" alt="wklee_1-1732780150006.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I verify this point by checking the original compilation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_0-1732780129871.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/313041i0DE4FB329BE49335/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_0-1732780129871.png" alt="wklee_0-1732780129871.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then modify the ezh_code to only ezh_code[2], which is 8 bytes.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wklee_2-1732780197711.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/313043iDB9D9CEC1A3A5FB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wklee_2-1732780197711.png" alt="wklee_2-1732780197711.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see that the SRAMX region is only changed a little.&lt;/P&gt;&lt;P&gt;I think that the problem should be some problems during the conversion from a trained model to the NPU version. If the trained model is in int8 and contains only 70K parameters, there is no reason for the size to grow up to so big (400KB+).&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2024 07:54:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2003495#M2059</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-11-28T07:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2004210#M2067</link>
      <description>&lt;P&gt;Sorry for not making the problems clear.&lt;/P&gt;&lt;P&gt;In my first post, I mentioned that the model that I trained only has ~67 K parameters, so I expect that after int8 quantization the size should be around 70KB. However, when it is loaded onto the MCU (FRDM-MCXN947), I see the size grows to ~512KB, which is not what I expected, see the serial port information below.&lt;/P&gt;&lt;P&gt;&lt;IMG border="0" alt="" /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="helmet_model.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/313285iC65E532A0A51A846/image-size/medium?v=v2&amp;amp;px=400" role="button" title="helmet_model.png" alt="helmet_model.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 08:43:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2004210#M2067</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-11-29T08:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2005068#M2088</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to convert this model in two ways and ran it on mcxn947, both of which encountered the same error. I think it's a problem with the model itself.&lt;/P&gt;
&lt;P&gt;If your model includes operations unsupported by the NPU, increasing the size.&lt;/P&gt;
&lt;P&gt;How did you train this model?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 10:14:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2005068#M2088</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-12-02T10:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2005799#M2095</link>
      <description>&lt;P&gt;The code can be found in the attachment. It is a customized CNN that performs object detection (helmet).&lt;/P&gt;&lt;P&gt;The training dataset is here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1xXwR6-OhXmePOGtyy9Yxn0bdhv3gmu4y/view?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1xXwR6-OhXmePOGtyy9Yxn0bdhv3gmu4y/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 07:49:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2005799#M2095</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-12-03T07:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2009907#M2138</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/231824"&gt;@wklee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to train a model trough your dataset. I downloaded your dataset and train.py.&lt;/P&gt;
&lt;P&gt;How do you process the data?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 09:10:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2009907#M2138</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-12-09T09:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Model Size is too large</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2016789#M2210</link>
      <description>&lt;P&gt;Hi Harry Zhang,&lt;/P&gt;&lt;P&gt;I choose to compress the model into very small so that it can fit into the MCXN947 MCU. Although this does not solve the issue, it works for my project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time and effort to support.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 03:14:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Model-Size-is-too-large/m-p/2016789#M2210</guid>
      <dc:creator>wklee</dc:creator>
      <dc:date>2024-12-19T03:14:20Z</dc:date>
    </item>
  </channel>
</rss>

