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,22 +1,24 @@
|
||||
This is a list of real-world applications and walkthroughs. These can be folders of either python files or notebooks .
|
||||
## Ultralytics YOLOv8 Example Applications
|
||||
|
||||
## Ultralytics YOLO example applications
|
||||
This repository features a collection of real-world applications and walkthroughs, provided as either Python files or notebooks. Explore the examples below to see how YOLOv8 can be integrated into various applications.
|
||||
|
||||
### Ultralytics YOLO Example Applications
|
||||
|
||||
| Title | Format | Contributor |
|
||||
| ------------------------------------------------------------------------ | ------------------ | --------------------------------------------------- |
|
||||
| [YOLO ONNX detection Inference with C++](./YOLOv8-CPP-Inference) | C++/ONNX | [Justas Bartnykas](https://github.com/JustasBart) |
|
||||
| [YOLO OpenCV ONNX detection Python](./YOLOv8-OpenCV-ONNX-Python) | OpenCV/Python/ONNX | [Farid Inawan](https://github.com/frdteknikelektro) |
|
||||
| [YOLO .Net ONNX detection C#](https://www.nuget.org/packages/Yolov8.Net) | C# .Net | [Samuel Stainback](https://github.com/sstainba) |
|
||||
| [YOLO ONNX Detection Inference with C++](./YOLOv8-CPP-Inference) | C++/ONNX | [Justas Bartnykas](https://github.com/JustasBart) |
|
||||
| [YOLO OpenCV ONNX Detection Python](./YOLOv8-OpenCV-ONNX-Python) | OpenCV/Python/ONNX | [Farid Inawan](https://github.com/frdteknikelektro) |
|
||||
| [YOLO .Net ONNX Detection C#](https://www.nuget.org/packages/Yolov8.Net) | C# .Net | [Samuel Stainback](https://github.com/sstainba) |
|
||||
|
||||
## How can you contribute ?
|
||||
### How to Contribute
|
||||
|
||||
We're looking for examples, applications and guides from the community. Here's how you can contribute:
|
||||
We welcome contributions from the community in the form of examples, applications, and guides. To contribute, please follow these steps:
|
||||
|
||||
- Make a PR with `[Example]` prefix in title after adding your project folder in the examples/ folder of the repository
|
||||
- The project should satisfy these conditions:
|
||||
- It should use ultralytics framework
|
||||
- It have a README.md with instructions to run the project
|
||||
- It should avoid adding large assets or dependencies unless absolutely needed
|
||||
- The contributor is expected to help out in issues related to their examples
|
||||
1. Create a pull request (PR) with the `[Example]` prefix in the title, adding your project folder to the `examples/` directory in the repository.
|
||||
1. Ensure that your project meets the following criteria:
|
||||
- Utilizes the `ultralytics` package.
|
||||
- Includes a `README.md` file with instructions on how to run the project.
|
||||
- Avoids adding large assets or dependencies unless absolutely necessary.
|
||||
- The contributor is expected to provide support for issues related to their examples.
|
||||
|
||||
If you're unsure about any of these requirements, make a PR and we'll happy to guide you
|
||||
If you have any questions or concerns about these requirements, please submit a PR, and we will be more than happy to guide you.
|
||||
|
@ -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};
|
||||
|
||||
|
@ -27,7 +27,7 @@ def main(onnx_model, input_image):
|
||||
image[0:height, 0:width] = original_image
|
||||
scale = length / 640
|
||||
|
||||
blob = cv2.dnn.blobFromImage(image, scalefactor=1 / 255, size=(640, 640))
|
||||
blob = cv2.dnn.blobFromImage(image, scalefactor=1 / 255, size=(640, 640), swapRB=True)
|
||||
model.setInput(blob)
|
||||
outputs = model.forward()
|
||||
|
||||
|
Reference in New Issue
Block a user