From 697204d47be4a3864f4b5509a8ad973bbc811ea8 Mon Sep 17 00:00:00 2001 From: MiXaiLL76 Date: Wed, 28 Aug 2024 11:53:33 +0300 Subject: [PATCH] pathlib.PosixPath support --- faster_coco_eval/core/coco.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/faster_coco_eval/core/coco.py b/faster_coco_eval/core/coco.py index d885da7..935ae99 100644 --- a/faster_coco_eval/core/coco.py +++ b/faster_coco_eval/core/coco.py @@ -5,6 +5,7 @@ import json import logging import os +import pathlib import time import warnings from collections import defaultdict @@ -25,7 +26,9 @@ def _isArrayLike(obj): class COCO: def __init__( self, - annotation_file: Optional[Union[str, dict, os.PathLike]] = None, + annotation_file: Optional[ + Union[str, dict, os.PathLike, pathlib.PosixPath] + ] = None, use_deepcopy: bool = False, ): """Constructor of Microsoft COCO helper class. @@ -51,7 +54,7 @@ def __init__( if annotation_file is not None: self._print_function("loading annotations into memory...") tic = time.time() - if type(annotation_file) in [str, os.PathLike]: + if type(annotation_file) in [str, os.PathLike, pathlib.PosixPath]: self.dataset = self.load_json(annotation_file) elif type(annotation_file) is dict: if self.use_deepcopy: