From 33e4702e5852264f0842d36397d08e63ca373eff Mon Sep 17 00:00:00 2001 From: Fabien Racape Date: Tue, 10 Nov 2026 12:08:10 -0800 Subject: [PATCH] fix: remove dependency on six --- .../evaluators/tf_evaluation_utils/metrics.py | 2 -- .../tf_evaluation_utils/np_box_list.py | 2 -- .../tf_evaluation_utils/np_box_list_ops.py | 2 -- .../tf_evaluation_utils/np_box_mask_list_ops.py | 2 -- .../object_detection_evaluation.py | 17 +++++------------ .../tf_evaluation_utils/per_image_evaluation.py | 2 -- 6 files changed, 5 insertions(+), 22 deletions(-) diff --git a/compressai_vision/evaluators/tf_evaluation_utils/metrics.py b/compressai_vision/evaluators/tf_evaluation_utils/metrics.py index 8c78fd25..3b815dd5 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/metrics.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/metrics.py @@ -50,8 +50,6 @@ import numpy as np -from six.moves import range - def compute_precision_recall(scores, labels, num_gt): """Compute precision and recall. diff --git a/compressai_vision/evaluators/tf_evaluation_utils/np_box_list.py b/compressai_vision/evaluators/tf_evaluation_utils/np_box_list.py index 559d11da..f1fd5db0 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/np_box_list.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/np_box_list.py @@ -48,8 +48,6 @@ import numpy as np -from six.moves import range - __all__ = ["BoxList"] diff --git a/compressai_vision/evaluators/tf_evaluation_utils/np_box_list_ops.py b/compressai_vision/evaluators/tf_evaluation_utils/np_box_list_ops.py index 3dfebdc3..c2a47c36 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/np_box_list_ops.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/np_box_list_ops.py @@ -54,8 +54,6 @@ import numpy as np -from six.moves import range - from ..tf_evaluation_utils import np_box_list, np_box_ops diff --git a/compressai_vision/evaluators/tf_evaluation_utils/np_box_mask_list_ops.py b/compressai_vision/evaluators/tf_evaluation_utils/np_box_mask_list_ops.py index 610735ef..08cfcdf4 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/np_box_mask_list_ops.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/np_box_mask_list_ops.py @@ -54,8 +54,6 @@ import numpy as np -from six.moves import range - from ..tf_evaluation_utils import np_box_list_ops, np_box_mask_list, np_mask_ops diff --git a/compressai_vision/evaluators/tf_evaluation_utils/object_detection_evaluation.py b/compressai_vision/evaluators/tf_evaluation_utils/object_detection_evaluation.py index 8609cf92..8b5da730 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/object_detection_evaluation.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/object_detection_evaluation.py @@ -66,9 +66,6 @@ from abc import ABCMeta, abstractmethod import numpy as np -import six - -from six.moves import range from ..tf_evaluation_utils import per_image_evaluation from .label_map_util import create_category_index @@ -80,7 +77,7 @@ from .standard_fields import DetectionResultFields, InputDataFields -class DetectionEvaluator(six.with_metaclass(ABCMeta, object)): +class DetectionEvaluator(metaclass=ABCMeta): """Interface for object detection evalution classes. Example usage of the Evaluator: @@ -286,12 +283,10 @@ def _build_metric_names(self): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]["name"] try: - category_name = six.text_type(category_name, "utf-8") + category_name = str(category_name, "utf-8") except TypeError: pass category_name = unicodedata.normalize("NFKD", category_name) - if six.PY2: - category_name = category_name.encode("ascii", "ignore") self._metric_names.append( self._metric_prefix + "PerformanceByCategory/AP@{}IOU/{}".format( @@ -339,7 +334,7 @@ def add_single_ground_truth_image_info(self, image_id, groundtruth_dict): # If the key is not present in the groundtruth_dict or the array is empty # (unless there are no annotations for the groundtruth on this image) # use values from the dictionary or insert None otherwise. - if InputDataFields.groundtruth_difficult in six.viewkeys(groundtruth_dict) and ( + if InputDataFields.groundtruth_difficult in groundtruth_dict and ( groundtruth_dict[InputDataFields.groundtruth_difficult].size or not groundtruth_classes.size ): @@ -437,12 +432,10 @@ def evaluate(self): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]["name"] try: - category_name = six.text_type(category_name, "utf-8") + category_name = str(category_name, "utf-8") except TypeError: pass category_name = unicodedata.normalize("NFKD", category_name) - if six.PY2: - category_name = category_name.encode("ascii", "ignore") display_name = ( self._metric_prefix + "PerformanceByCategory/AP@{}IOU/{}".format( @@ -581,7 +574,7 @@ def add_single_ground_truth_image_info(self, image_id, groundtruth_dict): # If the key is not present in the groundtruth_dict or the array is empty # (unless there are no annotations for the groundtruth on this image) # use values from the dictionary or insert None otherwise. - if InputDataFields.groundtruth_group_of in six.viewkeys(groundtruth_dict) and ( + if InputDataFields.groundtruth_group_of in groundtruth_dict and ( groundtruth_dict[InputDataFields.groundtruth_group_of].size or not groundtruth_classes.size ): diff --git a/compressai_vision/evaluators/tf_evaluation_utils/per_image_evaluation.py b/compressai_vision/evaluators/tf_evaluation_utils/per_image_evaluation.py index 9e22821d..9c60ec2b 100644 --- a/compressai_vision/evaluators/tf_evaluation_utils/per_image_evaluation.py +++ b/compressai_vision/evaluators/tf_evaluation_utils/per_image_evaluation.py @@ -57,8 +57,6 @@ import numpy as np -from six.moves import range - from ..tf_evaluation_utils import ( np_box_list, np_box_list_ops,