forked from Vladkryvoruchko/PSPNet-Keras-tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Vladkryvoruchko#74 from Vladkryvoruchko/feat/tests
Feat/tests
- Loading branch information
Showing
11 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
make test: | ||
pytest -vv -s --disable-warnings --tb short -n 4 tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,4 +80,4 @@ List of arguments: | |
|
||
|
||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
numpy | ||
scipy==1.3 | ||
tensorflow==1.0.0 | ||
#tensorflow-gpu | ||
tensorflow-gpu | ||
keras==2.1.1 | ||
imageio==2.5.0 | ||
opencv-python=4.1.1 | ||
opencv-python=4.1.1 | ||
pytest==5.1.3 | ||
pytest-xdist==1.29.0 |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import argparse | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def cli_args_ade(): | ||
args = argparse.Namespace(flip=False, glob_path=None, id='0', input_path='tests/ade20k_test.jpg', input_size=500, model='pspnet50_ade20k', output_path='tests/ade20k_test.jpg', sliding=False, weights=None, multi_scale=False) | ||
return args | ||
|
||
@pytest.fixture | ||
def cli_args_cityscapes(): | ||
args = argparse.Namespace(flip=False, glob_path=None, id='0', input_path='tests/cityscapes_test.jpg', input_size=500, model='pspnet101_cityscapes', output_path='tests/cityscapes_test.jpg', sliding=False, weights=None, multi_scale=False) | ||
return args | ||
|
||
@pytest.fixture | ||
def cli_args_voc(): | ||
args = argparse.Namespace(flip=False, glob_path=None, id='0', input_path='tests/pascal_voc_test.jpg', input_size=500, model='pspnet101_voc2012', output_path='tests/pascal_voc_test.jpg', sliding=False, weights=None, multi_scale=False) | ||
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import pytest | ||
|
||
import numpy as np | ||
from imageio import imread | ||
|
||
|
||
def compare_2_images(validator_path, output_path): | ||
val_abs_path = os.path.join(os.path.dirname(__file__), validator_path) | ||
out_abs_path = os.path.join(os.path.dirname(__file__), output_path) | ||
val_img = imread(val_abs_path, pilmode='RGB') | ||
out_img = imread(out_abs_path, pilmode='RGB') | ||
assert np.all(np.equal(val_img, out_img)) | ||
|
||
def clean_test_results(output_file_no_ext): | ||
os.remove("tests/" + output_file_no_ext + "_probs.jpg") | ||
os.remove("tests/" + output_file_no_ext + "_seg.jpg") | ||
os.remove("tests/" + output_file_no_ext + "_seg_blended.jpg") | ||
os.remove("tests/" + output_file_no_ext + "_seg_read.jpg") | ||
|
||
def test_main_flip_ade20k(cli_args_ade): | ||
from pspnet import main | ||
main(cli_args_ade) | ||
compare_2_images("ade20k_test_probs.jpg", "validators/ade20k_test_probs.jpg") | ||
compare_2_images("ade20k_test_seg.jpg", "validators/ade20k_test_seg.jpg") | ||
compare_2_images("ade20k_test_seg_read.jpg", "validators/ade20k_test_seg_read.jpg") | ||
clean_test_results("ade20k_test") | ||
|
||
|
||
@pytest.mark.skip | ||
def test_main_flip_cityscapes(cli_args_cityscapes): | ||
""" | ||
TODO: Add images | ||
:param cli_args_cityscapes: | ||
:return: | ||
""" | ||
from pspnet import main | ||
main(cli_args_cityscapes) | ||
|
||
compare_2_images("cityscapes_test_probs.jpg", "validators/cityscapes_test_probs.jpg") | ||
compare_2_images("cityscapes_test_seg.jpg", "validators/cityscapes_test_seg.jpg") | ||
compare_2_images("cityscapes_test_seg_read.jpg", "validators/cityscapes_test_seg_read.jpg") | ||
clean_test_results("cityscapes_test") | ||
|
||
|
||
|
||
@pytest.mark.skip | ||
def test_main_flip_voc(cli_args_voc): | ||
""" | ||
TODO: Add images | ||
:param cli_args_voc: | ||
:return: | ||
""" | ||
from pspnet import main | ||
main(cli_args_voc) | ||
|
||
compare_2_images("pascal_voc_test_probs.jpg", "validators/pascal_voc_test_probs.jpg") | ||
compare_2_images("pascal_voc_test_seg.jpg", "validators/pascal_voc_test_seg.jpg") | ||
compare_2_images("pascal_voc_test_seg_read.jpg", "validators/pascal_voc_test_seg_read.jpg") | ||
clean_test_results("pascal_voc_test") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.