Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix v8seg #121

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/ax650/yolov8_seg_out.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions examples/ax620e/ax_yolov8_seg_steps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,25 @@ namespace ax
{
void post_process(AX_ENGINE_IO_INFO_T* io_info, AX_ENGINE_IO_T* io_data, const cv::Mat& mat, int input_w, int input_h, const std::vector<float>& time_costs)
{
middleware::print_io_info(io_info);
std::vector<detection::Object> proposals;
std::vector<detection::Object> objects;
timer timer_postprocess;
float* output_ptr[3] = {(float*)io_data->pOutputs[0].pVirAddr,
(float*)io_data->pOutputs[1].pVirAddr,
(float*)io_data->pOutputs[2].pVirAddr};
float* output_seg_ptr[3] = {(float*)io_data->pOutputs[3].pVirAddr,
(float*)io_data->pOutputs[4].pVirAddr,
(float*)io_data->pOutputs[5].pVirAddr};
float* output_ptr[3] = {(float*)io_data->pOutputs[4].pVirAddr, // 1*80*80*144
(float*)io_data->pOutputs[5].pVirAddr, // 1*40*40*144
(float*)io_data->pOutputs[6].pVirAddr}; // 1*20*20*144
float* output_seg_ptr[3] = {(float*)io_data->pOutputs[1].pVirAddr, // 1*80*80*32
(float*)io_data->pOutputs[2].pVirAddr, // 1*40*40*32
(float*)io_data->pOutputs[3].pVirAddr}; // 1*20*20*32
for (int i = 0; i < 3; ++i)
{
auto feat_ptr = output_ptr[i];
auto feat_seg_ptr = output_seg_ptr[i];
int32_t stride = (1 << i) * 8;
detection::generate_proposals_yolov8_seg_native(stride, feat_ptr, feat_seg_ptr, PROB_THRESHOLD, proposals, input_w, input_h, NUM_CLASS);
}

auto mask_proto_ptr = (float*)io_data->pOutputs[6].pVirAddr;
// 1*32*160*160
auto mask_proto_ptr = (float*)io_data->pOutputs[0].pVirAddr;

detection::get_out_bbox_mask(proposals, objects, mask_proto_ptr, DEFAULT_MASK_PROTO_DIM, DEFAULT_MASK_SAMPLE_STRIDE, NMS_THRESHOLD, input_h, input_w, mat.rows, mat.cols);
fprintf(stdout, "post process cost time:%.2f ms \n", timer_postprocess.cost());
Expand Down
56 changes: 56 additions & 0 deletions examples/ax650/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,59 @@ Repeat 1 times, avg time 258.29 ms, max_time 258.29 ms, min_time 258.29 ms
--------------------------------------
```
<img src="../../docs/ax650/glpdepth_out.png">

### YoloV8-Seg
```
/opt/test # ./ax_yolov8_seg -m yolov8n_seg.axmodel -i ssd_horse.jpg
--------------------------------------
model file : yolov8n_seg.axmodel
image file : ssd_horse.jpg
img_h, img_w : 640 640
--------------------------------------
Engine creating handle is done.
Engine creating context is done.
Engine get io info is done.
Engine alloc io is done.
Engine push input is done.
--------------------------------------

input size: 1
name: images [UINT8]
1 x 640 x 640 x 3


output size: 7
name: output1 [FLOAT32]
1 x 32 x 160 x 160

name: /model.22/cv4.0/cv4.0.2/Conv_output_0 [FLOAT32]
1 x 80 x 80 x 32

name: /model.22/cv4.1/cv4.1.2/Conv_output_0 [FLOAT32]
1 x 40 x 40 x 32

name: /model.22/cv4.2/cv4.2.2/Conv_output_0 [FLOAT32]
1 x 20 x 20 x 32

name: /model.22/Concat_1_output_0 [FLOAT32]
1 x 80 x 80 x 144

name: /model.22/Concat_2_output_0 [FLOAT32]
1 x 40 x 40 x 144

name: /model.22/Concat_3_output_0 [FLOAT32]
1 x 20 x 20 x 144

post process cost time:8.62 ms
--------------------------------------
Repeat 1 times, avg time 5.16 ms, max_time 5.16 ms, min_time 5.16 ms
--------------------------------------
detection num: 5
17: 90%, [ 214, 75, 419, 369], horse
0: 83%, [ 272, 13, 349, 232], person
7: 77%, [ 0, 105, 133, 196], truck
0: 77%, [ 427, 125, 451, 175], person
16: 69%, [ 144, 203, 195, 343], dog
--------------------------------------
```
<img src="../../docs/ax650/yolov8_seg_out.jpg">
17 changes: 9 additions & 8 deletions examples/ax650/ax_yolov8_seg_steps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,25 @@ namespace ax
{
void post_process(AX_ENGINE_IO_INFO_T* io_info, AX_ENGINE_IO_T* io_data, const cv::Mat& mat, int input_w, int input_h, const std::vector<float>& time_costs)
{
middleware::print_io_info(io_info);
std::vector<detection::Object> proposals;
std::vector<detection::Object> objects;
timer timer_postprocess;
float* output_ptr[3] = {(float*)io_data->pOutputs[0].pVirAddr,
(float*)io_data->pOutputs[1].pVirAddr,
(float*)io_data->pOutputs[2].pVirAddr};
float* output_seg_ptr[3] = {(float*)io_data->pOutputs[3].pVirAddr,
(float*)io_data->pOutputs[4].pVirAddr,
(float*)io_data->pOutputs[5].pVirAddr};
float* output_ptr[3] = {(float*)io_data->pOutputs[4].pVirAddr, // 1*80*80*144
(float*)io_data->pOutputs[5].pVirAddr, // 1*40*40*144
(float*)io_data->pOutputs[6].pVirAddr}; // 1*20*20*144
float* output_seg_ptr[3] = {(float*)io_data->pOutputs[1].pVirAddr, // 1*80*80*32
(float*)io_data->pOutputs[2].pVirAddr, // 1*40*40*32
(float*)io_data->pOutputs[3].pVirAddr}; // 1*20*20*32
for (int i = 0; i < 3; ++i)
{
auto feat_ptr = output_ptr[i];
auto feat_seg_ptr = output_seg_ptr[i];
int32_t stride = (1 << i) * 8;
detection::generate_proposals_yolov8_seg_native(stride, feat_ptr, feat_seg_ptr, PROB_THRESHOLD, proposals, input_w, input_h, NUM_CLASS);
}

auto mask_proto_ptr = (float*)io_data->pOutputs[6].pVirAddr;
// 1*32*160*160
auto mask_proto_ptr = (float*)io_data->pOutputs[0].pVirAddr;

detection::get_out_bbox_mask(proposals, objects, mask_proto_ptr, DEFAULT_MASK_PROTO_DIM, DEFAULT_MASK_SAMPLE_STRIDE, NMS_THRESHOLD, input_h, input_w, mat.rows, mat.cols);
fprintf(stdout, "post process cost time:%.2f ms \n", timer_postprocess.cost());
Expand Down