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.

CCS: TDA4x: Input range -1 to 1 for Onnx Model

Tool/software: Code Composer Studio

Dear Sir,

We are using,

TIDL version: tidl_j7_01_00_00_00

Target Board: TDA4x

We have Onnx based model trained on floating data for which input Image is Normalized by subtracting mean and dividing by Standard Deviation.

In this case, our input range is -1 to 1 float value.

Q1. How to process the same in our model?

Q2. What could be the "inQuantfactor" to be used?

Kindly help us in this.

Thanks and Regards,

Vyom Mishra

  • Dear Sir,

    Gentle Reminder!!

    Thanks and Regards,

    Vyom Mishra

  • Hi Vyom,

     We already have support to do normalization as part of TIDL processing. You can enable this by setting inDataNorm = 1 in the import config file and you will have to provide the inScale and inMean for all the channels. You can refer the mobileNet import config to refer the same (ti_dl\test\testvecs\config\import\public\caffe\tidl_import_mobilenet_v1.txt )

      With these parameter TIDL will add a batch norm layer during the import which will do the scaling and mean shift. If following layer is a convolution layer then this layer can be merged to it.


    Regards,

    Anshu

  • Dear Sir,

    Thanks for the suggestion.

    We are doing the same on our side.

    But we are not sure about the "inQuantfactor" to be used.

    Observation:

    By following the above method and providing the "inQuantfactor=128"

    a) Please find the Import log for your reference 

    Num of Layer Detected :  77 
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Num|TIDL Layer Name               |Out Data Name                                     |Group |#Ins  |#Outs |Inbuf Ids                       |Outbuf Id |In NCHW                             |Out NCHW                            |MACS       |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        0|TIDL_DataLayer                |input_original                                    |     0|    -1|     1|  x   x   x   x   x   x   x   x |  0       |       0        0        0        0 |       1        3      336      512 |         0 |
        1|TIDL_BatchNormLayer           |input                                             |     0|     1|     1|  0   x   x   x   x   x   x   x |  1       |       1        3      336      512 |       1        3      336      512 |   2064384 |
        2|TIDL_ConvolutionLayer         |267                                               |     0|     1|     1|  1   x   x   x   x   x   x   x |  2       |       1        3      336      512 |       1       27      168      256 |  31352832 |
        3|TIDL_PoolingLayer             |268                                               |     0|     1|     1|  1   x   x   x   x   x   x   x |  3       |       1        3      336      512 |       1        3      168      256 |    516096 |
        4|TIDL_ConcatLayer              |269                                               |     0|     2|     1|  2   3   x   x   x   x   x   x |  4       |       1       27      168      256 |       1       30      168      256 |   1290240 |
        5|TIDL_BatchNormLayer           |271                                               |     0|     1|     1|  4   x   x   x   x   x   x   x |  5       |       1       30      168      256 |       1       30      168      256 |   2580480 |
        6|TIDL_ConvolutionLayer         |272                                               |     0|     1|     1|  5   x   x   x   x   x   x   x |  6       |       1       30      168      256 |       1       30       84      128 |  87091200 |
        7|TIDL_PoolingLayer             |273                                               |     0|     1|     1|  5   x   x   x   x   x   x   x |  7       |       1       30      168      256 |       1       30       84      128 |   1290240 |
        8|TIDL_ConvolutionLayer         |396                                               |     0|     1|     1|  5   x   x   x   x   x   x   x |  8       |       1       30      168      256 |       1        6      168      256 |   7741440 |
        9|TIDL_ConcatLayer              |274                                               |     0|     2|     1|  6   7   x   x   x   x   x   x |  9       |       1       30       84      128 |       1       60       84      128 |    645120 |
       10|TIDL_BatchNormLayer           |276                                               |     0|     1|     1|  9   x   x   x   x   x   x   x | 10       |       1       60       84      128 |       1       60       84      128 |   1290240 |
       11|TIDL_ConvolutionLayer         |279                                               |     0|     1|     1| 10   x   x   x   x   x   x   x | 11       |       1       60       84      128 |       1       30       84      128 |  19998720 |
       12|TIDL_ConvolutionLayer         |280                                               |     0|     1|     1| 11   x   x   x   x   x   x   x | 12       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       13|TIDL_ConvolutionLayer         |283                                               |     0|     1|     1| 12   x   x   x   x   x   x   x | 13       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       14|TIDL_ConvolutionLayer         |284                                               |     0|     1|     1| 13   x   x   x   x   x   x   x | 14       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       15|TIDL_ConvolutionLayer         |287                                               |     0|     1|     1| 14   x   x   x   x   x   x   x | 15       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       16|TIDL_ConcatLayer              |288                                               |     0|     2|     1| 15  10   x   x   x   x   x   x | 16       |       1       30       84      128 |       1       90       84      128 |    967680 |
       17|TIDL_ConvolutionLayer         |291                                               |     0|     1|     1| 16   x   x   x   x   x   x   x | 17       |       1       90       84      128 |       1       30       84      128 |  29675520 |
       18|TIDL_ConvolutionLayer         |292                                               |     0|     1|     1| 17   x   x   x   x   x   x   x | 18       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       19|TIDL_ConvolutionLayer         |295                                               |     0|     1|     1| 18   x   x   x   x   x   x   x | 19       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       20|TIDL_ConvolutionLayer         |296                                               |     0|     1|     1| 19   x   x   x   x   x   x   x | 20       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       21|TIDL_ConvolutionLayer         |299                                               |     0|     1|     1| 20   x   x   x   x   x   x   x | 21       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       22|TIDL_ConcatLayer              |300                                               |     0|     2|     1| 21  16   x   x   x   x   x   x | 22       |       1       30       84      128 |       1      120       84      128 |   1290240 |
       23|TIDL_ConvolutionLayer         |303                                               |     0|     1|     1| 22   x   x   x   x   x   x   x | 23       |       1      120       84      128 |       1       30       84      128 |  39352320 |
       24|TIDL_ConvolutionLayer         |304                                               |     0|     1|     1| 23   x   x   x   x   x   x   x | 24       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       25|TIDL_ConvolutionLayer         |307                                               |     0|     1|     1| 24   x   x   x   x   x   x   x | 25       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       26|TIDL_ConvolutionLayer         |308                                               |     0|     1|     1| 25   x   x   x   x   x   x   x | 26       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       27|TIDL_ConvolutionLayer         |311                                               |     0|     1|     1| 26   x   x   x   x   x   x   x | 27       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       28|TIDL_ConcatLayer              |312                                               |     0|     2|     1| 27  22   x   x   x   x   x   x | 28       |       1       30       84      128 |       1      150       84      128 |   1612800 |
       29|TIDL_ConvolutionLayer         |315                                               |     0|     1|     1| 28   x   x   x   x   x   x   x | 29       |       1      150       84      128 |       1       30       84      128 |  49029120 |
       30|TIDL_ConvolutionLayer         |316                                               |     0|     1|     1| 29   x   x   x   x   x   x   x | 30       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       31|TIDL_ConvolutionLayer         |319                                               |     0|     1|     1| 30   x   x   x   x   x   x   x | 31       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       32|TIDL_ConvolutionLayer         |320                                               |     0|     1|     1| 31   x   x   x   x   x   x   x | 32       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       33|TIDL_ConvolutionLayer         |323                                               |     0|     1|     1| 32   x   x   x   x   x   x   x | 33       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       34|TIDL_ConcatLayer              |324                                               |     0|     2|     1| 33  28   x   x   x   x   x   x | 34       |       1       30       84      128 |       1      180       84      128 |   1935360 |
       35|TIDL_ConvolutionLayer         |327                                               |     0|     1|     1| 34   x   x   x   x   x   x   x | 35       |       1      180       84      128 |       1       30       84      128 |  58705920 |
       36|TIDL_ConvolutionLayer         |328                                               |     0|     1|     1| 35   x   x   x   x   x   x   x | 36       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       37|TIDL_ConvolutionLayer         |331                                               |     0|     1|     1| 36   x   x   x   x   x   x   x | 37       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       38|TIDL_ConvolutionLayer         |332                                               |     0|     1|     1| 37   x   x   x   x   x   x   x | 38       |       1       30       84      128 |       1       30       84      128 |  29030400 |
       39|TIDL_ConvolutionLayer         |335                                               |     0|     1|     1| 38   x   x   x   x   x   x   x | 39       |       1       30       84      128 |       1       30       84      128 |  29675520 |
       40|TIDL_ConcatLayer              |336                                               |     0|     2|     1| 39  34   x   x   x   x   x   x | 40       |       1       30       84      128 |       1      210       84      128 |   2257920 |
       41|TIDL_ConvolutionLayer         |339                                               |     0|     1|     1| 40   x   x   x   x   x   x   x | 41       |       1      210       84      128 |       1      120       42       64 | 122572800 |
       42|TIDL_ConvolutionLayer         |392                                               |     0|     1|     1| 40   x   x   x   x   x   x   x | 42       |       1      210       84      128 |       1        6       84      128 |  13547520 |
       43|TIDL_ConvolutionLayer         |342                                               |     0|     1|     1| 41   x   x   x   x   x   x   x | 43       |       1      120       42       64 |       1       30       42       64 |   9838080 |
       44|TIDL_ConvolutionLayer         |343                                               |     0|     1|     1| 43   x   x   x   x   x   x   x | 44       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       45|TIDL_ConvolutionLayer         |346                                               |     0|     1|     1| 44   x   x   x   x   x   x   x | 45       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       46|TIDL_ConvolutionLayer         |347                                               |     0|     1|     1| 45   x   x   x   x   x   x   x | 46       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       47|TIDL_ConvolutionLayer         |350                                               |     0|     1|     1| 46   x   x   x   x   x   x   x | 47       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       48|TIDL_ConcatLayer              |351                                               |     0|     2|     1| 47  41   x   x   x   x   x   x | 48       |       1       30       42       64 |       1      150       42       64 |    403200 |
       49|TIDL_ConvolutionLayer         |354                                               |     0|     1|     1| 48   x   x   x   x   x   x   x | 49       |       1      150       42       64 |       1       30       42       64 |  12257280 |
       50|TIDL_ConvolutionLayer         |355                                               |     0|     1|     1| 49   x   x   x   x   x   x   x | 50       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       51|TIDL_ConvolutionLayer         |358                                               |     0|     1|     1| 50   x   x   x   x   x   x   x | 51       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       52|TIDL_ConvolutionLayer         |359                                               |     0|     1|     1| 51   x   x   x   x   x   x   x | 52       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       53|TIDL_ConvolutionLayer         |362                                               |     0|     1|     1| 52   x   x   x   x   x   x   x | 53       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       54|TIDL_ConcatLayer              |363                                               |     0|     2|     1| 53  48   x   x   x   x   x   x | 54       |       1       30       42       64 |       1      180       42       64 |    483840 |
       55|TIDL_ConvolutionLayer         |366                                               |     0|     1|     1| 54   x   x   x   x   x   x   x | 55       |       1      180       42       64 |       1       30       42       64 |  14676480 |
       56|TIDL_ConvolutionLayer         |367                                               |     0|     1|     1| 55   x   x   x   x   x   x   x | 56       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       57|TIDL_ConvolutionLayer         |370                                               |     0|     1|     1| 56   x   x   x   x   x   x   x | 57       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       58|TIDL_ConvolutionLayer         |371                                               |     0|     1|     1| 57   x   x   x   x   x   x   x | 58       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       59|TIDL_ConvolutionLayer         |374                                               |     0|     1|     1| 58   x   x   x   x   x   x   x | 59       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       60|TIDL_ConcatLayer              |375                                               |     0|     2|     1| 59  54   x   x   x   x   x   x | 60       |       1       30       42       64 |       1      210       42       64 |    564480 |
       61|TIDL_ConvolutionLayer         |378                                               |     0|     1|     1| 60   x   x   x   x   x   x   x | 61       |       1      210       42       64 |       1       30       42       64 |  17095680 |
       62|TIDL_ConvolutionLayer         |379                                               |     0|     1|     1| 61   x   x   x   x   x   x   x | 62       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       63|TIDL_ConvolutionLayer         |382                                               |     0|     1|     1| 62   x   x   x   x   x   x   x | 63       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       64|TIDL_ConvolutionLayer         |383                                               |     0|     1|     1| 63   x   x   x   x   x   x   x | 64       |       1       30       42       64 |       1       30       42       64 |   7257600 |
       65|TIDL_ConvolutionLayer         |386                                               |     0|     1|     1| 64   x   x   x   x   x   x   x | 65       |       1       30       42       64 |       1       30       42       64 |   7418880 |
       66|TIDL_ConcatLayer              |387                                               |     0|     2|     1| 65  60   x   x   x   x   x   x | 66       |       1       30       42       64 |       1      240       42       64 |    645120 |
       67|TIDL_ConvolutionLayer         |390                                               |     0|     1|     1| 66   x   x   x   x   x   x   x | 67       |       1      240       42       64 |       1        6       42       64 |   3902976 |
       68|TIDL_Deconv2DLayer            |391                                               |     0|     1|     1| 67   x   x   x   x   x   x   x | 68       |       1        6       42       64 |       1        6       84      128 |   6193152 |
       69|TIDL_ConcatLayer              |393                                               |     0|     2|     1| 68  42   x   x   x   x   x   x | 69       |       1        6       84      128 |       1       12       84      128 |    129024 |
       70|TIDL_ConvolutionLayer         |394                                               |     0|     1|     1| 69   x   x   x   x   x   x   x | 70       |       1       12       84      128 |       1        6       84      128 |    774144 |
       71|TIDL_Deconv2DLayer            |395                                               |     0|     1|     1| 70   x   x   x   x   x   x   x | 71       |       1        6       84      128 |       1        6      168      256 |  24772608 |
       72|TIDL_ConcatLayer              |397                                               |     0|     2|     1| 71   8   x   x   x   x   x   x | 72       |       1        6      168      256 |       1       12      168      256 |    516096 |
       73|TIDL_ConvolutionLayer         |398                                               |     0|     1|     1| 72   x   x   x   x   x   x   x | 73       |       1       12      168      256 |       1        6      168      256 |   3096576 |
       74|TIDL_Deconv2DLayer            |399                                               |     0|     1|     1| 73   x   x   x   x   x   x   x | 74       |       1        6      168      256 |       1        6      336      512 |  99090432 |
       75|TIDL_ArgMaxLayer              |output                                            |     0|     1|     1| 74   x   x   x   x   x   x   x | 75       |       1        6      336      512 |       1        1      336      512 |    172032 |
       76|TIDL_DataLayer                |output                                            |     0|     1|    -1| 75   x   x   x   x   x   x   x |  0       |       1        1      336      512 |       0        0        0        0 |         0 |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total Giga Macs : 1.3759
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    

    b) Output of layer 0( Data Layer)  

    c) Output of Layer 1(Batch Norm) 

    d) Import config file 

    #0: Caffe, 1: TensorFlow, 2: ONNX, Default - 0
    modelType = 2
    
    # Net definition from Training frames work. Example "deploy.prototxt" from caffe or frozen binary protobuf with parameters from tensorflow
    inputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\model.onnx"
    
    # Output TIDL model with Net and Parameters
    outputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\net.bin"
    
    # Input and output buffer descriptor file for TIDL ivsion interface
    outputParamsFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\param"
    
    # TIDL PC Reference executable file path for range collection. If not specified, uses from default location
    tidlStatsTool = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\test\tidl_quant_stats_tool.out.exe"
    
    # Bit depth for model parameters like Kernel, Bias etc; , Default - 8
    numParamBits = 8
    
    # Bit depth for Layer activatios; , Default - 8 , Max suported is 16. Any value > 8 is experimentel in the 00.08 release..
    numFeatureBits = 8
    
    # 0: Quantization method. Default : Non-power of two scale. 2- Power of 2 scales. can experiment with '3' (power of 2) for stable models
    quantizationStyle = 2
    
    # Scale factor of input feature, if the input range used in training is 0 to 1 and the same is passed as tansor range of 0 - 255 to TIDL then this parameters shall be 255
    inQuantFactor = 128
    
    # Format for input feature, 0 : 8bit Unsigned, 1 : 8bit Signed Default - 1
    inElementType = 1
    
    # Input tensors width
    inWidth = 512
    
    # Input tensors Height
    inHeight = 336
    
    # Input tensors Number of channels
    inNumChannels = 3
    
    # Fold Batch Normalization Layer into TIDL Lib Conv Layer
    #foldBnInConv2D = 1
    
    # Combine 2x2 with stride 2 Max Pool layer processing with previous convolution layer if possible
    #foldMaxPoolInConv2D = 1
    
    #Input File Format - 0 : Compressed Image (JPEG/PNG), 1: RAW Image, 2: Compressed Image List
    inFileFormat = 0
    
    # List of input tensor names in network to be imported. Will be usefull to import portion of network
    #inDataNamesList = "input"
    
    # List of output tensor names in network to be imported. Will be usefull to import portion of network
    #outDataNamesList = "output"
    
    # Enable / Disable Normalization on input tensor. Scale and mean values are applicable only if this is enabled
    inDataNorm = 1
    
    #Mean value needs to be subtracted for each channel of all input tensors
    inMean = 94.61594, 94.85598, 93.67584
    
    # List : Scale value needs to be multiplied after means subtract for each channel of all input tensors
    inScale = 0.0001394 0.0001347 0.0001308
    
    # List : Input tensor color format. RBG or BGR planar etc. Refer TIDL API guide for supported formats list
    inDataFormat = 0
    
    # Image resize type . Refer TIDL API guide for supported formats list
    inResizeType = 0
    
    # Image cropping is performed if resizeWidth > imWidth
    resizeWidth = 512
    
    # Image cropping is performed if resizeHeight > inHeight
    resizeHeight = 336
    
    Post processing on output tensor. 0 : Disable, 1- Classification top 1 and 5 accuracy, 2 – Draw bounding box for OD, 3 - Pixel level color blending
    postProcType = 0
    
    #Input tensors File for Reading
    inData = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\bgr_2.jpg"
    
    # Number of input tensors to be processed from the input file
    numFrames = 1
    

    We feel that our output of Batch Norm is wrong.

    Can you please guide us in resolving this issue.

    Thanks and Regards,

    Vyom Mishra

  • Hi Vyom, 
        inQuantFactor should be 1 as your input image will be a fixed point image. The scale to be applied for normalization should be given as part of inScale in the import config file.

    Regards,

    Anshu

  • Dear Sir,

    Thanks for the Suggestion for "inQuantfactor".

    We will follow and get back to you.

    Thanks and Regards,

    Vyom Mishra

  • Dear Sir,

    As per your suggestion, we have used the "inQuantfactor" equals to 1.

    The output generated by BatchNorm layer is given below: 

     

    And also find the Normalized image obtained in Pytorch below:

    As we observed that two images are different and hence our output of the model is also incorrect.

    What could be the possible reason for this behaviour.

    Kindly help us in this.

    Thanks and Regards,

    Vyom Mishra

  • Hi Vyom,

        Can you share the import config file which you used?

    Regards,

    Anshu

  • Dear Sir, 

    Please find the Import config file used for Importing the model.

    #0: Caffe, 1: TensorFlow, 2: ONNX, Default - 0
    modelType = 2
    
    # Net definition from Training frames work. Example "deploy.prototxt" from caffe or frozen binary protobuf with parameters from tensorflow
    inputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\model.onnx"
    
    # Output TIDL model with Net and Parameters
    outputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\net.bin"
    
    # Input and output buffer descriptor file for TIDL ivsion interface
    outputParamsFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\param"
    
    # TIDL PC Reference executable file path for range collection. If not specified, uses from default location
    tidlStatsTool = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\test\tidl_quant_stats_tool.out.exe"
    
    # Bit depth for model parameters like Kernel, Bias etc; , Default - 8
    numParamBits = 8
    
    # Bit depth for Layer activatios; , Default - 8 , Max suported is 16. Any value > 8 is experimentel in the 00.08 release..
    numFeatureBits = 8
    
    # 0: Quantization method. Default : Non-power of two scale. 2- Power of 2 scales. can experiment with '3' (power of 2) for stable models
    quantizationStyle = 2
    
    # Scale factor of input feature, if the input range used in training is 0 to 1 and the same is passed as tansor range of 0 - 255 to TIDL then this parameters shall be 255
    inQuantFactor = 128
    
    # Format for input feature, 0 : 8bit Unsigned, 1 : 8bit Signed Default - 1
    inElementType = 1
    
    # Input tensors width
    inWidth = 512
    
    # Input tensors Height
    inHeight = 336
    
    # Input tensors Number of channels
    inNumChannels = 3
    
    # Fold Batch Normalization Layer into TIDL Lib Conv Layer
    #foldBnInConv2D = 1
    
    # Combine 2x2 with stride 2 Max Pool layer processing with previous convolution layer if possible
    #foldMaxPoolInConv2D = 1
    
    #Input File Format - 0 : Compressed Image (JPEG/PNG), 1: RAW Image, 2: Compressed Image List
    inFileFormat = 0
    
    # List of input tensor names in network to be imported. Will be usefull to import portion of network
    #inDataNamesList = "input"
    
    # List of output tensor names in network to be imported. Will be usefull to import portion of network
    #outDataNamesList = "output"
    
    # Enable / Disable Normalization on input tensor. Scale and mean values are applicable only if this is enabled
    inDataNorm = 1
    
    #Mean value needs to be subtracted for each channel of all input tensors
    inMean = 94.61594, 94.85598, 93.67584
    
    # List : Scale value needs to be multiplied after means subtract for each channel of all input tensors
    inScale = 0.0001394 0.0001347 0.0001308
    
    # List : Input tensor color format. RBG or BGR planar etc. Refer TIDL API guide for supported formats list
    inDataFormat = 0
    
    # Image resize type . Refer TIDL API guide for supported formats list
    inResizeType = 0
    
    # Image cropping is performed if resizeWidth > imWidth
    resizeWidth = 512
    
    # Image cropping is performed if resizeHeight > inHeight
    resizeHeight = 336
    
    Post processing on output tensor. 0 : Disable, 1- Classification top 1 and 5 accuracy, 2 – Draw bounding box for OD, 3 - Pixel level color blending
    postProcType = 0
    
    #Input tensors File for Reading
    inData = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\bgr_2.jpg"
    
    # Number of input tensors to be processed from the input file
    numFrames = 1
    

    Thanks and Regards,

    Vyom Mishra

  • Hi Vyom,

          I see that you have separated inMean values by comma. Use space to separate values for different channels :

    inMean = 94.61594, 94.85598, 93.67584

    should be 

    inMean = 94.61594 94.85598 93.67584

    Regards,

    Anshu

  • Dear Sir,

    We removed the commas from the parameter "inMean" 

    but still facing a similar issue,

    please find the image below

    Please find the Import config used

    #0: Caffe, 1: TensorFlow, 2: ONNX, Default - 0
    modelType = 2
    
    # Net definition from Training frames work. Example "deploy.prototxt" from caffe or frozen binary protobuf with parameters from tensorflow
    inputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\model_ir_3_opset_8_h_w_4x4_deconv_fix.onnx"
    
    # Output TIDL model with Net and Parameters
    outputNetFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\eda_side_deconv_4x4_padding\eda_net.bin"
    
    # Input and output buffer descriptor file for TIDL ivsion interface
    outputParamsFile = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\eda_side_deconv_4x4_padding\eda_param"
    
    # TIDL PC Reference executable file path for range collection. If not specified, uses from default location
    tidlStatsTool = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\test\tidl_quant_stats_tool.out.exe"
    
    # Bit depth for model parameters like Kernel, Bias etc; , Default - 8
    numParamBits = 8
    
    # Bit depth for Layer activatios; , Default - 8 , Max suported is 16. Any value > 8 is experimentel in the 00.08 release..
    numFeatureBits = 8
    
    # 0: Quantization method. Default : Non-power of two scale. 2- Power of 2 scales. can experiment with '3' (power of 2) for stable models
    quantizationStyle = 2
    
    # Scale factor of input feature, if the input range used in training is 0 to 1 and the same is passed as tansor range of 0 - 255 to TIDL then this parameters shall be 255
    inQuantFactor = 1
    
    # Format for input feature, 0 : 8bit Unsigned, 1 : 8bit Signed Default - 1
    inElementType = 1
    
    # Input tensors width
    inWidth = 512
    
    # Input tensors Height
    inHeight = 336 
    
    # Input tensors Number of channels
    inNumChannels = 3
    
    # Fold Batch Normalization Layer into TIDL Lib Conv Layer
    #foldBnInConv2D = 1
    
    # Combine 2x2 with stride 2 Max Pool layer processing with previous convolution layer if possible
    #foldMaxPoolInConv2D = 1
    
    #Input File Format - 0 : Compressed Image (JPEG/PNG), 1: RAW Image, 2: Compressed Image List
    inFileFormat = 0
    
    # List of input tensor names in network to be imported. Will be usefull to import portion of network
    #inDataNamesList = "input"
    
    # List of output tensor names in network to be imported. Will be usefull to import portion of network
    #outDataNamesList = "output"
    
    # Enable / Disable Normalization on input tensor. Scale and mean values are applicable only if this is enabled
    inDataNorm = 1
    
    #Mean value needs to be subtracted for each channel of all input tensors
    inMean = 94.61594 94.85598 93.67584
    
    # List : Scale value needs to be multiplied after means subtract for each channel of all input tensors
    inScale = 0.0001394 0.0001347 0.0001308
    
    # List : Input tensor color format. RBG or BGR planar etc. Refer TIDL API guide for supported formats list
    inDataFormat = 0
    
    # Image resize type . Refer TIDL API guide for supported formats list
    inResizeType = 0
    
    # Image cropping is performed if resizeWidth > imWidth
    resizeWidth = 512
    
    # Image cropping is performed if resizeHeight > inHeight
    resizeHeight = 336
    
    Post processing on output tensor. 0 : Disable, 1- Classification top 1 and 5 accuracy, 2 – Draw bounding box for OD, 3 - Pixel level color blending
    postProcType = 0
    
    #Input tensors File for Reading
    inData = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\bgr_2.jpg"
    
    # Number of input tensors to be processed from the input file
    numFrames = 1
    

    Thanks and Regards,

    Vyom Mishra

  • Since you are enabling inDataNorm, comment below two lines in your import config file.


    #inQuantFactor = 1

    #inElementType = 1

  • Dear Sir,

    Thanks for the Suggestion.

    We have experimented the same on our side and got the below output from BatchNorm, which is still not matching with Pytorch output.

    we suspect there is swapping of channels (Blue and Red).

    Background: Pytorch model is trained with BGR input, So we provided BGR input to the import tool and "inDataFormat = 0"i.e., BGR_Planar in the config file.

    Please find the updated Import_config file for your reference

    modelType          = 2
    numParamBits       = 8
    inputNetFile      = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\model.onnx"
    outputNetFile      = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\net.bin"
    outputParamsFile   = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\param.bin"
    inDataNorm  = 1
    inMean = 94.61594 94.85598 93.67584
    inScale = 0.0001394 0.0001347 0.0001308
    resizeWidth = 512
    resizeHeight = 336
    inWidth  = 512
    inHeight = 336 
    inNumChannels = 3
    inData = E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\tidlModelImport\out\bgr_2.jpg
    postProcType = 0
    tidlStatsTool = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\test\tidl_quant_stats_tool.out.exe"
    perfSimConfig = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\test\testvecs\config\import\perfsim_base.cfg"
    perfSimTool = "E:\TIDL_workshop\TIDL_import_tool_v14_updated\tidl_j7_01_00_00_00\ti_dl\utils\perfsim\ti_cnnperfsim.out.exe"
    numFrames = 1
    inDataFormat = 0
    inFileFormat = 0

    Kindly help us to resolve the issue.

    Thanks and Regards,

    Vyom Mishra

  • Dear Sir,

    Gentle Reminder!!

    Any suggestions.

    Thanks and Regards,

    Vyom Mishra

  • Hi Vyom Mishra,

    How did you generate the image that you have shared here?

    Can you share the simail image for input layer as well

  • Dear Sir,

    a) we have read the float bin file for that layer using python, reshaped it to the respective dimension.

        Used "cv2normalize" method to normalize the image from 0-255 and then wrote an image using "cv2.imwrite"

    b) Please find the output of the data layer

    Thanks and Regards,

    Vyom Mishra

      

  • Dear Sir,

    Gentle Reminder!!

    Thanks and Regards,

    Vyom Mishra

  • Vyom Mishra,

     This image shall match with the image that is passed to the model during your training step. Can you compare this with your input in PyTorch.

  • Dear Sir,

    We have checked on our side and we have shared the images in the above replies.

    We suspect that Swapping is happening in DataLayer, Kindly confirm this or please provide us with the reason for this mismatch.

    Thanks and Regards,

    Vyom Mishra

  • Is this issue related to the below thread? If yes. I will close this read and we continue in the below

    https://e2e.ti.com/support/j721e/f/1026/t/864182