Thanks for the help Klemen.
QuickConversion works. This tool also made me realise what I was doing wrong: incompatible snpe version.
Step-by-step I followed when attempting to convert a yolo11m-seg (followed model conversion):
onnx conversion
1.1: setup tools-cli
1.2: conversion command: tools yolo11m-seg.pt --imgsz "640 640" --no-use-rvc2
ModelConverter
2.1: pip install modelconv
2.2: created folders and copied onnx model to folder archives
2.3: conversion command: modelconverter convert rvc4 --path archives/yolo11m-seg.tar.xz --to nn_archive rvc4.quantization_mode FP16_STANDARD
-- I got the following error:
*Failed to pull the image, building it locally... docker_utils.py:434
WARNING SNPE archive not found at .build/rvc4/modelconverter-0.5.4-beta/docker/extra_packages/snpe-2.32.6.zip; attempting download from https://softwarecenter.qualcomm.com/api/download/software/sdks/Qualcomm_AI_Runtime_Community/All/2.32.6/v2.32.6.zip docker_utils.py:234
RuntimeError: Failed to download SNPE archive from https://softwarecenter.qualcomm.com/api/download/software/sdks/Qualcomm_AI_Runtime_Community/All/2.32.6/v2.32.6.zip: HTTP Error 404: Not Found. Download it manually from https://softwarecenter.qualcomm.com/catalog/item/Qualcomm_AI_Runtime_Community and save it as .build/rvc4/modelconverter-0.5.4-beta/docker/extra_packages/snpe-2.32.6.zip.*
2.4: Manually downloaded the latest snpe version from: https://softwarecenter.qualcomm.com/catalog/item/Qualcomm_AI_Runtime_Community. Currently, the defalult version is 2.46.
2.5: moved to the requested folder and executed the command again.
Attempted to load converted model in C++:
constexpr float FPS = 15.0f;
device_ = std::make_shared<dai::Device>();
pipeline_ = std::make_unique<dai::Pipeline>(device_);
auto camColour = pipeline_->create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);
auto camLeft = pipeline_->create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_B);
auto camRight = pipeline_->create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_C);
auto objDetector = pipeline_->create<dai::node::DetectionNetwork>();
auto stereo = pipeline_->create<dai::node::NeuralDepth>();
auto pc = pipeline_->create<dai::node::PointCloud>();
auto imageAlign = pipeline_->create<dai::node::ImageAlign>();
auto sync = pipeline_->create<dai::node::Sync>();
dai::NNArchive modelArchive("/ws2/dnn_models/yolo11m-seg.rvc4.tar.xz");
auto imgsz = modelArchive.getInputSize().value();
objDetector->build(camColour, modelArchive, FPS, dai::ImgResizeMode::CROP);
auto leftOut = camLeft->requestFullResolutionOutput(std::nullopt, FPS);
auto rightOut = camRight->requestFullResolutionOutput(std::nullopt, FPS);
stereo->build(*leftOut, *rightOut, dai::DeviceModelZoo::NEURAL_DEPTH_864X540);
pc->initialConfig->setLengthUnit(dai::LengthUnit::METER);
pc->initialConfig->setOrganized(true);
pc->setTargetCoordinateSystem(dai::CameraBoardSocket::CAM_A);
pc->useCPUMT();
stereo->depth.link(imageAlign->input);
objDetector->passthrough.link(imageAlign->inputAlignTo);
imageAlign->outputAligned.link(pc->inputDepth);
//objDetector->passthrough.link(sync->inputs["colour"]);
objDetector->out.link(sync->inputs["dets"]);
pc->outputPointCloud.link(sync->inputs["cloud"]);
queue_ = sync->out.createOutputQueue(1, false);
pipeline_->start();
device_->setIrLaserDotProjectorIntensity(0.7f);
device_->setIrFloodLightIntensity(0.3f);
callback_id_ = queue_->addCallback(
[this](std::shared_ptr<dai::ADatatype> data) {
auto msg = std::dynamic_pointer_cast<dai::MessageGroup>(data);
if (msg) {
auto dets = msg->get<dai::ImgDetections>("dets");
auto cloud = msg->get<dai::PointCloudData>("cloud");
auto seg_msk = dets->getSegmentationMask();
if (!cloud || !dets || !seg_msk)
return;
const auto mask_data = seg_msk->getData();
…}});
Code compiles and runs ("oakctl app run ."); however, model always reported 0 detections.
After my experience with the QuickConversion, I replaced the snpe version I downloaded (2.46) with 2.32.6 and attempted to convert the model again with ModelConvert. This time, the converted model worked.
I would recommend an update to the ModelConverter page. I might be missing something, but I don't see anything stating that ModelConverter requires version 2.32.6. In my view, In the sentence "For RVC4, a full SNPE build version such as 2.32.6….", the term 'such as' indicates that other versions should work.
Some questions:
- Since the resulting converted archive file contains only 1 dlc model (rather than 2 like "luxonis/yolov8-instance-segmentation-large"), am I correct to assume that mask post processing is done by the CPU instead of a neural network?
- When converting a model using modelconvert, I added "--to nn_archive" to the command. How and when should I use the native version (which seems to give just a .dlc file)? Coulnd't find documentation about it.
- (extra) Am I doing anything wrong/inefficiently in the code snippet I provided? For my use case, I want to extract data from the pointcloud based on the incoming instance segmentation masks.
Thanks for the support.
Regards,
Goulart