Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVS-160560 nanobindings for keypoint detection and segmentation #258

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

mgumowsk
Copy link
Collaborator

@mgumowsk mgumowsk commented Jan 22, 2025

What does this PR do?

Ready for python replacement, this will have the same structure results as python version:

  • AnomalyDetection
  • Classification
  • Detection
  • KeypointDetection
  • Segmentation

Still needs work:

  • InstanceSegmentation - this will be done in a separate PR

@mgumowsk mgumowsk requested a review from sovrasov January 23, 2025 08:05
@github-actions github-actions bot added the cpp C++ related changes label Jan 27, 2025
nb::class_<InstanceSegmentationResult, ResultBase>(m, "InstanceSegmentationResult")
.def(nb::init<int64_t, std::shared_ptr<MetaData>>(), nb::arg("frameId") = -1, nb::arg("metaData") = nullptr)
.def_prop_ro(
"feature_vector",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iseg result also contains a saliency map as a vector of cv::Mat. Perhaps, it's not that easy to expose but there is a chance a vector of nb::ndarray<uint8_t... would work here

.def_prop_ro(
"soft_prediction",
[](ResultBase& r) {
ImageResultWithSoftPrediction ir = r.asRef<ImageResultWithSoftPrediction>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that work if the result entity is actually an ImageResult?
In sseg wrapper now we have the following logic:

if (return_soft_prediction) {
  return a ptr to ImageResultWithSoftPrediction
}
else 
  return a ptr to ImageResult

infer() method's return type is a ptr to ImageResult. I think that kind of design looks weird an overall inconvenient, because we always need to check if type conversion to ImageResultWithSoftPrediction is successful.
Related refactoring can be done in subsequent PR, here we just need to be sure that both the cases return_soft_prediction==true/false are handled correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp C++ related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants