|
||
---|---|---|
.. | ||
images | ||
model | ||
src | ||
CMakeLists.txt | ||
README.md | ||
README_CN.md | ||
build-android_RK3562.sh | ||
build-android_RK3566_RK3568.sh | ||
build-android_RK3588.sh | ||
build-linux_RK3562.sh | ||
build-linux_RK3566_RK3568.sh | ||
build-linux_RK3588.sh |
README.md
RKNN C API Dynamic Shape Input Demo
This is a demo that uses the RKNN C API for dynamic shape input inference. In this demo, you can see how to use the RKNN dynamic shape C API to perform image classification.
How to Use
- Clone or download this code repository: ssh://git@10.10.10.59:8001/hpc/rknpu2.git.
- Navigate to the dynamic shape inference demo directory in your terminal.
cd examples/rknn_dynamic_shape_input_demo
- Compile the application by running the shell script based on the chip platform. For example, for the RK3562 Android system, run the following command:
./build-android_RK3562.sh
- Push the demo program directory to the target board's system using the adb command. For example:
#If using Android system, make sure to run adb root & adb remount first.
adb push ./install/rknn_dynshape_demo_Android/ /data
- Set the runtime library path.
export LD_LIBRARY_PATH=./lib
-
Run the program. For example, on the RK3562 platform, use the command
./rknn_dynshape_inference model/RK3562/mobilenet_v2.rknn images/dog_224x224.jpg
,where
mobilenet_v2.rknn
is the name of the neural network model file, anddog_224x224.jpg
is the name of the image file to classify.
Compilation Instructions
Arm Linux
Specify the cross-compiler path for the specific chip platform by modifying the GCC_COMPILER
in build-linux_<TARGET_PLATFORM>.sh
, where TARGET_PLATFORM is the chip name. Then execute:
./build-linux_<TARGET_PLATFORM>.sh
Android
Specify the path to the Android NDK by modifying ANDROID_NDK_PATH
in build-android_<TARGET_PLATFORM>.sh
, where TARGET_PLATFORM is the chip name. Then execute:
./build-android_<TARGET_PLATFORM>.sh
Included Features
This demonstration application includes the following features:
- Creating a neural network model with dynamic shape inputs. Please refer to the examples/functions/dynamic_input directory in the https://github.com/rockchip-linux/rknn-toolkit2 repository for more information.
- Reading an image from a file and performing classification using the neural network model. The program follows these steps:
- Initialize the RKNN context using the
rknn_init()
function. - Set the shape information of all the model inputs using the
rknn_set_input_shapes()
function, including shape and layout. - Query the current model input and output information, including shape, data type, and size, using the
rknn_query()
function. - Set the input data of the model using the
rknn_inputs_set()
function, including data pointer and size. - Run the model using the
rknn_run()
function. - Retrieve the output data by using the
rknn_outputs_get()
function, specifying the need for float-type results. - Process the output data to obtain the classification results and probabilities.
- Release the RKNN context using the
rknn_release()
function.