From 03a2e4d9d4d9c2eb993db41af22a7d7c59d83559 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:46:04 +0200 Subject: [PATCH 1/4] [DOC] Added important information about how to export a YoloV7 model in the documentation of the detection by DNN tutorial --- doc/tutorial/detection_dnn/tutorial-detection-dnn.dox | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox index 0ab2a417f1..f1752ff8dd 100644 --- a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox +++ b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox @@ -474,6 +474,11 @@ If you want to train your own YoloV7 model, please refer to the [official docume If your dataset is rather small (only hundreds of pictures), you may want to consider to base your training on `yolov7-tiny` network, as it tends to get better results. +**Important note**: if you train your own model, be sure to use the same image size in the `python train.py`, +`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to : +- an error thrown by OpenCV +- the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. + \subsubsection dnn_supported_yolov8 Yolo v8 You can find the weights (`yolov8s.onnx`) in ONNX format From 54369800e4fde33f42316707ba2f3bf8fcccf776 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:50:41 +0200 Subject: [PATCH 2/4] [DOC] Added note about potential issue when following blenderproc tutorial --- doc/tutorial/misc/tutorial-synthetic-blenderproc.dox | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox index 91f04a807a..c22ddd297d 100644 --- a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox +++ b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox @@ -715,6 +715,17 @@ We also download the pretrained yolo model, that we will finetune on our own dat (yolov7) ~/yolov7 $ wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt ``` +**Important note**: while creating the yolov7 virtual environment, you may face the following error: +``` +requirements to build wheel did not run successfully +``` +It can be solved by fixing the version of the Python of the virtual environment: +``` +~/yolov7 $ conda create --name yolov7 pip python=3.10 +~/yolov7 $ conda activate yolov7 +(yolov7) ~/yolov7 $ pip install -r requirements.txt +``` + To fine-tune a YoloV7, we should create two new files: the network configuration and the hyperparameters. We will reuse the ones provided for the tiny model. ``` From 307082c720cba02b49e96c40a7e346700160bb3d Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:52:08 +0200 Subject: [PATCH 3/4] [TUTO][FIX] Fixing error when image is RGBa instead of BGR --- .../detection/dnn/tutorial-dnn-object-detection-live.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp index 44f670a142..4f8fe47c1b 100644 --- a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp +++ b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp @@ -338,6 +338,11 @@ int main(int argc, const char *argv[]) cv::Mat frame; while (true) { capture >> frame; + if (frame.type() == CV_8UC4) { + // RGBa format is not supported by the class, converting to BGR format + cv::Mat cpy = frame; + cv::cvtColor(cpy, frame, cv::COLOR_RGBA2BGR); + } if (frame.empty()) break; From a526b11391b0242d4e3fe5a726e307864cde8dee Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 11:01:01 +0200 Subject: [PATCH 4/4] [DOC] Improved readability of the warnings --- .../detection_dnn/tutorial-detection-dnn.dox | 7 +++---- .../misc/tutorial-synthetic-blenderproc.dox | 13 +++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox index f1752ff8dd..c5897fb046 100644 --- a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox +++ b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox @@ -474,10 +474,9 @@ If you want to train your own YoloV7 model, please refer to the [official docume If your dataset is rather small (only hundreds of pictures), you may want to consider to base your training on `yolov7-tiny` network, as it tends to get better results. -**Important note**: if you train your own model, be sure to use the same image size in the `python train.py`, -`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to : -- an error thrown by OpenCV -- the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. +\warning If you train your own model, be sure to use the same image size in the `python train.py`, +`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to either an error thrown +by OpenCV or the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. \subsubsection dnn_supported_yolov8 Yolo v8 diff --git a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox index c22ddd297d..e6e576ce6a 100644 --- a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox +++ b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox @@ -715,16 +715,9 @@ We also download the pretrained yolo model, that we will finetune on our own dat (yolov7) ~/yolov7 $ wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt ``` -**Important note**: while creating the yolov7 virtual environment, you may face the following error: -``` -requirements to build wheel did not run successfully -``` -It can be solved by fixing the version of the Python of the virtual environment: -``` -~/yolov7 $ conda create --name yolov7 pip python=3.10 -~/yolov7 $ conda activate yolov7 -(yolov7) ~/yolov7 $ pip install -r requirements.txt -``` +\warning While creating the yolov7 virtual environment, you may face the following error: +"requirements to build wheel did not run successfully". It can be solved by fixing the version of the Python of +the virtual environment: `conda create --name yolov7 pip python=3.10` To fine-tune a YoloV7, we should create two new files: the network configuration and the hyperparameters. We will reuse the ones provided for the tiny model.