techwingslab / yolov5-net

YOLOv5 object detection with C#, ML.NET, ONNX
MIT License
351 stars 104 forks source link

How to use my model #42

Open Yang-Code984 opened 2 years ago

Yang-Code984 commented 2 years ago

Hello, I'm a newcomer,After the model I trained in pytorch is converted to. Onnx, it can't run smoothly.How can I run my own model.

1 2

if (output[0, i, k] <= _model.MulConfidence) return; // skip low mul_conf results

                    float xMin = ((output[0, i, 0] - output[0, i, 2] / 2) - xPad) / gain; // unpad bbox tlx to original
                    float yMin = ((output[0, i, 1] - output[0, i, 3] / 2) - yPad) / gain; // unpad bbox tly to original
                    float xMax = ((output[0, i, 0] + output[0, i, 2] / 2) - xPad) / gain; // unpad bbox brx to original
                    float yMax = ((output[0, i, 1] + output[0, i, 3] / 2) - yPad) / gain; // unpad bbox bry to original

                    xMin = Clamp(xMin, 0, w - 0); // clip bbox tlx to boundaries
                    yMin = Clamp(yMin, 0, h - 0); // clip bbox tly to boundaries
                    xMax = Clamp(xMax, 0, w - 1); // clip bbox brx to boundaries
                    yMax = Clamp(yMax, 0, h - 1); // clip bbox bry to boundaries

                    YoloLabel label = _model.Labels[k - 5];

                var prediction = new YoloPrediction(label, output[0, i, k])
                {
                    Rectangle = new RectangleF(xMin, yMin, xMax - xMin, yMax - yMin)
                };