Bobholamovic 1 year ago
parent
commit
f6859c46a4

+ 1 - 1
requirements.txt

@@ -15,7 +15,7 @@ opencv-contrib-python <= 4.3.0.28
 openpyxl
 # paddlepaddle >= 2.5.0
 # paddlepaddle-gpu >= 2.5.0
-paddleslim
+paddleslim @ git+https://github.com/PaddlePaddle/PaddleSlim.git@release/2.5
 pandas
 protobuf >= 3.1.0
 pycocotools

+ 4 - 2
tests/check_coverage.sh

@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
-coverage run --source paddlers --omit=../paddlers/models/* -m unittest discover -v
+bash download_test_data.sh
+
+coverage run --source paddlers --omit='*/paddlers/models/*' -m unittest discover -v
 coverage report
-coverage html -d coverage_html
+coverage html -d coverage_html

+ 7 - 6
tests/deploy/test_predictor.py

@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import os.path as osp
+import sys
 import tempfile
 import unittest.mock as mock
 
@@ -54,7 +55,7 @@ class TestPredictor(CommonTest):
                     optimizer.state_dict.return_value = {'foo': 'bar'}
                     trainer.optimizer = optimizer
                     trainer.save_model(dynamic_model_dir)
-                    export_cmd = f"python export_model.py --model_dir {dynamic_model_dir} --save_dir {static_model_dir} "
+                    export_cmd = f"{sys.executable} export_model.py --model_dir {dynamic_model_dir} --save_dir {static_model_dir} "
                     if trainer_name in self.TRAINER_NAME_TO_EXPORT_OPTS:
                         export_cmd += self.TRAINER_NAME_TO_EXPORT_OPTS[
                             trainer_name]
@@ -126,7 +127,7 @@ class TestCDPredictor(TestPredictor):
         t2_path = "data/ssmt/optical_t2.bmp"
         single_input = (t1_path, t2_path)
         num_inputs = 2
-        transforms = [pdrs.transforms.Normalize()]
+        transforms = pdrs.transforms.Compose([pdrs.transforms.Normalize()])
 
         # Expected failure
         with self.assertRaises(ValueError):
@@ -191,7 +192,7 @@ class TestClasPredictor(TestPredictor):
     def check_predictor(self, predictor, trainer):
         single_input = "data/ssst/optical.bmp"
         num_inputs = 2
-        transforms = [pdrs.transforms.Normalize()]
+        transforms = pdrs.transforms.Compose([pdrs.transforms.Normalize()])
         labels = list(range(2))
         trainer.labels = labels
         predictor._model.labels = labels
@@ -257,7 +258,7 @@ class TestDetPredictor(TestPredictor):
         # given that the network is (partially?) randomly initialized.
         single_input = "data/ssst/optical.bmp"
         num_inputs = 2
-        transforms = [pdrs.transforms.Normalize()]
+        transforms = pdrs.transforms.Compose([pdrs.transforms.Normalize()])
         labels = list(range(80))
         trainer.labels = labels
         predictor._model.labels = labels
@@ -319,7 +320,7 @@ class TestResPredictor(TestPredictor):
         # because the output is of uint8 type.
         single_input = "data/ssst/optical.bmp"
         num_inputs = 2
-        transforms = [pdrs.transforms.Normalize()]
+        transforms = pdrs.transforms.Compose([pdrs.transforms.Normalize()])
 
         # Single input (file path)
         input_ = single_input
@@ -371,7 +372,7 @@ class TestSegPredictor(TestPredictor):
     def check_predictor(self, predictor, trainer):
         single_input = "data/ssst/optical.bmp"
         num_inputs = 2
-        transforms = [pdrs.transforms.Normalize()]
+        transforms = pdrs.transforms.Compose([pdrs.transforms.Normalize()])
 
         # Single input (file path)
         input_ = single_input

+ 1 - 1
tests/run_fast_tests.sh

@@ -1,4 +1,4 @@
 #!/usr/bin/env bash
 
 bash download_test_data.sh
-python -m unittest -v fast_tests
+python -m unittest -v fast_tests

+ 1 - 1
tests/run_tipc_lite.sh

@@ -10,4 +10,4 @@ for config in $(ls test_tipc/configs/*/*/train_infer_python.txt); do
     if grep -q 'failed' "test_tipc/output/${task}/${model}/lite_train_lite_infer/results_python.log"; then
         exit 1
     fi
