Преглед изворни кода

bugfix (#3869)

* bugfix: page number is missed in path to save when input file format is PDF

* bugfix: remove models unsupported CINN from the whitelist

* bugfix: TRT cache don't work

* bugfix: incompatibility error when pandas > 1.5.3
Tingquan Gao пре 7 месеци
родитељ
комит
795e04563d

+ 11 - 0
paddlex/inference/common/result/base_cv_result.py

@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from pathlib import Path
+
 from .base_result import BaseResult
 from .mixin import ImgMixin
 
@@ -28,3 +30,12 @@ class BaseCVResult(BaseResult, ImgMixin):
         """
         super().__init__(data)
         ImgMixin.__init__(self, "pillow")
+
+    def _get_input_fn(self):
+        fn = super()._get_input_fn()
+        if (page_idx := self.get("page_index", None)) is not None:
+            fp = Path(fn)
+            stem, suffix = fp.stem, fp.suffix
+            return f"{stem}_{page_idx}{suffix}"
+        else:
+            return fn

+ 17 - 12
paddlex/inference/models/common/static_infer.py

@@ -495,18 +495,23 @@ class PaddleInfer(StaticInfer):
             if self._option.trt_dynamic_shapes is None:
                 raise RuntimeError("No dynamic shape information provided")
             trt_save_path = cache_dir / "trt" / self.model_file_prefix
-            _convert_trt(
-                self._option.trt_cfg_setting,
-                model_file,
-                params_file,
-                trt_save_path,
-                self._option.device_id,
-                self._option.trt_dynamic_shapes,
-                self._option.trt_dynamic_shape_input_data,
-            )
-            model_file = trt_save_path.with_suffix(".json")
-            params_file = trt_save_path.with_suffix(".pdiparams")
-            config = paddle.inference.Config(str(model_file), str(params_file))
+            trt_model_file = trt_save_path.with_suffix(".json")
+            trt_params_file = trt_save_path.with_suffix(".pdiparams")
+            if not trt_model_file.exists() or not trt_params_file.exists():
+                _convert_trt(
+                    self._option.trt_cfg_setting,
+                    model_file,
+                    params_file,
+                    trt_save_path,
+                    self._option.device_id,
+                    self._option.trt_dynamic_shapes,
+                    self._option.trt_dynamic_shape_input_data,
+                )
+            else:
+                logging.debug(
+                    f"Use TRT cache files(`{trt_model_file}` and `{trt_params_file}`)."
+                )
+            config = paddle.inference.Config(str(trt_model_file), str(trt_params_file))
         else:
             config = paddle.inference.Config(str(model_file), str(params_file))
             config.set_optim_cache_dir(str(cache_dir / "optim_cache"))

+ 0 - 16
paddlex/modules/base/utils/cinn_setting.py

@@ -22,9 +22,6 @@ CINN_WHITELIST = [
     "PP-HGNet_small",
     "PP-LCNet_x1_0",
     "ResNet50",
-    "SwinTransformer_base_patch4_window7_224",
-    "Mask-RT-DETR-L",
-    "RT-DETR-L",
     "Deeplabv3-R50",
     "Deeplabv3_Plus-R50",
     "PP-LiteSeg-T",
@@ -63,19 +60,6 @@ CINN_WHITELIST = [
     "ResNet101_vd",
     "ResNet152_vd",
     "ResNet200_vd",
-    "SwinTransformer_tiny_patch4_window7_224",
-    "SwinTransformer_small_patch4_window7_224",
-    "SwinTransformer_base_patch4_window12_384",
-    "SwinTransformer_large_patch4_window7_224",
-    "SwinTransformer_large_patch4_window12_384",
-    "Mask-RT-DETR-H",
-    "Mask-RT-DETR-X",
-    "Mask-RT-DETR-M",
-    "Mask-RT-DETR-S",
-    "RT-DETR-H",
-    "RT-DETR-X",
-    "RT-DETR-R18",
-    "RT-DETR-R50",
     "Deeplabv3-R101",
     "Deeplabv3_Plus-R101",
     "PP-LiteSeg-B",

+ 1 - 1
setup.py

@@ -51,7 +51,7 @@ DEP_SPECS = {
     "opencv-contrib-python": "== 4.10.0.84",
     "openpyxl": "",
     "packaging": "",
-    "pandas": "",
+    "pandas": "<= 1.5.3",
     "pillow": "",
     "premailer": "",
     "prettytable": "",