Kaynağa Gözat

str path (#2144)

* str path

* bugfix

* add faiss-cpu

* bugfix
Tingquan Gao 1 yıl önce
ebeveyn
işleme
755d1e5e28

+ 3 - 3
paddlex/inference/pipelines/__init__.py

@@ -66,17 +66,17 @@ def create_pipeline_from_config(
         predictor_kwargs["use_hpip"] = use_hpip
     if hpi_params is not None:
         predictor_kwargs["hpi_params"] = hpi_params
-        pipeline_setting.pop("hpi_params")
+        pipeline_setting.pop("hpi_params", None)
     elif "hpi_params" in pipeline_setting:
         predictor_kwargs["hpi_params"] = pipeline_setting.pop("hpi_params")
     if device is not None:
         predictor_kwargs["device"] = device
-        pipeline_setting.pop("device")
+        pipeline_setting.pop("device", None)
     elif "device" in pipeline_setting:
         predictor_kwargs["device"] = pipeline_setting.pop("device")
     if pp_option is not None:
         predictor_kwargs["pp_option"] = pp_option
-        pipeline_setting.pop("pp_option")
+        pipeline_setting.pop("pp_option", None)
     elif "pp_option" in pipeline_setting:
         predictor_kwargs["pp_option"] = pipeline_setting.pop("pp_option")
 

+ 4 - 4
paddlex/inference/utils/io/readers.py

@@ -81,7 +81,7 @@ class PDFReader(_BaseReader):
         super().__init__(backend, **bk_args)
 
     def read(self, in_path):
-        return self._backend.read_file(in_path)
+        return self._backend.read_file(str(in_path))
 
     def _init_backend(self, bk_type, bk_args):
         return PDFReaderBackend(**bk_args)
@@ -98,7 +98,7 @@ class ImageReader(_BaseReader):
 
     def read(self, in_path):
         """read the image file from path"""
-        arr = self._backend.read_file(in_path)
+        arr = self._backend.read_file(str(in_path))
         return arr
 
     def _init_backend(self, bk_type, bk_args):
@@ -147,7 +147,7 @@ class VideoReader(_GenerativeReader):
     def read(self, in_path):
         """read vide file from path"""
         self._backend.set_pos(self.st_frame_id)
-        gen = self._backend.read_file(in_path)
+        gen = self._backend.read_file(str(in_path))
         if self.num_frames is not None:
             gen = itertools.islice(gen, self.num_frames)
         yield from gen
@@ -286,7 +286,7 @@ class CSVReader(_BaseReader):
 
     def read(self, in_path):
         """read the image file from path"""
-        arr = self._backend.read_file(in_path)
+        arr = self._backend.read_file(str(in_path))
         return arr
 
     def _init_backend(self, bk_type, bk_args):

+ 6 - 6
paddlex/inference/utils/io/writers.py

@@ -95,7 +95,7 @@ class ImageWriter(_BaseWriter):
 
     def write(self, out_path, obj):
         """write"""
-        return self._backend.write_obj(out_path, obj)
+        return self._backend.write_obj(str(out_path), obj)
 
     def _init_backend(self, bk_type, bk_args):
         """init backend"""
@@ -119,7 +119,7 @@ class TextWriter(_BaseWriter):
 
     def write(self, out_path, obj):
         """write"""
-        return self._backend.write_obj(out_path, obj)
+        return self._backend.write_obj(str(out_path), obj)
 
     def _init_backend(self, bk_type, bk_args):
         """init backend"""
@@ -138,7 +138,7 @@ class JsonWriter(_BaseWriter):
         super().__init__(backend=backend, **bk_args)
 
     def write(self, out_path, obj, **bk_args):
-        return self._backend.write_obj(out_path, obj, **bk_args)
+        return self._backend.write_obj(str(out_path), obj, **bk_args)
 
     def _init_backend(self, bk_type, bk_args):
         if bk_type == "json":
@@ -158,7 +158,7 @@ class HtmlWriter(_BaseWriter):
         super().__init__(backend=backend, **bk_args)
 
     def write(self, out_path, obj, **bk_args):
-        return self._backend.write_obj(out_path, obj, **bk_args)
+        return self._backend.write_obj(str(out_path), obj, **bk_args)
 
     def _init_backend(self, bk_type, bk_args):
         if bk_type == "html":
@@ -176,7 +176,7 @@ class XlsxWriter(_BaseWriter):
         super().__init__(backend=backend, **bk_args)
 
     def write(self, out_path, obj, **bk_args):
-        return self._backend.write_obj(out_path, obj, **bk_args)
+        return self._backend.write_obj(str(out_path), obj, **bk_args)
 
     def _init_backend(self, bk_type, bk_args):
         if bk_type == "xlsx":
@@ -307,7 +307,7 @@ class CSVWriter(_BaseWriter):
 
     def write(self, out_path, obj):
         """write"""
-        return self._backend.write_obj(out_path, obj)
+        return self._backend.write_obj(str(out_path), obj)
 
     def _init_backend(self, bk_type, bk_args):
         """init backend"""

+ 5 - 5
paddlex/inference/utils/pp_option.py

@@ -121,7 +121,7 @@ class PaddlePredictorOption(object):
 
     @property
     def shape_info_filename(self):
-        self._cfg["shape_info_filename"]
+        return self._cfg["shape_info_filename"]
 
     @shape_info_filename.setter
     def shape_info_filename(self, shape_info_filename: str):
@@ -130,7 +130,7 @@ class PaddlePredictorOption(object):
 
     @property
     def trt_calib_mode(self):
-        self._cfg["trt_calib_mode"]
+        return self._cfg["trt_calib_mode"]
 
     @trt_calib_mode.setter
     def trt_calib_mode(self, trt_calib_mode):
@@ -139,7 +139,7 @@ class PaddlePredictorOption(object):
 
     @property
     def cpu_threads(self):
-        self._cfg["cpu_threads"]
+        return self._cfg["cpu_threads"]
 
     @cpu_threads.setter
     def cpu_threads(self, cpu_threads):
@@ -150,7 +150,7 @@ class PaddlePredictorOption(object):
 
     @property
     def trt_use_static(self):
-        self._cfg["trt_use_static"]
+        return self._cfg["trt_use_static"]
 
     @trt_use_static.setter
     def trt_use_static(self, trt_use_static):
@@ -167,7 +167,7 @@ class PaddlePredictorOption(object):
 
     @property
     def enable_new_ir(self):
-        self._cfg["enable_new_ir"]
+        return self._cfg["enable_new_ir"]
 
     @enable_new_ir.setter
     def enable_new_ir(self, enable_new_ir: bool):

+ 1 - 0
requirements.txt

@@ -31,3 +31,4 @@ erniebot == 0.5.0
 erniebot-agent == 0.5.0
 unstructured
 networkx
+faiss-cpu