mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #27600 from atamas19:ov_output_clamping
G-API: Implement cfgClampOutputs option to OpenVINO Params #27600 Added the option `cfgClampOutputs` to control where output clamping is performed for OpenVINO models. When enabled, output values are clamped in the PrePostProcessor stage instead of by the device or plugin. This provides a consistent and standardized clamping method across devices, helping to maintain accuracy regardless of device-specific clamping behavior. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -66,6 +66,8 @@ struct ParamDesc {
|
||||
LayerVariantAttr<std::vector<float>> scale_values;
|
||||
|
||||
LayerVariantAttr<int> interpolation;
|
||||
|
||||
bool clamp_outputs = false;
|
||||
};
|
||||
|
||||
struct CompiledModel {
|
||||
@@ -356,6 +358,24 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Enables or disables clamping of model outputs in the PrePostProcessor.
|
||||
|
||||
By default, output values are clamped to the valid range for the output precision
|
||||
by the device or plugin. Enabling this option moves clamping to the PrePostProcessor stage.
|
||||
|
||||
@note This feature is only available with OpenVINO 2025.2 and newer.
|
||||
|
||||
@param flag If true, clamping is performed in the PrePostProcessor;
|
||||
otherwise, it is handled by the device or plugin.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies the new shape for input layers.
|
||||
|
||||
The function is used to set new shape for input layers.
|
||||
@@ -625,6 +645,14 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgClampOutputs. */
|
||||
Params&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgReshape. */
|
||||
Params& cfgReshape(std::vector<size_t> new_shape) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "reshape")
|
||||
|
||||
Reference in New Issue
Block a user