Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a folder yolov8s-pose in path ~/c3v/Models. Please ensure the folder name is the same as the ONNX file name.

Code Block
breakoutModewide
breakoutWidth760
~/c3v/Models$ mkdir yolov8s-pose && cd yolov8s-pose
  1. Copy the ONNX file and input.jpg which resolution is 640x640 to the folder yolov8s. These two files will be used as input files during model conversion.

Code Block
breakoutModewide
breakoutWidth760
~/c3v/Models$ cp yolov8s-pose.onnx yolov8s-pose/
~/c3v/Models$ cp input.jpg yolov8s-pose/
  1. Create a dataset.txt file, the content of dataset.txt is the input.jpg file name.

Code Block
breakoutModewide
breakoutWidth760
./input.jpg
  1. Create inputs_outputs.txt file and get the information from yolov8s-pose .onnx via netron tool/webpage. Here is the onnx file:

    View file
    nameyolov8s-pose_onnx.zip
    .

...

Select the three operators within the red box as the output. write --input-size-list and --outputs informations to inputs_outputs.txt:

Code Block
breakoutModewide
breakoutWidth760
--outputs  '/model.22/Sigmoid_output_0 /model.22/Mul_2_output_0 /model.22/Sigmoid_1_output_0 /model.22/Mul_4_output_0'

...

Execute the command in the console or terminal, and wait for it to complete. It will import and translate an NN model to NN formats.

Code Block
breakoutModewide
breakoutWidth760
./pegasus_import.sh yolov8s-pose

...

Select one quantized type for your need, such as uint8 / int16 / bf16 / pcq. In this sample we use int16.

Code Block
breakoutModewide
breakoutWidth760
./pegasus_quantize.sh yolov8s-pose int16

...

Inference the NN model with the quantization data type.

Code Block
breakoutModewide
breakoutWidth760
./pegasus_inference.sh yolov8s-pose int16

...

Export the quantized application for device deployment. Please modify the pegasus_export_ovx.sh for the nb file generating, and add both 3 lines marked in the red box.

...

Code Block
breakoutModewide
breakoutWidth760
./pegasus_export_ovx.sh yolov8s-pose int16

...

The function needs to be modified:vnn_PostProcessYolov8sPoseInt16

Code Block
breakoutModewide
breakoutWidth760
languagecpp
vsi_status vnn_PostProcessYolov8sPoseInt16(vsi_nn_graph_t *graph)
{
    vsi_status status = VSI_FAILURE;

#if DETECT_RESULT_IMPL
    /*detect result sample implement*/
    post_proc_init(graph);
    post_proc_process(graph);
    post_proc_deinit();

#else
    /* Show the top5 result */
    status = show_top5(graph, vsi_nn_GetTensor(graph, graph->output.tensors[0]));
    TEST_CHECK_STATUS(status, final);

    /* Save all output tensor data to txt file */
    save_output_data(graph);

final:
#endif

    return VSI_SUCCESS;
}

For detailed function implementation, please refer to the following file:

View file
namevnnyolov8sPose_int16_post_process.zip

we needs to be unzipped and placed in ~/c3v/Models/yolov8s-pose/wksp/yolov8s_int16_nbg_unify Folder.

...

  • Example of SDK Includes Path:

Code Block
breakoutModewide
breakoutWidth760
INCLUDES+=-I$(NN_SDK_DIR)/include/ \
-I$(NN_SDK_DIR)/include/CL \
-I$(NN_SDK_DIR)/include/VX \
-I$(NN_SDK_DIR)/include/ovxlib \
-I$(NN_SDK_DIR)/include/jpeg

Example of SDK Link Libraries:

Code Block
breakoutModewide
breakoutWidth760
LIBS+=-lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -ljpeg -lovxlib

3. Example flow of the program build and run

Unzipped

View file
namevnnyolov8sPose_int16_post_process.zip
and
View file
nameMakefile.zip
then placed them in ~/c3v/Models/yolov8s-pose/wksp/yolov8s-pose_int16_nbg_unify Folder. The brief folder of the project is like this:

...

If you want to build the project in c3v directly, please modify these contents of Makefile:

