[libcamera-devel] [PATCH v1 1/3] utils: raspberrypi: ctt: Fix namespace for sklearn NearestCentroid function
David Plowman
david.plowman at raspberrypi.com
Mon Aug 2 10:20:34 CEST 2021
The NearestCentroid function is in the sklearn.neighbors namespace
since version 0.22.
Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
Reviewed-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
utils/raspberrypi/ctt/ctt_tools.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py
index 48e0aac2..41c4efb6 100644
--- a/utils/raspberrypi/ctt/ctt_tools.py
+++ b/utils/raspberrypi/ctt/ctt_tools.py
@@ -14,7 +14,12 @@ import imutils
import sys
import matplotlib.pyplot as plt
from sklearn import cluster as cluster
-from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids
+try:
+ # From sklearn version 0.22 onwards, NearestCentroid is no longer in the
+ # nearest_centroid module
+ from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids
+except (ModuleNotFoundError):
+ from sklearn.neighbors import NearestCentroid as get_centroids
"""
This file contains some useful tools, the details of which aren't important to
--
2.30.2
More information about the libcamera-devel
mailing list