ultralytics 8.0.62
HUB Syntax updates and fixes (#1795)
Co-authored-by: Danny Kim <imbird0312@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: MagicCodess <32194768+MagicCodess@users.noreply.github.com> Co-authored-by: ayush chaurasia <ayush.chaurarsia@gmail.com> Co-authored-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
# yolov8/yolov5 Inference C++
|
||||
# YOLOv8/YOLOv5 Inference C++
|
||||
|
||||
Usage:
|
||||
This example demonstrates how to perform inference using YOLOv8 and YOLOv5 models in C++ with OpenCV's DNN API.
|
||||
|
||||
```
|
||||
# git clone ultralytics
|
||||
## Usage
|
||||
|
||||
```commandline
|
||||
git clone ultralytics
|
||||
cd ultralytics
|
||||
pip install .
|
||||
cd examples/cpp_
|
||||
|
||||
Add a **yolov8\_.onnx** and/or **yolov5\_.onnx** model(s) to the ultralytics folder.
|
||||
Edit the **main.cpp** to change the **projectBasePath** to match your user.
|
||||
# Add a **yolov8\_.onnx** and/or **yolov5\_.onnx** model(s) to the ultralytics folder.
|
||||
# Edit the **main.cpp** to change the **projectBasePath** to match your user.
|
||||
|
||||
Note that by default the CMake file will try and import the CUDA library to be used with the OpenCVs dnn (cuDNN) GPU Inference.
|
||||
If your OpenCV build does not use CUDA/cuDNN you can remove that import call and run the example on CPU.
|
||||
# Note that by default the CMake file will try and import the CUDA library to be used with the OpenCVs dnn (cuDNN) GPU Inference.
|
||||
# If your OpenCV build does not use CUDA/cuDNN you can remove that import call and run the example on CPU.
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
@ -20,24 +23,18 @@ make
|
||||
./Yolov8CPPInference
|
||||
```
|
||||
|
||||
To export yolov8 models:
|
||||
## Exporting YOLOv8 and YOLOv5 Models
|
||||
|
||||
```
|
||||
yolo export \
|
||||
model=yolov8s.pt \
|
||||
imgsz=[480,640] \
|
||||
format=onnx \
|
||||
opset=12
|
||||
To export YOLOv8 models:
|
||||
|
||||
```commandline
|
||||
yolo export model=yolov8s.pt imgsz=480,640 format=onnx opset=12
|
||||
```
|
||||
|
||||
To export yolov5 models:
|
||||
To export YOLOv5 models:
|
||||
|
||||
```
|
||||
python3 export.py \
|
||||
--weights yolov5s.pt \
|
||||
--img 480 640 \
|
||||
--include onnx \
|
||||
--opset 12
|
||||
```commandline
|
||||
python3 export.py --weights yolov5s.pt --img 480 640 --include onnx --opset 12
|
||||
```
|
||||
|
||||
yolov8s.onnx:
|
||||
@ -48,10 +45,6 @@ yolov5s.onnx:
|
||||
|
||||

|
||||
|
||||
This repository is based on OpenCVs dnn API to run an ONNX exported model of either yolov5/yolov8 (In theory should work
|
||||
for yolov6 and yolov7 but not tested). Note that for this example the networks are exported as rectangular (640x480)
|
||||
resolutions, but it would work for any resolution that you export as although you might want to use the letterBox
|
||||
approach for square images depending on your use-case.
|
||||
This repository utilizes OpenCV's DNN API to run ONNX exported models of YOLOv5 and YOLOv8. In theory, it should work for YOLOv6 and YOLOv7 as well, but they have not been tested. Note that the example networks are exported with rectangular (640x480) resolutions, but any exported resolution will work. You may want to use the letterbox approach for square images, depending on your use case.
|
||||
|
||||
The **main** branch version is based on using Qt as a GUI wrapper the main interest here is the **Inference** class file
|
||||
which shows how to transpose yolov8 models to work as yolov5 models.
|
||||
The **main** branch version uses Qt as a GUI wrapper. The primary focus here is the **Inference** class file, which demonstrates how to transpose YOLOv8 models to work as YOLOv5 models.
|
||||
|
@ -83,7 +83,7 @@ std::vector<Detection> Inference::runInference(const cv::Mat &input)
|
||||
{
|
||||
float confidence = data[4];
|
||||
|
||||
if (confidence >= modelConfidenseThreshold)
|
||||
if (confidence >= modelConfidenceThreshold)
|
||||
{
|
||||
float *classes_scores = data+5;
|
||||
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
|
||||
cv::Size2f modelShape{};
|
||||
|
||||
float modelConfidenseThreshold {0.25};
|
||||
float modelConfidenceThreshold {0.25};
|
||||
float modelScoreThreshold {0.45};
|
||||
float modelNMSThreshold {0.50};
|
||||
|
||||
|
Reference in New Issue
Block a user