Ticket Name: Linux/TDA2PXEVM: Application for the new adaboost weight file to usecase of the Analytics2 Query Text: Part Number: TDA2PXEVM Tool/software: Linux Dear, I did training PD with the Caltech Pedestrian data-set. I converted *.descriptor to *.bin file using AdaboostTableGen.exe. I'm reading the userguide of the "ObjectDetection". After I replace the pd_adaboost_weight.bin to new one(then need not modification of the object_detection.cfg file), what I do? I ran the analytics2 usecase with EVM board. I'd like to apply the new weight training file to check the improvement of the PD. Best regards, Heechang Responses: I have looped in the experts for using the trained descriptor in VisionSDK. There is an ongoing thread on this topic. Kindly refer the same. TDA2: AdaBoost Training with CaltechUsa We are also in the process of providing a reference implementation as part of next SDK release. Regards, Shyam Hi Shyam, I read the similar topic that thread. It mixed the topic of the host emulation build and the VSDK. I'd like to apply *.bin for vision_sdk. Should I do test application if I apply this bin file? After I build the OD library, can I apply this library to usecase directly on EVM board? Since I ran the analytics2 usecase on EVM, I think that the it is fine to replace the OD library. Best regards, Heechang Hi Heechang, I think there are two separate things here. The OD library comes with a small test bench where one can provide a new .bin file or modify the .cfg file to take the new file. But by just replacing the .bin file you will not be able to run the analytics2 use case on EVM. On a high level, you will have put the new bin file in a SD card and let ARM/M3 read this file from SD card to a buffer. Once read, the buffer has to be passed from ARM/M3 to DSP at the time of initializatoin. Now DSP can take this buffer with updated weights and run the algorithm. Regards, Shyam Hi Shyam, I understand there are two cases, right? 1. If I run the test bench with a new .bin file, can I use the new OD library for running the analytics2? Should I build the test application with OD userguide document? 2. In SD card, read a new .bin file to buffer. In this function of AlgorithmLink_objectDetectionCreate() in objectDetectionLink_algPlugin.c, should I read a file with size to a buffer? ... pObjectDetectObj->inBufDescList[TI_OD_IN_BUFDESC_FEATURE_PLANES] = &pObjectDetectObj->inBufDesc; pObjectDetectObj->outBufDescList[TI_OD_OUT_BUFDESC_OBJECT_LIST] = &pObjectDetectObj->outBufDesc[0]; pObjectDetectObj->outBufDescList[TI_OD_OUT_BUFDESC_DETECTION_LIST] = &pObjectDetectObj->outBufDesc[1]; ... There are input and output buffer descriptors. Please let me know some sample code . Best regards, Heechang Hi Shyam, In case of high level, I inserted the file open code in usecase and buffer code in function of the AlgorithmLink_objectDetectionInitIOBuffers(). I referenced code by TestApp_AllocIOBuffers(IVISION_InBufs * inBufs,IVISION_OutBufs * outBufs). Is this right? Or some code should be inserted? Best regards, Heechang Hi Shyam, I confirmed the read the binary file. In function of the AlgorithmLink_objectDetectionInitIOBuffers() in objectDetectionLink_algPlugin.c, I inserted the code like this. pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->numPlanes = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.x = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.y = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].width = 40*1024; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].height = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.width = 40*1024; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.height = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].planeType = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = (void *)pObj->algLinkCreateParams.pWeightPDBuf; I ran the object detection usecase but it looks same result before the read the binary file. Best regards, Heechang Somebody help me, please. Best regards, Heechang Hi Heechang, Sorry for a late reply, your implementation is correct. Can you please confirm if you are setting the flag useExtWeightsPD = 1 as passing it in? pObj->inArgs.pdConfig.useExtWeightsPD = pObj->algLinkCreateParams.useExtWeightsPD; Regards, Shyam Yes, I set the "pObj->inArgs.pdConfig.useExtWeightsPD = 1;" in function of the "AlgorithmLink_objectDetectionSetIOArgs() in objectDetectionLink_algPlugin.c. I modified the code like below. { .... UInt8 *pTransBuf; UInt8 pWeightPDBuf; } AlgorithmLink_ObjectDetectionCreateParams; //for input buffer AlgorithmLink_objectDetectionInitIOBuffers() { ... pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->numPlanes = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.x = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.y = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].width = 40*1024; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].height = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.width = 40*1024; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.height = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].planeType = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = (void *)pObj->algLinkCreateParams.pWeightPDBuf; ... } //for setting the external flag AlgorithmLink_objectDetectionSetIOArgs() { ... pObj->inArgs.pdConfig.useExtWeightsPD = 1; //before "0" ... } //for file read Void Chains_ReadAdaboostFromFile(AlgorithmLink_ObjectDetectionCreateParams *pOdPrm, char *fileName) { Int32 status; UInt32 dataSize = 0; pOdPrm->pTransBuf = OSA_memAllocSR(OSA_HEAPID_DDR_CACHED_SR1, PD_FILE_MAX_SIZE, 128); if(!pOdPrm->pTransBuf) { Vps_printf("Adaboost memory alloc error!!\n"); } status = OSA_fileReadFile( fileName, pOdPrm->pTransBuf, PD_FILE_MAX_SIZE, &dataSize ); if(status == OSA_EFAIL) { Vps_printf("Adaboost file read error!!\n"); } OSA_memCacheWb((Uint32)pOdPrm->pTransBuf, (Uint32)pOdPrm->pTransBuf + (PD_FILE_MAX_SIZE)); pOdPrm->pWeightPDBuf = OSA_memVirt2Phys((UInt32)pOdPrm->pTransBuf, OSA_MEM_REGION_TYPE_AUTO); } I ran the usecase on Linux. Best regards, Heechang Heechang >> I ran the object detection usecase but it looks same result before the read the binary file. Did you try checking the output detections and score? Does it give the same number of detections and values? I tested it with still images. It is same for detecting tree or traffic signal as a person. The number of detections is same. Could you check my code that is correct or not? I did training with INRIA dataset. So, I additionally do training more dataset including INRIA dataset. Best regards, Heechang Hi Shyam, It looks that it is no taking effect. I modified the code for testing like below. pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = NULL; The test result is same. But, I confirmed that the file buffer was filled. Best regards, Heechang I'm working on Linux not RTOS. If I comment the OSA_memVirt2Phys() like below, the result is same. //pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = (void*)pObj->algLinkCreateParams.pWeightPDBuf; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = pObj->algLinkCreateParams.pTransBuf; // file read // pOdPrm->pWeightPDBuf = OSA_memVirt2Phys((UInt32)pOdPrm->pTransBuf, OSA_MEM_REGION_TYPE_AUTO); There is no taking effect. What's the problem? Is the external binary of the PD working on Linux? Best regards, Heechang Hi Shyam, I enabled enablePD in usecase function. Its value is set pObj->inArgs.pdConifg.enablePD = pObj->algLinkCreateParams.enablePD in AlgorithmLink_objectDetectionSetIOArgs(). But, If I set in here like pObj->inArgs.pdConifg.enablePD = 1 or 0, it is not taking effect. This "AlgorithmLink_objectDetectionSetIOArgs" function is called but, the pdConfig values is no taking effect!! So, I guess that the useExtWeightsPD also is not taking effect. What is problem? Best regards, Heechang In AlgorithmLink_objectDetectionProcess(), I set useExtWeightsPD. But the result is same. BR, Heechang Hi Heechang, We have certainly verified the functionality of providing weights externally to the OD library. But in the Linux usecase scenario we are yet to try it out. It is possible that something is broken, so kindly allow us some time to investigate. We will post updates on this thread once we've reproduced and fixed the issue. Regards, Shyam Hi Shyam, Okay, thank you very much. I think that something is strange on Linux. Best regards, Heechang Hi Shyam, I have a question. Then, if I use external binary file on RTOS, it was verified? I will try it on RTOS, too. Best regards, Heechang Hi Heechang, We have only tested the OD library with this feature, so we will be investigating both on RTOS and Linux. Please feel free to try RTOS as well. Regards, Shyam Hi Shyam, I'm trying out training model with OD library on Windows10. I read the document that "3.3.6 Building the Test Application Executable through GMAKE" in Objectdetection_DSP_Userguide.pdf. I followed this description but when I build the makefile at "4) Build the sample test application project by gmake" the build error is shown. "System cannot find the path specified" I installed the file followed by "3.3 Building Sample Test Application". Should I modify the makefile? Best regards, Heechang In \makerules\config.mk, there are the path of tools. I think it should be modified, right? BR, Heechang If right, what the path of the ARP32_TOOLS and TIARM_TOOLS are correct path in VSDK3.6? And the VXLIB_PATH is VLIB PATH? BR, Heechang I modified the path in config.mk. When I build the error is shown. compiling .\.\src\object_detection_config.c >> WARNING: more than one source file is specified; preprocessor output will be generated for last file only [Files.] Fatal error: cannot open source file "Files" 1 catastrophic error detected in the compilation of "Files". Compilation terminated. >> Compilation failure make: *** [C:\PROCESSOR_SDK_VISION_03_06_00_00\ti_components\algorithms\REL.200.V.OD.C66X.00.06.02..] error 1 What is problem? BR, Heechang DSP_TOOLS ?="C:\cgt8.3.1" ARP32_TOOLS ?="C:\ti\ccsv8\tools\compiler\gcc-arm-none-eabi-7-2017-q4-major-win32" TIARM_TOOLS ?="C:\ti\ccsv8\tools\compiler\ti-cgt-arm_18.1.4.LTS" XDAIS_PATH ?="C:\ti\ccsv8\xdais_7_24_00_04" UTILS_PATH ?="C:\ti\ccsv8\utils\cygwin" VXLIB_PATH ?="C:\ti\vlib_c66x_3_3_2_0" DMAUTILS_PATH ?="C:\Program Files (x86)\REL.DMAUTILS.00.08.00.02\REL.DMAUTILS.00.08.00.02\dmautils" ALGFRAMEWORK_PATH ?=$(ALGBASE_PATH)/algframework I modified the path like above BR, Heechang Can you try installing DMAUTILS in a different path? the c:\Program Files (x86) path could be causing some problem. Regards, Shyam I modified the path like this("C:\ti\REL.DMAUTILS.00.08.00.02\dmautils") but the error is same. BR, Heechang Please tell me if I should modify the configure or path. DSP_TOOLS ?="C:\cgt8.3.1" ARP32_TOOLS ?="C:\ti\ccsv8\tools\compiler\gcc-arm-none-eabi-7-2017-q4-major-win32" TIARM_TOOLS ?="C:\ti\ccsv8\tools\compiler\ti-cgt-arm_18.1.4.LTS" XDAIS_PATH ?="C:\ti\ccsv8\xdais_7_24_00_04" UTILS_PATH ?="C:\ti\ccsv8\utils\cygwin" VXLIB_PATH ?="C:\ti\vlib_c66x_3_3_2_0" DMAUTILS_PATH ?="C:\ti\REL.DMAUTILS.00.08.00.02\dmautils" ALGFRAMEWORK_PATH ?=$(ALGBASE_PATH)/algframework I modified the config.mk like above. BR, Heechang What is your ALGBASE_PATH ? where is it installed? You can provide in quotes and check as well, ALGFRAMEWORK_PATH ?="$(ALGBASE_PATH)\algframework" ALGBASE_PATH ?= $(abspath ../../../) include $(ALGBASE_PATH)/makerules/config.mk The makefile is in "\ti_components\algorithms\REL.200.V.OD.C66X.00.06.02.00\200.V.OD.C66X.00.06\modules\ti_object_detection\test" BR, Heechang I start again from the beginning. 1. Open TI_CCS. 2. Import->C/C++->Existing Code as Makefile Project 3. Open "200.V.OD.C66X.00.06" 4. Language checkbox check the "c, c++" 5. Toolchain for Indexer Settings -> TI Build Tools? or Cross GCC? BR, Heechang 3.Open "200.V.OD.C66X.00.06" means the path of the "\200.V.OD.C66X.00.06\modules\ti_object_detection\test" BR, Heechang 5. Toolchain for Indexer Settings -> TI Build Tools If I select this, the error is same. BR, Heechang I'm using the CCS Version: 8.3.0.00009 on Windows. BR, Heechang Heechang, Did you go over the steps in User Guide for OD? It is there in ti_object_detection\docs folder. Also we support only a makefile based build not CCS import. Regards, Shyam Hi Shyam, I also build a makefile not CCS. But build error is same, so I tried out importing to CCS. BR, Heechang Hi Shyam, I start again from the beginning. I removed and downloaded all. And set the path. I build successfully. I don't know why the build error was shown. Thanks. I get the output in path of "\modules\ti_object_detection\lib\dsp\release\ti_object_detection.lib" After I replace the library then build the vision_sdk? BR, Heechang Hi Shyam, In object_detecction.cfg, if I apply trained model, only enablePD=1 , enableTSR =0 and enableVD=0 is OK? And set the useExtWeightsPD = 1. BR, Heechang Hi Shyam, In userguide, "Open CCS with TDA2x platform selected configuration file. Select Target > Load Program on C66x DSP, browse to the modules\ti_object_detection\test\out sub-directory, select the executable created in step 5, and load it into Code Composer Studio in preparation for execution." In CCS, where is the Target->Load Program in menu bar? BR, Heechang Hi Heechang, In objectgDetectionLink_priv.h, in the the declaration of the structure 'AlgorithmLink_ObjectDetectionObj', try replacing IVISION_BufDesc inBufDesc ---> IVISION_BufDesc inBufDesc[TI_OD_IN_BUFDESC_TOTAL]; Also, in the function AlgorithmLink_objectDetectionCreate() in the file objectDetectionLink_algPlugin.c just before the AlgorithmLink_objectDetectionInitIOBuffers(pObjectDetectObj); is called change or add, pObjectDetectObj->inBufDescList[TI_OD_IN_BUFDESC_FEATURE_PLANES] = &pObjectDetectObj->inBufDesc[0]; pObjectDetectObj->inBufDescList[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS] = &pObjectDetectObj->inBufDesc[1]; instead of pObjectDetectObj->inBufDescList[TI_OD_IN_BUFDESC_FEATURE_PLANES] = &pObjectDetectObj->inBufDesc; I hope this will work for you. :) Regards, Ganesh Hi Ganesh, Is your method for using external binary weights, right? I will apply your method. I'm now using OD library. I will share the result for your suggestion. Thank you. Best regards, Heechang Hi Ganesh, It doesn't work in my case. (The result is same.) I'm working on Linux. Thank you for your suggestion. Best regards, Heechang Hi Shyam, I build it successfully. How can I apply this? In folder "\modules\ti_object_detection\lib\dsp\release", the "ti_object_detection.lib" is generated. Should I replace this library and new "pd_adaboost_weights.bin"? Best regards, Heechang The new generated library file is same with before. So, I think that it cannot apply for usecase. BR, Heechang Hi Ganesh, Did you improve the PD with external weights? I'm working two cases on Linux. (1) One is the high level(using pd_adaboost_weights.bin) that the binary file read and run the usecase. (2) Another is using OD library. In case of (1), as you can this thread, I think that I applied the code TI suggests. But, the result looks no taking effect for new training binary. Do you think that something is added for code? Best regards, Heechang Hi Heechang, I read the external bin file from the sdcard into vision sdk in chains_vipSingleCameraObjectDetect2Tda3xx_SetObjectDetectPrm() by using another function Void ChainsCommon_od_adaboost_externalWeights_ReadExtWeightsFromFile(AlgorithmLink_ObjectDetectionCreateParams *pOD_Prm, char *extWeightsPDfileName) { Int32 status; UInt32 dataSize = 0;//, copySize; pOD_Prm->pExtAdaboostWeignts_PD = Utils_memAlloc(UTILS_HEAPID_DDR_CACHED_SR, MAX_ADABOOST_WEIGHT_SIZE_PD, 128); UTILS_assert(pOD_Prm->pExtAdaboostWeignts_PD!=NULL); //Vps_printf("\n ----------> CHAINS: External Adaboost Weights File Address Before Read: %lu !!!\n\n", pOD_Prm->pExtAdaboostWeignts_PD); status = Utils_fileReadFile( extWeightsPDfileName, pOD_Prm->pExtAdaboostWeignts_PD, MAX_ADABOOST_WEIGHT_SIZE_PD, &dataSize ); Vps_printf("\n ----------> CHAINS: External Adaboost Weights File Address After Read: %lu !!!\n\n", pOD_Prm->pExtAdaboostWeignts_PD); UTILS_assert(status==SYSTEM_LINK_STATUS_SOK); } --------------------------------------------------------------------------- then in AlgorithmLink_objectDetectionInitIOBuffers() , I assign the pointer to the buf, which i had declared....(told you about this in previous mail) #ifdef ENABLE_DEBUG_PRINTS_OD Int32 *pointer_Temp = NULL; // variable to verify the correctness of the external adaboost read #endif if(pObj->algLinkCreateParams.enableExtAdaboostWeights == 1) { pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->numPlanes = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.x = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.topLeft.y = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].width = MAX_ADABOOST_WEIGHT_SIZE_PD; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].height = 1; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.width = pInBufs->bufDesc[TI_OD_IN_BUFDESC_FEATURE_PLANES]->bufPlanes[0].width; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].frameROI.height = pInBufs->bufDesc[TI_OD_IN_BUFDESC_FEATURE_PLANES]->bufPlanes[0].frameROI.height; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].planeType = 0; pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf = (void *)pObj->algLinkCreateParams.pExtAdaboostWeignts_PD; #ifdef ENABLE_DEBUG_PRINTS_OD // FSD - Prints to verify the correctness of external Adaboost bin file reading Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Using External Weights!! \n"); Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Buf Address = %lu !! \n", (void *)pObj->algLinkCreateParams.pExtAdaboostWeignts_PD); Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Buf Address = %lu !! \n", pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf); Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Buf[0] = %u !! \n", (*(int *)(pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf))); pointer_Temp=pInBufs->bufDesc[TI_OD_IN_BUFDESC_PD_ADABOOST_WEIGHTS]->bufPlanes[0].buf; Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Buf[1] = %u !! \n", (*(pointer_Temp + 1))); Vps_printf("\n--------------AlgorithmLink_objectDetectionInitIOBuffers(): Buf[2] = %u !! \n", (*(pointer_Temp + 2))); #endif --------------------------------------------- I read the external bin file in OD test application, open memory browser and check the values at the memory where the external file is read. In vision sdk, in the above code I print the first two values of buf and compare them to the ones i read in OD test application. For me they come same , so I guess the external weights are being read correctly from SDcard and passed successfully to the OD code. --------------------------------------------- As of now I used Caltech dataset to train adaboost using the matlab tool at github.com/.../acf-jacinto but was not able to improve the accuracy in PD. Still working on it! Thanks and Regards, Ganesh Hi Ganesh, I also checked the buffer. It was correct. But, the accuracy of the PD is not better before. I did training model with the INRIA and Caltech-USA. Thank you very much. Best regards, Heechang I have a question. On which scenario is the accuracy "not better"? For the results to improve, the images used in training should be similar to that in test. I think one cannot add more Caltech images in training and expect to get better results in INRIA test. Hi Heechang, Yes even I trained the model with INRIA and Caltech-USA dataset. The results for PD are not better. I tested the it live on TDA3 with OV2775 2Mp camera in my office and also outside the office for some time. The results were better in case of the default Adaboost model provided by TI. I think our aim is same, maybe we can discuss this one to one on how can we improve the accuracy. If you are open for discussion write me on rotgo39@gmail.com If you find something which might improve the accuracy kindly let me know. I will write you from my side. Thanks and Regards, Ganesh