yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

Segmentation in C++

Open sctrueew opened this issue 1 year ago • 3 comments

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

sctrueew avatar Sep 19 '22 05:09 sctrueew

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 avatar Sep 19 '22 05:09 AyushExel

@AyushExel Hi,

I couldn't find any solution. Is there anything you could suggest about inference in ONNX or TensorRt C++?

Thanks in advance

sctrueew avatar Sep 19 '22 17:09 sctrueew

Hi i have found a c++ demo infer by ncnn, hope to help you.
https://github.com/FeiGeChuanShu/yolov5-seg-ncnn

hylrh2008 avatar Sep 20 '22 08:09 hylrh2008

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 avatar Sep 27 '22 17:09 sctrueew

@sctrueew example by opencv-dnn: https://github.com/UNeedCryDear/yolov5-seg-opencv-dnn-cpp

UNeedCryDear avatar Oct 10 '22 07:10 UNeedCryDear

@UNeedCryDear Hi, Thank you for sharing

sctrueew avatar Oct 10 '22 08:10 sctrueew

@UNeedCryDear thanks, added to export tutorial https://docs.ultralytics.com/yolov5/tutorials/model_export

glenn-jocher avatar Oct 10 '22 13:10 glenn-jocher

👋 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 ⭐!

github-actions[bot] avatar Nov 10 '22 00:11 github-actions[bot]

how to deploy yolov5 instance segmentation model on Ubuntu with C++ and onnxruntime?

HXB-1997 avatar Oct 31 '23 02:10 HXB-1997

@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:

  1. Export your trained YOLOv5 model to ONNX format using the export.py script provided in the YOLOv5 repository.

  2. Install ONNX Runtime on your Ubuntu system. You can follow the installation instructions provided in the ONNX Runtime documentation.

  3. 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.

  4. Preprocess your input images or video frames according to the requirements of the YOLOv5 model. This may involve resizing, normalization, and other transformations.

  5. Pass the preprocessed data to the loaded model using the Run method of the InferenceSession class.

  6. 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.

  7. 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.

glenn-jocher avatar Oct 31 '23 04:10 glenn-jocher