ultralytics 8.0.210 docs updates and bug fixes (#6365)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Ceyda Cinarel (재이다) <15624271+cceyda@users.noreply.github.com> Co-authored-by: DennisJ <106725464+DennisJcy@users.noreply.github.com> Co-authored-by: Dickson Neoh <dickson.neoh@gmail.com> Co-authored-by: Sergiu Waxmann <47978446+sergiuwaxmann@users.noreply.github.com> Co-authored-by: Luca Serra <56681681+luca-serra@users.noreply.github.com>
This commit is contained in:
parent
9a5891444e
commit
0473da00a9
18 changed files with 125 additions and 57 deletions
|
|
@ -39,14 +39,32 @@ char *BlobFromImage(cv::Mat &iImg, T &iBlob) {
|
|||
}
|
||||
|
||||
|
||||
char *PostProcess(cv::Mat &iImg, std::vector<int> iImgSize, cv::Mat &oImg) {
|
||||
cv::Mat img = iImg.clone();
|
||||
cv::resize(iImg, oImg, cv::Size(iImgSize.at(0), iImgSize.at(1)));
|
||||
if (img.channels() == 1) {
|
||||
cv::cvtColor(oImg, oImg, cv::COLOR_GRAY2BGR);
|
||||
}
|
||||
cv::cvtColor(oImg, oImg, cv::COLOR_BGR2RGB);
|
||||
return RET_OK;
|
||||
char* DL_CORE::PreProcess(cv::Mat& iImg, std::vector<int> iImgSize, cv::Mat& oImg)
|
||||
{
|
||||
if (iImg.channels() == 3)
|
||||
{
|
||||
oImg = iImg.clone();
|
||||
cv::cvtColor(oImg, oImg, cv::COLOR_BGR2RGB);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cvtColor(iImg, oImg, cv::COLOR_GRAY2RGB);
|
||||
}
|
||||
|
||||
if (iImg.cols >= iImg.rows)
|
||||
{
|
||||
resizeScales = iImg.cols / (float)iImgSize.at(0);
|
||||
cv::resize(oImg, oImg, cv::Size(iImgSize.at(0), int(iImg.rows / resizeScales)));
|
||||
}
|
||||
else
|
||||
{
|
||||
resizeScales = iImg.rows / (float)iImgSize.at(0);
|
||||
cv::resize(oImg, oImg, cv::Size(int(iImg.cols / resizeScales), iImgSize.at(1)));
|
||||
}
|
||||
cv::Mat tempImg = cv::Mat::zeros(iImgSize.at(0), iImgSize.at(1), CV_8UC3);
|
||||
oImg.copyTo(tempImg(cv::Rect(0, 0, oImg.cols, oImg.rows)));
|
||||
oImg = tempImg;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -127,7 +145,7 @@ char *DCSP_CORE::RunSession(cv::Mat &iImg, std::vector<DCSP_RESULT> &oResult) {
|
|||
|
||||
char *Ret = RET_OK;
|
||||
cv::Mat processedImg;
|
||||
PostProcess(iImg, imgSize, processedImg);
|
||||
PreProcess(iImg, imgSize, processedImg);
|
||||
if (modelType < 4) {
|
||||
float *blob = new float[processedImg.total() * 3];
|
||||
BlobFromImage(processedImg, blob);
|
||||
|
|
@ -188,8 +206,6 @@ char *DCSP_CORE::TensorProcess(clock_t &starttime_1, cv::Mat &iImg, N &blob, std
|
|||
rawData = rawData.t();
|
||||
float *data = (float *) rawData.data;
|
||||
|
||||
float x_factor = iImg.cols / 640.;
|
||||
float y_factor = iImg.rows / 640.;
|
||||
for (int i = 0; i < strideNum; ++i) {
|
||||
float *classesScores = data + 4;
|
||||
cv::Mat scores(1, this->classes.size(), CV_32FC1, classesScores);
|
||||
|
|
@ -205,11 +221,11 @@ char *DCSP_CORE::TensorProcess(clock_t &starttime_1, cv::Mat &iImg, N &blob, std
|
|||
float w = data[2];
|
||||
float h = data[3];
|
||||
|
||||
int left = int((x - 0.5 * w) * x_factor);
|
||||
int top = int((y - 0.5 * h) * y_factor);
|
||||
int left = int((x - 0.5 * w) * resizeScales);
|
||||
int top = int((y - 0.5 * h) * resizeScales);
|
||||
|
||||
int width = int(w * x_factor);
|
||||
int height = int(h * y_factor);
|
||||
int width = int(w * resizeScales);
|
||||
int height = int(h * resizeScales);
|
||||
|
||||
boxes.emplace_back(left, top, width, height);
|
||||
}
|
||||
|
|
@ -254,7 +270,7 @@ char *DCSP_CORE::WarmUpSession() {
|
|||
clock_t starttime_1 = clock();
|
||||
cv::Mat iImg = cv::Mat(cv::Size(imgSize.at(0), imgSize.at(1)), CV_8UC3);
|
||||
cv::Mat processedImg;
|
||||
PostProcess(iImg, imgSize, processedImg);
|
||||
PreProcess(iImg, imgSize, processedImg);
|
||||
if (modelType < 4) {
|
||||
float *blob = new float[iImg.total() * 3];
|
||||
BlobFromImage(processedImg, blob);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ public:
|
|||
char *TensorProcess(clock_t &starttime_1, cv::Mat &iImg, N &blob, std::vector<int64_t> &inputNodeDims,
|
||||
std::vector<DCSP_RESULT> &oResult);
|
||||
|
||||
char* PreProcess(cv::Mat& iImg, std::vector<int> iImgSize, cv::Mat& oImg);
|
||||
|
||||
std::vector<std::string> classes{};
|
||||
|
||||
private:
|
||||
|
|
@ -81,4 +83,5 @@ private:
|
|||
std::vector<int> imgSize;
|
||||
float rectConfidenceThreshold;
|
||||
float iouThreshold;
|
||||
float resizeScales;//letterbox scale
|
||||
};
|
||||
|
|
|
|||
|
|
@ -349,10 +349,10 @@
|
|||
"| [PyTorch](https://pytorch.org/) | - | `yolov8n.pt` | ✅ | - |\n",
|
||||
"| [TorchScript](https://pytorch.org/docs/stable/jit.html) | `torchscript` | `yolov8n.torchscript` | ✅ | `imgsz`, `optimize` |\n",
|
||||
"| [ONNX](https://onnx.ai/) | `onnx` | `yolov8n.onnx` | ✅ | `imgsz`, `half`, `dynamic`, `simplify`, `opset` |\n",
|
||||
"| [OpenVINO](https://docs.openvino.ai/latest/index.html) | `openvino` | `yolov8n_openvino_model/` | ✅ | `imgsz`, `half` |\n",
|
||||
"| [OpenVINO](https://docs.openvino.ai/latest/index.html) | `openvino` | `yolov8n_openvino_model/` | ✅ | `imgsz`, `half`, `int8` |\n",
|
||||
"| [TensorRT](https://developer.nvidia.com/tensorrt) | `engine` | `yolov8n.engine` | ✅ | `imgsz`, `half`, `dynamic`, `simplify`, `workspace` |\n",
|
||||
"| [CoreML](https://github.com/apple/coremltools) | `coreml` | `yolov8n.mlpackage` | ✅ | `imgsz`, `half`, `int8`, `nms` |\n",
|
||||
"| [TF SavedModel](https://www.tensorflow.org/guide/saved_model) | `saved_model` | `yolov8n_saved_model/` | ✅ | `imgsz`, `keras` |\n",
|
||||
"| [TF SavedModel](https://www.tensorflow.org/guide/saved_model) | `saved_model` | `yolov8n_saved_model/` | ✅ | `imgsz`, `keras`, `int8` |\n",
|
||||
"| [TF GraphDef](https://www.tensorflow.org/api_docs/python/tf/Graph) | `pb` | `yolov8n.pb` | ❌ | `imgsz` |\n",
|
||||
"| [TF Lite](https://www.tensorflow.org/lite) | `tflite` | `yolov8n.tflite` | ✅ | `imgsz`, `half`, `int8` |\n",
|
||||
"| [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | `imgsz` |\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue