Open ablyzniuk opened 3 months ago
👋 Hello @ablyzniuk, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
@ablyzniuk yo buddy, inference on NCNN models is super easy, just use them the same as PyTorch models, i.e.:
from ultralytics import YOLO
# Export your NCNN model...
# Load your NCNN model
model = YOLO("path/to/your/ncnn_model")
# Run inference normally
results = model("path/to/img.jpg")
@ablyzniuk yo buddy, inference on NCNN models is super easy, just use them the same as PyTorch models, i.e.:
from ultralytics import YOLO # Export your NCNN model... # Load your NCNN model model = YOLO("path/to/your/ncnn_model") # Run inference normally results = model("path/to/img.jpg")
Hi Glen. I'm sorry but there is a misunderstanding. I asked how to post-process the output layer of the latest ultralytics YOLOV8/YOLOV5 model in C++. I had problems with latest ultralytics-ncnn models in C++ postprocessing implementation due to shape incompatibility.
Steps:
1) Converting model to ncnn via model.export(format='ncnn')
2) Loading model in C++ yolov5.load_param("yolov5n.ncnn.param"); yolov5.load_model("yolov5n.ncnn.bin");
3) Standard image preprocess taken from Tencent C++ examples.
4) Inference.
5) Postprocess of the output layer with (1, 84, 8400) dims.
On fifth step I still have problems. I visualized output tensor and I saw that a great part of it is zerod. Only a couple of raws had a useful info. After standard moves like reshape/transpose the mess of the numbers still remains. I tried to rewrite ultralytics postprocess, and the result was the same. Can you please give me some instructions/tips/advice how should I work with ultralytics-ncnn YoloV5/YoloV8 models on ncnn c++ postprocess step?
@ablyzniuk it sounds like you're encountering issues with the post-processing step of YOLOv5/YOLOv8 models in NCNN. The output shape (1, 84, 8400) indicates that you have 8400 anchors, each with 84 values (4 for bounding box coordinates, 1 for objectness score, and 79 for class scores). The zeros you see are likely due to the objectness score threshold not being met.
Ensure you correctly parse the output tensor by iterating over the anchors and applying a threshold to the objectness score. Only process anchors with objectness scores above this threshold. Then, extract the bounding box coordinates and class scores for these anchors.
If you continue to face issues, please verify that you are using the latest version of the Ultralytics package and NCNN. This ensures compatibility and includes any recent bug fixes. For detailed guidance, refer to the Ultralytics documentation and NCNN examples. If the problem persists, consider opening an issue on the Ultralytics GitHub repository with detailed information about your implementation.
@ablyzniuk it sounds like you're encountering issues with the post-processing step of YOLOv5/YOLOv8 models in NCNN. The output shape (1, 84, 8400) indicates that you have 8400 anchors, each with 84 values (4 for bounding box coordinates, 1 for objectness score, and 79 for class scores). The zeros you see are likely due to the objectness score threshold not being met.
Ensure you correctly parse the output tensor by iterating over the anchors and applying a threshold to the objectness score. Only process anchors with objectness scores above this threshold. Then, extract the bounding box coordinates and class scores for these anchors.
If you continue to face issues, please verify that you are using the latest version of the Ultralytics package and NCNN. This ensures compatibility and includes any recent bug fixes. For detailed guidance, refer to the Ultralytics documentation and NCNN examples. If the problem persists, consider opening an issue on the Ultralytics GitHub repository with detailed information about your implementation.
@pderrenger Thanks!!!! Got it, I will. Thank you again. Best regards.
You're welcome! If you encounter any further issues or need additional assistance, feel free to reach out. Make sure to check the latest versions of the Ultralytics package and NCNN for any updates that might resolve your problem. Best of luck with your project!
Search before asking
Question
Can someone give me some tips or code pieces, on how to make the correct postprocessing for YoloV8 or YoloV5 output shape(1, 84, 8400) on C++? I did it in a standard way(after reshaping ncnn::Mat pred, iterating over 8400 anchors) but the outputs are a mess of random numbers. I've tried a lot of Tencents examples, but it seems it hasn't been adapted for the latest release of Ultralytics, because yolo5 and yolo8 have similar output shapes in the latest releases, and examples from 2020 are not matched to it.
I'm looking forward to your reply ASAP))) Best regards.
Additional
No response