# snnf **Repository Path**: sunplus-group/snnf ## Basic Information - **Project Name**: snnf - **Description**: Sunplus提供的C++ NN Framework - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-21 - **Last Updated**: 2025-02-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # snnf #### 介绍 https://sunplus.atlassian.net/wiki/spaces/C3/pages/2427224156/SP7350#SDK%E4%B8%8B%E8%BD%BD%E7%BC%96%E8%AF%91 #### 编译与部署教程 环境: SP7350 开发平台 在SP7350平台上通过下面命令下载及编译snnf代码 ``` cd ~ git clone https://gitee.com/sunplus-group/snnf.git cd snnf cat snnf_release.part.* > snnf_release.tar.gz rm -rf snnf_release.part.* tar -xf snnf_release.tar.gz && tar -xf NPUSdk-6.4.18.5.tar.xz cd snnf_release ./snnf_build.sh ``` #### 测试 编译完成后,可以通过snnf_demo/snnf_sample命令测试 1. snnf_demo测试 snnf_demo只能测试snnf内每个模型范例默认使用的模型 ``` sunplus@ubuntu:~/snnf/snnf_release$ cd release sunplus@ubuntu:~/snnf/snnf_release/release$ ./snnf_demo.sh Usage: ./bin/snnf_demo [-m|-s|-a|-h] [-i|-v|-o|option] Version: 1.2.0_V1.2.0 Time: 2025-01-24 14:35:55 +0800 [-m,--model ] run a single model :Age Det10g HumanAttr LightFace OcrCls OcrDet OcrRec VehicleAttr W600kR50 YoloV8sOdMap Yolov5sDetection Yolov5sV1 Yolov8nClassify Yolov8sClassify stgcn BotSortTrack BotSortTrackStgcn YoloV8sDetection example:./bin/snnf_demo -m Yolov5sDetection ./bin/snnf_demo --model HumanAttr [-s,--sequential ] run sequential models :Yolov5sDetection,HumanFilter,HumanAttr LightFace,Age OcrDet,OcrRec OcrDet,OcrCls,OcrRec Det10g,W600kR50 YoloV8sDetection,VehicleFilter,VehicleAttr YoloV8nDetectionOpti,BotSortTrack YoloV8nPoseOpti,BotSortTrackStgcn YoloV8nCcpdOpti,OcrRec YoloV8nCcpdOpti,OcrCls,OcrRec example:./bin/snnf_demo -s Yolov5sDetection,HumanFilter,HumanAttr ./bin/snnf_demo --sequential OcrDet,OcrCls,OcrRec ./bin/snnf_demo -s YoloV8nCcpdOpti,OcrRec,imageWriter ./bin/snnf_demo -s YoloV8sDetectionOpti,BotSortTrack,videoWriter -v resource/video/humanTracking.mp4 ./bin/snnf_demo -s YoloV8nPoseOpti,BotSortTrackStgcn,videoWriter -v resource/video/person-falling.mp4 [-i,--image file] set image file to nn detection. : file name [-c | option]: test count, this parameter is only match with -i example:./bin/snnf_demo -s Yolov5sDetection,HumanFilter,HumanAttr -i resource/image/person.jpg -c 2 ./bin/snnf_demo -s Yolov5sDetection,HumanFilter,HumanAttr --image resource/image/person.jpg -c 2 [-v,--video file] set video file to nn detection. : file name example:./bin/snnf_demo -s YoloV8sDetectionOpti,BotSortTrack,videoWriter -v resource/video/humanTracking.mp4 ./bin/snnf_demo -s YoloV8sDetectionOpti,BotSortTrack,videoWriter --video resource/video/humanTracking.mp4 [-o,--output file] specify the output file name for saving results. : file name with extension (e.g., output.jpg, output.json, output.mp4) This parameter must be used in conjunction with imageWriter, jsonWriter, or videoWriter. example:./bin/snnf_demo -s Yolov5sDetection,HumanFilter,HumanAttr,imageWriter -i resource/image/person.jpg -o output.jpg ./bin/snnf_demo -s Yolov5sDetection,HumanFilter,HumanAttr,jsonWriter -i resource/image/person.jpg -o output.json ./bin/snnf_demo -s YoloV8sDetectionOpti,BotSortTrack,videoWriter -v resource/video/humanTracking.mp4 -o output.mp4 [-a,--all] run all model testing assist tools: imageWriter videoWriter jsonWriter BotSortTrack HumanFilter VehicleFilter ``` 可以通过下面的命令测试单个模型 ``` sunplus@ubuntu:~/snnf/snnf_release/release$ ./snnf_demo.sh -m Yolov5sDetection 1738997435490|7f83386040|T|common: [app]Yolov5sDetection in 1738997435889|7f5eb02b40|T|common: [app]GeneralModelOutputListener detect from resource/image/person.jpg, the result: (box: 612.44 156.84 268.88 625.51) --> label: 0(person), confidence: 0.95, fin: false 1738997435889|7f5eb02b40|T|common: [app]GeneralModelOutputListener detect from resource/image/person.jpg, the result: (box: 311.82 181.12 199.79 606.84) --> label: 0(person), confidence: 0.90, fin: false 1738997435889|7f5eb02b40|T|common: [app]GeneralModelOutputListener detect from resource/image/person.jpg, the result: (box: 448.12 283.81 76.55 186.72) --> label: 26(handbag), confidence: 0.43, fin: true 1738997435947|7f83386040|T|common: [app]Yolov5sDetection out, retVal: -0x0 ``` 2. snnf_sample测试 如需测试自训练模型,可以通过snnf_sample来测试,需要按照前面提供的连接文档修改模型的相关差异参数,然后在snnf_release下执行./snnf_build.sh编译代码 ``` cd release source snnf_env.sh ./bin/snnf_singleMode ``` ``` sunplus@ubuntu:~/snnf/snnf_release/release$ ./bin/snnf_single_model 1738997671944|7f88b27040|T|common: [app]the result: (box: 613.0210 151.1255 277.9775 640.6787) --> label: 0(person), confidence: 0.93, fin: false 1738997671944|7f88b27040|T|common: [app]the result: (box: 313.3374 175.0488 210.7588 617.1055) --> label: 0(person), confidence: 0.91, fin: false 1738997671944|7f88b27040|T|common: [app]the result: (box: 449.4962 286.2632 67.5105 180.4170) --> label: 26(handbag), confidence: 0.40, fin: true ```