Code Block
breakoutModewide
breakoutWidth760
BIN=yolov8s-pose-int16

# 2.build in c3v
NN_SDK_DIR=/usr

CC=gcc
CXX=g++

then copy the whole folder yolov8s-pose_int16_nbg_unify to the c3v Linux system. Then using make to compile the project.

Code Block
breakoutModewide
breakoutWidth760
cd /sample/yolov8s-pose_int16_nbg_unify
make -j

...

The param2 is the image that is for detection. Please prepare the image file which format is jpg and the pixel size is 640 * 640.

Code Block
breakoutModewide
breakoutWidth760
./yolov8s-pose-int16 ./network_binary.nb ./input.jpg

The result is like this:

Code Block
breakoutModewide
breakoutWidth760
/mnt/yolov8s-pose_int16_nbg_unify # ./yolov8s-pose-int16 ./network_binary.nb
../input.jpg
Create Neural Network: 59ms or 59044us
Verify...
Verify Graph: 24ms or 24933us
Start run graph [1] times...
Run the 1 time: 122.44ms or 122443.93us
vxProcessGraph execution time:
Total   122.66ms or 122658.48us
Average 122.66ms or 122658.48us
obj: L: 0 P:0.93, [(0, 42) - (200, 599)]
obj: L: 0 P:0.91, [(309, 279) - (180, 361)]
obj: L: 0 P:0.58, [(344, 171) - (170, 301)]

...

If you want to build the project in host Linux, please modify these contents of Makefile:

Code Block
breakoutModewide
breakoutWidth760
BIN=yolov8s-pose-int16

# 1.cross compile
NN_SDK_DIR=Path to NN SDK directory
TOOLCHAIN=Path to toolchain directory

CROSS_COMPILE=$(TOOLCHAIN)/aarch64-none-linux-gnu-
CC=$(CROSS_COMPILE)gcc
CXX=$(CROSS_COMPILE)g++

...

TOOLCHAIN: The cross-compile toolchain path. which format may be like this:

Code Block
breakoutModewide
breakoutWidth760
TOOLCHAIN=/pub/toolchain/crossgcc/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin

then using make to compile the project.

Code Block
breakoutModewide
breakoutWidth760
make

Copy the application, network_binary.nb file and related libraries into C3V Linux and run:

...

The param2 is the image that is for detection. Please prepare the image file which format is jpg and the pixel size is 640 * 640.

Code Block
breakoutModewide
breakoutWidth760
./yolov8s-pose-int16 ./network_binary.nb ./input.jpg

The result is like this:

Code Block
breakoutModewide
breakoutWidth760
/mnt/yolov8s-pose_int16_nbg_unify # ./yolov8s-pose-int16 ./network_binary.nb
../input.jpg
Create Neural Network: 59ms or 59044us
Verify...
Verify Graph: 24ms or 24933us
Start run graph [1] times...
Run the 1 time: 122.44ms or 122443.93us
vxProcessGraph execution time:
Total   122.66ms or 122658.48us
Average 122.66ms or 122658.48us
obj: L: 0 P:0.93, [(0, 42) - (200, 599)]
obj: L: 0 P:0.91, [(309, 279) - (180, 361)]
obj: L: 0 P:0.58, [(344, 171) - (170, 301)]

3.2. ImageWriter Tool

If you want to show the detection results in an image, we suggest using ImageWriter tools.

Install the related environment

Code Block
breakoutModewide
breakoutWidth760
sudo apt update
sudo apt install libopencv-dev

Please download

View file
nameimageWriter.zip
and compile it in c3v:

Code Block
breakoutModewide
breakoutWidth760
cd imageWriter
make -j

Then you can run the imageWriter application directly on c3v:

Param1 is the image which is the same as yolov8s-pose-int16 param2. The yolov8s-pose-int16 is the application that is built in step 3.1. build in c3v.

Param2 is the file pose_results.raw which was generated after the program yolov8s-pose-int16 runs.

Param3 is the output name, which format is jpg.

Code Block
breakoutModewide
breakoutWidth760
./imageWriter ./input.jpg ./pose_results.raw ./output.jpg

The result is like this:

...