Object Detection with YOLOv3 (Dynamic Batch/Image Size)
Description
This sample implements object detection based on the Caffe YOLOv3 network in the dynamic batch/image size scenario.
The Caffe YOLOv3 network is converted into an .om offline model adapted to the Ascend AI Processor. In the conversion command, set the batch size profiles (for example, 1, 2, 4, and 8) or the image size profiles (for example, 416, 416, 832, 832, 1248, and 1248). In your app, load the .om file, select the batch/image size for inference by passing the corresponding argument, and output the inference result to a file.
Principles
The following table lists the key functions involved in this sample.
Initialization |
|
|---|---|
Device Management |
|
Stream Management |
|
Memory Management |
|
Data Transfer |
aclrtMemcpy (used when the app runs on the host):
Data transfer is not required if your app runs in the board environment. |
Model Inference |
|
Data Postprocessing |
DumpModelOutputResult: outputs the model inference result to a file. (After the executable file is executed, the inference result file is stored in the same directory in the operating environment as the executable file of the app.) processModel.DumpModelOutputResult(); |
Directory Structure
The sample directory is organized as follows:
├── data │ ├── tools_generate_data.py //Script for generating test data ├── inc │ ├── model_process.h //Header file that declares functions related to model processing │ ├── sample_process.h //Header file that declares functions related to resource initialization and destruction │ ├── utils.h //Header file that declares common functions (such as the file reading function) ├── src │ ├── acl.json //Configuration file for system initialization │ ├── CMakeLists.txt //Build script │ ├── main.cpp //Implementation file of the main function, for image classification │ ├── model_process.cpp //Implementation file of model processing functions │ ├── sample_process.cpp //Implementation file of functions related to resource initialization and destruction │ ├── utils.cpp //Implementation file of common functions (such as the file reading function) ├── .project //Project information file, including the project type, project description, and type of the target device ├── CMakeLists.txt //Build script that calls the CMakeLists file in the src directory