# Model inference wrong

**URL:** <https://community.topst.ai/t/model-inference-wrong/741>\
**Category:** AI\
**Created:** [November 8, 2025, 7:31am UTC](https://community.topst.ai/t/model-inference-wrong/741 "2025-11-08T07:31:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [November 8, 2025, 7:31am UTC](https://community.topst.ai/t/model-inference-wrong/741/1 "2025-11-08T07:31:55Z")

</div>

Hello.

I have model monocular depth estimation and complete compilation and quantization. But on AI-G doesn’t inference, it just return as input video. Can you check all my command and model.

> **[midas\_v2.1\_small - Google Drive](https://drive.google.com/drive/folders/1sG2Y2ErYo1xt7VTtCJWNorETDir4bYhS?usp=sharing)**

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [November 10, 2025, 12:32am UTC](https://community.topst.ai/t/model-inference-wrong/741/2 "2025-11-10T00:32:51Z")

</div>

Hello. This is TOPST.  
Have you resolved the camera-related issue you previously asked about?  
First, you converted the model to an unknown type, but currently only classification and object detection models can be inferred in the toolkit and inference app.  
Slight modifications are required to use other types of models.

First, the output tensor is currently output in custom\_postproc.c within the build\_network directory’s custom\_postproc and in post\_process.c within the compiled network.

Currently, it simply outputs the output tensor, so it may appear that no visualization or inference is being performed. You need to analyze this tensor, perform postprocessing, and then retrieve the corresponding tensor values ​​from ai-g’s tcnnapp for visualization.

In tcnnapp, you need to modify the postprocessing steps in NnAppMain.c, which we shared previously, when the model type is custom.  
You also need to modify NnNeuralNetwork.c to determine which structure the values ​​are stored in when the model type is custom.

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/75363a9836c057790817cfdfb570a1ecc61b515d.png)

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/09da397e9908b2ad14d44ffd891ec70220d0d446.png)

A model conversion guide for custom types is currently being prepared.  
Please understand that the materials are still insufficient. Please feel free to contact us with any further questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [November 14, 2025, 7:09am UTC](https://community.topst.ai/t/model-inference-wrong/741/3 "2025-11-14T07:09:15Z")

</div>

Hello.

So i need to modify custom\_postproc.c in tc-nn-toolkit to convert, quantize and compile model from tflite to enlight type.

After that, I modify postprocessing in NnAppMain.c and NnNeuralNetwork.c then rebuild AI-G. however, i see 2 line NPU\_POST\_CUSTOM in NnAppMain.c. do i need to modify all of this?

One in NnDrawResult(app\_context\_t \*pContext) funtion,

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/cbbdd1a9968d3717c0e1ab570a28a1e178533f22.png)

One in NnOutputResultData(app\_context\_t \*pContext, MessageHandle msgHandle) funtion.

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/7228e4baa4d0829c6a10fdd8191458d10f90702e.png)

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [November 14, 2025, 9:00am UTC](https://community.topst.ai/t/model-inference-wrong/741/4 "2025-11-14T09:00:48Z")

</div>

Yes, you can modify both. I handled everything in the function above, so NnOutputResultData was left empty..

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [November 25, 2025, 9:00am UTC](https://community.topst.ai/t/model-inference-wrong/741/5 "2025-11-25T09:00:13Z")

</div>

Hello.

I’m working on another Linux server that never had the AI-G firmware installed. I build `bitbake -c compile -f tc-nn-app` instead of running `bitbake telechips-topst-ai-image` at step 3.6 . Then, I modify postprocessing in NnAppMain.c and NnNeuralNetwork.c.

After that, how do I rebuild AI-G/tcnnapp? just follow session 3.7 in [TOPST](https://topst.ai/tech/docs?page=23d4fc61a909643df78e63a70a0f855a1501cd14) ?

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [November 25, 2025, 1:53pm UTC](https://community.topst.ai/t/model-inference-wrong/741/6 "2025-11-25T13:53:22Z")

</div>

Hello,  
After making the modifications, run ‘bitbake -c compile -f tc-nn-app’ again.  
Then, as shown in the picture below, navigate to the build directory of tcnnapp, and you should be able to see the built tcnnapp.  
 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/6b53babe0ec56057a5f9d9a27f0af5bebe478333.png)  
After transferring the app to the board using the scp command, set the permission with “chmod 755 tcnnapp” and run it with “./tcnnapp”.  
Thank you.

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [December 12, 2025, 8:52am UTC](https://community.topst.ai/t/model-inference-wrong/741/7 "2025-12-12T08:52:18Z")

</div>

Hello.

I have analyze output model but it custom\_postproc.c, then convert, quantized and compile model.  
Can I handle all postprocessing in custom\_postproc.c ?

Is the output from the custom\_postproc.c file passed to NnNeuralNetwork.c and then to NnAppMain?

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [December 15, 2025, 1:09am UTC](https://community.topst.ai/t/model-inference-wrong/741/8 "2025-12-15T01:09:06Z")

</div>

Hello.

This is the TOPST manager. First, post-processing is handled in custom\_postproc.c and post\_process.c within the model.

In post\_process.c, the output tensor is obtained through the API, and post-processing is performed on it in custom\_postproc.c.

After that, in tc-nn-app, the post-processed results are obtained through the NPU API, and in NnAppMain.c, this value is used to perform post-processing tasks such as visualization.

In the post-processing code, you should declare a structure for the value created from the obtained tensor, then declare the same structure within the tc-nn-app source code, and you can receive these values.

Thank you.

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [March 5, 2026, 8:26pm UTC](https://community.topst.ai/t/model-inference-wrong/741/9 "2026-03-05T20:26:26Z")

</div>

Hello.

I have declared struct Depth in post\_process.c and NnType.h.

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/9f8cea4e2559208ed0f65a8d6f1428f8bee96859.png)

I declare “DepthResult depth;” in both custom\_postproc.c and NnAppmain.c and “extern DepthResult depth” in NnNeuralNetwork.c and NnRtpm.c. then “bitbake -c compile -f tcnnapp”, chmod successfully.

But when i try “./tcnnapp -n midas3\_quantized/”, It freezes even though I didn’t add any logic. Are there any other files I need to modify?

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/406d93262d8d7ca494fd48d00fa4c2d454a805e4.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [March 9, 2026, 4:09am UTC](https://community.topst.ai/t/model-inference-wrong/741/10 "2026-03-09T04:09:58Z")

</div>

Hello.  
Could you please send me the modified app source code and post-processing code?  
I’ll get back to you after testing.

Thank you.

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [March 9, 2026, 8:24am UTC](https://community.topst.ai/t/model-inference-wrong/741/11 "2026-03-09T08:24:41Z")

</div>

This drive incude git, midas3\_quantized and custom\_postproc.c.

> **[midas\_v2.1\_small - Google Drive](https://drive.google.com/drive/folders/1sG2Y2ErYo1xt7VTtCJWNorETDir4bYhS?usp=drive_link)**

in source code, I modified in NnType.h for new struct, new enum \_message\_result\_type in message\_api.h. NnDrawResult in NnAppMain.c, NnRunInference in NnNeuralNetwork.c and RtpmSendResultDataAsJson in NnRtpm.c.

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [March 10, 2026, 8:44am UTC](https://community.topst.ai/t/model-inference-wrong/741/12 "2026-03-10T08:44:39Z")

</div>

Hello  
First, I ran the app and model you provided.  
Command used: ./tcnnapp -N midas3\_quantized/

I used the camera and display output, and in the case of midas, inference proceeded, but no subsequent logs were output, whereas in the case of YOLO, I confirmed that inference proceeded.

Also, when running the unchanged tcnnapp -N midas3\_quantized/, I confirmed that the inference logs were displayed correctly.

Since there is no problem with the model, I analyzed the tcnnapp source.  
In NnNeuralNetwork.c, for the custom type, the call to the network\_run\_postprocess() function, which starts post-processing, is missing.

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/topst/original/1X/27b610fafef475fea9d48d33cb993b14e1e92d70.png)

If you just add the function call in that part, it should resolve the issue without any problem.  
Thank you~

---

<div class="post-metadata">

**Author:** ![CafNar](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.topst.ai/cafnar/32/706_2.png) [@CafNar](https://community.topst.ai/u/CafNar)\
**Post date:** [March 11, 2026, 7:43am UTC](https://community.topst.ai/t/model-inference-wrong/741/13 "2026-03-11T07:43:32Z")

</div>

Thanks for your help. It’s works.

For color visualization in RTPM and display, Which file should I need to modify?

Thank you.

---

<div class="post-metadata">

**Author:** ![TOPST-manager-cy](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TOPST-manager-cy](https://community.topst.ai/u/TOPST-manager-cy)\
**Post date:** [March 12, 2026, 1:02am UTC](https://community.topst.ai/t/model-inference-wrong/741/14 "2026-03-12T01:02:59Z")

</div>

For display visualization, you can add custom type logic inside the NnDrawResult function in the NnAppMain.c file. OpenCV-related functions exist in git/common/utils, so it would be good to refer to them.

In the case of RTPM, after sending the inference result values to RTPM, you can modify model-\>PostProcessor.py in the RTPM folder.  
Thank you.
