mirror of
https://github.com/opencv/opencv.git
synced 2026-11-14 12:18:09 -06:00
python: warn once when ml_dtypes is missing and bfloat16 / float8 are widened to float32
Signed-off-by: Abhishek Gola <abhishek.gola@bigvisionllc.com>
This commit is contained in:
@@ -369,6 +369,9 @@ PyObject* pyopencv_from(const cv::Mat& m)
|
||||
if( PyArray_Descr* descr = mlDtypeDescrForCvDepth(m.depth()) )
|
||||
return pyopencv_from_mldtype(m, descr);
|
||||
// Without ml_dtypes NumPy cannot name these; widen to float32 (lossless).
|
||||
CV_LOG_ONCE_WARNING(NULL, "Python bindings: ml_dtypes package is not found, "
|
||||
"bfloat16 / float8 arrays are returned as float32. "
|
||||
"Install ml_dtypes to keep the exact dtype.");
|
||||
cv::Mat m32f;
|
||||
ERRWRAP2(m.convertTo(m32f, CV_32F));
|
||||
return pyopencv_from(m32f);
|
||||
|
||||
Reference in New Issue
Block a user