-done
+done

+ 7 - 7
tests/tools/run_coco_tools.py

@@ -12,26 +12,26 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import tempfile
+import sys
 
 from testing_utils import run_script
 
 if __name__ == '__main__':
     run_script(
-        f"python coco_tools/json_info_show.py --json_path ../tests/data/instances_val2017.json",
+        f"{sys.executable} coco_tools/json_info_show.py --json_path ../tests/data/instances_val2017.json",
         wd="../tools")
     run_script(
-        f"python coco_tools/json_image2json.py --image_dir ../tests/data/img_test --json_train_path ../tests/data/instances_train2017.json --result_path ../tests/data/test.json",
+        f"{sys.executable} coco_tools/json_image2json.py --image_dir ../tests/data/img_test --json_train_path ../tests/data/instances_train2017.json --result_path ../tests/data/test.json",
         wd="../tools")
     run_script(
-        f"python coco_tools/json_merge.py --json1_path ../tests/data/instances_train2017.json --json2_path ../tests/data/instances_train2017.json --save_path ../tests/data/instances_trainval2017.json",
+        f"{sys.executable} coco_tools/json_merge.py --json1_path ../tests/data/instances_train2017.json --json2_path ../tests/data/instances_train2017.json --save_path ../tests/data/instances_trainval2017.json",
         wd="../tools")
     run_script(
-        f"python coco_tools/json_split.py --json_all_path ../tests/data/instances_train2017.json --json_train_path ../tests/data/instances_train2017_1.json --json_val_path ../tests/data/instances_train2017_2.json",
+        f"{sys.executable} coco_tools/json_split.py --json_all_path ../tests/data/instances_train2017.json --json_train_path ../tests/data/instances_train2017_1.json --json_val_path ../tests/data/instances_train2017_2.json",
         wd="../tools")
     run_script(
-        f"python coco_tools/json_image_sta.py --json_path ../tests/data/instances_train2017.json --csv_path ../tests/data/instances_val2017_images.csv --pic_shape_path ../tests/data/images_shape.png --pic_shape_rate_path ../tests/data/shape_rate.png",
+        f"{sys.executable} coco_tools/json_image_sta.py --json_path ../tests/data/instances_train2017.json --csv_path ../tests/data/instances_val2017_images.csv --pic_shape_path ../tests/data/images_shape.png --pic_shape_rate_path ../tests/data/shape_rate.png",
         wd="../tools")
     run_script(
-        f"python coco_tools/json_anno_sta.py --json_path ../tests/data/instances_train2017.json --csv_path ../tests/data/instances_val2017_annos.csv --pic_shape_path ../tests/data/images_shape.png --pic_shape_rate_path ../tests/data/shape_rate.png --pic_pos_path ../tests/data/pos.png --pic_pos_end_path ../tests/data/pos_end.png --pic_cat_path ../tests/data/cat.png --pic_obj_num_path ../tests/data/obj_num.png",
+        f"{sys.executable} coco_tools/json_anno_sta.py --json_path ../tests/data/instances_train2017.json --csv_path ../tests/data/instances_val2017_annos.csv --pic_shape_path ../tests/data/images_shape.png --pic_shape_rate_path ../tests/data/shape_rate.png --pic_pos_path ../tests/data/pos.png --pic_pos_end_path ../tests/data/pos_end.png --pic_cat_path ../tests/data/cat.png --pic_obj_num_path ../tests/data/obj_num.png",
         wd="../tools")

+ 2 - 1
tests/tools/run_extract_ms_patches.py

@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import tempfile
 
 from testing_utils import run_script
@@ -19,5 +20,5 @@ from testing_utils import run_script
 if __name__ == '__main__':
     with tempfile.TemporaryDirectory() as td:
         run_script(
-            f"python extract_ms_patches.py --image_paths ../tests/data/ssst/multispectral.tif --mask_path ../tests/data/ssst/multiclass_gt2.png --min_patch_size 32 --save_dir {td}",
+            f"{sys.executable} extract_ms_patches.py --image_paths ../tests/data/ssst/multispectral.tif --mask_path ../tests/data/ssst/multiclass_gt2.png --min_patch_size 32 --save_dir {td}",
             wd="../tools")

+ 3 - 1
tests/tools/run_generate_file_lists.py

@@ -12,9 +12,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
+
 from testing_utils import run_script
 
 if __name__ == '__main__':
     run_script(
-        f"python generate_file_lists.py --data_dir ../tests/data/levircd_crop --save_dir ../tests/data/levircd_crop --subsets train val test --subdirs A B label --glob_pattern '*' --store_abs_path",
+        f"{sys.executable} generate_file_lists.py --data_dir ../tests/data/levircd_crop --save_dir ../tests/data/levircd_crop --subsets train val test --subdirs A B label --glob_pattern '*' --store_abs_path",
         wd="../tools")

+ 2 - 1
tests/tools/run_match.py

@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import tempfile
 
 from testing_utils import run_script
@@ -19,5 +20,5 @@ from testing_utils import run_script
 if __name__ == '__main__':
     with tempfile.TemporaryDirectory() as td:
         run_script(
-            f"python match.py --image1_path ../tests/data/ssmt/multispectral_t1.tif --image2_path ../tests/data/ssmt/multispectral_t1.tif --save_path {td}/out.tiff",
+            f"{sys.executable} match.py --image1_path ../tests/data/ssmt/multispectral_t1.tif --image2_path ../tests/data/ssmt/multispectral_t1.tif --save_path {td}/out.tiff",
             wd="../tools")

+ 3 - 1
tests/tools/run_oif.py

@@ -12,9 +12,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
+
 from testing_utils import run_script
 
 if __name__ == '__main__':
     run_script(
-        f"python oif.py --image_path ../tests/data/ssst/multispectral.tif",
+        f"{sys.executable} oif.py --image_path ../tests/data/ssst/multispectral.tif",
         wd="../tools")

+ 2 - 1
tests/tools/run_pca.py

@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import tempfile
 
 from testing_utils import run_script
@@ -19,5 +20,5 @@ from testing_utils import run_script
 if __name__ == '__main__':
     with tempfile.TemporaryDirectory() as td:
         run_script(
-            f"python pca.py --image_path ../tests/data/ssst/multispectral.tif --save_dir {td} --dim 5",
+            f"{sys.executable} pca.py --image_path ../tests/data/ssst/multispectral.tif --save_dir {td} --dim 5",
             wd="../tools")

+ 2 - 1
tests/tools/run_split.py

@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import tempfile
 
 from testing_utils import CpuCommonTest, run_script
@@ -19,5 +20,5 @@ from testing_utils import CpuCommonTest, run_script
 if __name__ == '__main__':
     with tempfile.TemporaryDirectory() as td:
         run_script(
-            f"python split.py --image_path ../tests/data/ssst/multispectral.tif --mask_path ../tests/data/ssst/multiclass_gt2.png --block_size 128 --save_dir {td}",
+            f"{sys.executable} split.py --image_path ../tests/data/ssst/multispectral.tif --mask_path ../tests/data/ssst/multiclass_gt2.png --block_size 128 --save_dir {td}",
             wd="../tools")