This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: Inference Performance Anomalies with TDA4VM

Part Number: TDA4VM

Tool/software: Jupyter Notebook

Hello,

I am currently using Processor SDK LINUX 10.00.00.08, Processor SDK RTOS 10.00.00.05, and EdgeAI TIDL 10_00_08_00.

My inference results with custom models on the EVM are poorer than those obtained during a previous study (same notebook, same model) using the older SDK version 08.01.00.02. I have noticed that the accuracy is also lower, and the performance is not as good, even though I am using the exact same model file as before.

When I compile the model with the options `tensor_bits=8` and `calibration_iterations=16`, I find that the inference results are incorrect if I use the same preprocessing function given by edgeai_tidl_tool example :

def preprocess(image_path, size, mean, scale, layout, reverse_channels):
    # Step 1
    img = cv2.imread(image_path)
    
    # Step 2
    img = img[:,:,::-1]
    
    # Step 3
    img = cv2.resize(img, (size[1], size[0]), interpolation=cv2.INTER_CUBIC)
     
    # Step 4
    img = img.astype('float32')
    for mean, scale, ch in zip(mean, scale, range(img.shape[2])):
            img[:,:,ch] = ((img.astype('float32')[:,:,ch] - mean) * scale)
    # Step 5
    if reverse_channels:
        img = img[:,:,::-1]
        
    # Step 6
    if layout == 'NCHW':
        img = np.expand_dims(np.transpose(img, (2,0,1)),axis=0)
    else:
        img = np.expand_dims(img,axis=0)
    
    return img

However, when I compile with other options, the inference produces correct results (see notebook).

So I tried an other preprocessing function for the inference with the compilation options `tensor_bits=8` and `calibration_iterations=16`. Now,  I am able to achieve inference with correct results, but the accuracy obtained is lower : 80% instead of 90%.

Could you please provide insights into the potential causes of this difference? Furthermore, I would appreciate any suggestions on changes I might implement to enhance my results. 

The model used with the notebook used (from jupyter notebook example of edgeai_tidl_tool) : 

6661.ssd_mobilenet_v2_300.zip

Thank you for your assistance.

Best regards,

Azer

  • Hi Azer; Thanks for providing the notebook file, this will help us greatly. I will load your notebook and try to run. 

    Now, what do you mean by "....compile with other options.....". We would like to know the exact differences you did. Are comparing the SDK 08.01 vs 10.00?

    Perhaps, you have already indicated in your notebook file; if not, please provide this info as well. 

    Best regards

    Wen Li

  • Hi, 

    1 ) To provide more details on the other compilation options yielding valid results, here are two examples:

    compile_options = {
        'tidl_tools_path' : os.environ['TIDL_TOOLS_PATH'],
        'artifacts_folder' : output_dir,
        'tensor_bits' : 8,
        'accuracy_level' : 1,
        'advanced_options:calibration_frames' : len(calib_images),
        'advanced_options:calibration_iterations' : 20,
    }
    
    compile_options = {
        'tidl_tools_path' : os.environ['TIDL_TOOLS_PATH'],
        'artifacts_folder' : output_dir,
        'tensor_bits' : 8,
        'accuracy_level' : 9,
        'advanced_options:calibration_frames' : len(calib_images),
        'advanced_options:calibration_iterations' : 16,
        'advanced_options:activation_clipping' : 1,
    }
    

    2 ) In a second phase, I compared the results obtained with SDK 08.01 and 10.00. The results from SDK 08.01 were similar to my findings on ARM, so I assume it is possible to achieve better accuracy with the `tensor_bits=8` and `calibration_iterations=16` options.

    Thank you for your assistance.

    Best regards,

    Azer

  • Hi,

    I am still experiencing the same issue. I have compared the results from SDK 08.01 and 10.00.

    The performance with SDK 10.00 is better on ARM compared to SDK 08.01. However, on C7x+MMA, the performance with SDK 10.00 is lower than with 08.01. I tried with differents models (pretrained and custom models with differents user options for compilation).

    Could you please share any insights into the possible reasons for this discrepancy? Additionally, I would appreciate any recommendations on changes I could make to improve my results.

    Thank you and regards,

    Azer

  • Hi,

    Do you have any recommendations on how I can improve performance of my model on C7x+MMA ? I already looked at this link edgeai-tidl-tools/examples/osrt_python at master · TexasInstruments/edgeai-tidl-tools · GitHub so do you have any advices ?

    Thank you very much

    Azer

  • Hi,

    Some performance improvements were made in 10.1, to address performance issues which were seen in 10.0.  Please try this with 10.1.

    Regards,

    Chris