cancel
Showing results for 
Search instead for 
Did you mean: 

porting yolov11 model to stm32mp257.

fanronghua0123456
Associate III
I porting yolov11 model to stm32mp257. and The target detection model I use ,The output tensor is a combination of [1x7x8400] and [1x4x8400]. [1x7x8400] should be our classification because I have set 7 categories, and [1x4x8400] should be our positional information.
 
1. best.pt changed to best.onnx
from ultralytics import YOLO
# Load the YOLO11 model
model = YOLO("best.pt")
# Export the model to ONNX format
model.export(format="onnx") # creates 'yolo11n.onnx'
 
2. best.onnx changed to best.nb
./stedgeai generate -m path/to/onnx/model --target stm32mp25
 
3. into broad stm32mp257 ,and get output shape.
 
#C++
float *pfloatdata = static_cast<float*>(nn_model->get_output(0));
std::vector<ObjDetect_Results> returnx = parseModelOutput(pfloatdata);
 
std::vector<ObjDetect_Results> parseModelOutput(float* output, int num_classes = 7, float confidence_threshold = 0.55f)
{
std::vector<ObjDetect_Results> detections;
float *data = output;
const int num_boxes = 8400;
const int attributes_per_box = 4 + num_classes; // 4坐标 + 1置信度 + n类别
 
for (int w = 0; w < 8400; w++)
{
for (int h = 0; h < attributes_per_box; h++)
{
printf(" %.2f ",data[h * 8400 + w]);
}
printf("\r\n");
}
 
4. I received the following output.I use the onnx model, and the probability of all 7 categories on the PC is 0. This seems to be correct, and the reasoning is also correct. However, when converted to. nb format, why is the probability of all 7 categories 1? This is obviously not correct. Why is this?
16.66  10.19  38.69  12.38  1.00  1.00  0.00  1.00  1.00  1.00  1.00
22.69  12.00  42.62  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
16.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
24.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
32.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
40.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
47.53  12.01  71.06  16.02  1.00  1.00  1.00  1.00  1.00  1.00  1.00
54.12  12.00  68.25  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
60.03  12.00  64.06  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
68.00  12.00  80.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
76.00  12.00  80.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
88.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
96.00  11.99  72.00  16.02  1.00  1.00  1.00  1.00  1.00  1.00  1.00
104.00  11.56  72.00  15.15  1.00  1.00  1.00  1.00  1.00  1.00  1.00
109.88  11.91  76.25  15.84  1.00  1.00  1.00  1.00  1.00  1.00  1.00
116.00  8.00  80.00  8.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
124.00  8.00  80.00  8.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
132.00  8.02  80.00  8.02  1.00  1.00  1.00  1.00  1.00  1.00  1.00
144.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
152.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
160.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
168.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
176.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
183.75  12.00  72.38  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
192.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
200.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
208.00  12.00  72.00  16.00  1.00  1.00  1.00  1.00  1.00  1.00  1.00
0 REPLIES 0