yolov5
yolov5 copied to clipboard
Segmentation in C++
Search before asking
- [X] I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
Hi, thanks for your work.
Is it possible to infer the segmentation in C++?
Additional
No response
Yes, it is. After exporting the model to torchscript, you can use C++ to infer the segmentation in C++. You can find more info on using torchscript models with c++ here https://pytorch.org/tutorials/advanced/cpp_export.html
@AyushExel Hi,
I couldn't find any solution. Is there anything you could suggest about inference in ONNX or TensorRt C++?
Thanks in advance
Hi i have found a c++ demo infer by ncnn, hope to help you.
https://github.com/FeiGeChuanShu/yolov5-seg-ncnn
Hi i have found a c++ demo infer by ncnn, hope to help you. https://github.com/FeiGeChuanShu/yolov5-seg-ncnn
I have seen it before, but I want an example in TensorRt or onnx
@sctrueew example by opencv-dnn: https://github.com/UNeedCryDear/yolov5-seg-opencv-dnn-cpp
@UNeedCryDear Hi, Thank you for sharing
@UNeedCryDear thanks, added to export tutorial https://docs.ultralytics.com/yolov5/tutorials/model_export
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 🚀 resources:
- Wiki – https://github.com/ultralytics/yolov5/wiki
- Tutorials – https://docs.ultralytics.com/yolov5
- Docs – https://docs.ultralytics.com
Access additional Ultralytics ⚡ resources:
- Ultralytics HUB – https://ultralytics.com/hub
- Vision API – https://ultralytics.com/yolov5
- About Us – https://ultralytics.com/about
- Join Our Team – https://ultralytics.com/work
- Contact Us – https://ultralytics.com/contact
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!
how to deploy yolov5 instance segmentation model on Ubuntu with C++ and onnxruntime?
@HXB-1997 you can deploy a YOLOv5 instance segmentation model on Ubuntu with C++ and ONNX Runtime. Here are the general steps you can follow:
-
Export your trained YOLOv5 model to ONNX format using the
export.py
script provided in the YOLOv5 repository. -
Install ONNX Runtime on your Ubuntu system. You can follow the installation instructions provided in the ONNX Runtime documentation.
-
Write a C++ program that loads the ONNX model using the ONNX Runtime C++ API. You can use the
InferenceSession
class to load the model and perform inference. -
Preprocess your input images or video frames according to the requirements of the YOLOv5 model. This may involve resizing, normalization, and other transformations.
-
Pass the preprocessed data to the loaded model using the
Run
method of theInferenceSession
class. -
Process the output of the model to obtain the instance segmentation results. This may involve decoding the bounding box coordinates, applying non-maximum suppression, and visualizing the segmentation masks.
-
Compile and run your C++ program, and verify that it produces the desired instance segmentation results.
Please note that these are general steps, and you may need to adapt them to your specific use case and programming environment.