Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobholamovic committed Nov 28, 2023
1 parent 600caff commit f6859c4
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/check_coverage.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions tests/deploy/test_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os.path as osp
import sys
import tempfile
import unittest.mock as mock

Expand Down Expand Up @@ -54,7 +55,7 @@ def _test_predictor_impl(self):
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]
Expand Down Expand Up @@ -126,7 +127,7 @@ def check_predictor(self, predictor, trainer):
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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -257,7 +258,7 @@ def check_predictor(self, predictor, trainer):
# 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
Expand Down Expand Up @@ -319,7 +320,7 @@ def check_predictor(self, predictor, trainer):
# 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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/run_fast_tests.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/run_tipc_lite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions tests/tools/run_coco_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
3 changes: 2 additions & 1 deletion tests/tools/run_extract_ms_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import tempfile

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")
4 changes: 3 additions & 1 deletion tests/tools/run_generate_file_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
3 changes: 2 additions & 1 deletion tests/tools/run_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import tempfile

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")
4 changes: 3 additions & 1 deletion tests/tools/run_oif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
3 changes: 2 additions & 1 deletion tests/tools/run_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import tempfile

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")
3 changes: 2 additions & 1 deletion tests/tools/run_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# 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

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")

0 comments on commit f6859c4

Please sign in to comment.