提交 e3fd0d56 编写于 作者: D dangqingqing

Pass unit test

上级 a6ec6c05
......@@ -29,7 +29,7 @@ if [ $USE_VIRTUALENV_FOR_TEST -ne 0 ]; then
fi
export PYTHONPATH=$SCRIPTPATH/../../python/
$PYTHON -m pip install $SCRIPTPATH/../dist/*.whl requests matplotlib ipython==5.3
$PYTHON -m pip install $SCRIPTPATH/../dist/*.whl requests matplotlib opencv-python ipython==5.3
for fn in "$@"
do
......
......@@ -45,8 +45,13 @@ def load_image(file, is_color=True):
return a color image. Otherwise, it will
load and return a gray image.
"""
flag = cv2.CV_LOAD_IMAGE_COLOR if is_color else \
cv2.CV_LOAD_IMAGE_GRAYSCALE
# cv2.IMAGE_COLOR for OpenCV3
# cv2.CV_LOAD_IMAGE_COLOR for older OpenCV Version
# cv2.IMAGE_GRAYSCALE for OpenCV3
# cv2.CV_LOAD_IMAGE_GRAYSCALE for older OpenCV Version
# Here, use constant 1 and 0
# 1: COLOR, 0: GRAYSCALE
flag = 1 if is_color else 0
im = cv2.imread(file, flag)
return im
......@@ -178,6 +183,11 @@ def simple_transform(im, resize_size, crop_size, is_train, is_color=True):
Simply data argumentation for traing. These operations includes
resizing, croping and flipping.
Example usage:
.. code-block:: python
im = simple_transform(im, 256, 224, True)
:param im: The input image with HWC layout.
:type im: ndarray
:param resize_size: The shorter edge length of the resized image.
......@@ -209,6 +219,11 @@ def load_and_transform(filename,
data argumentation. Please refer the `simple_transform` interface
for the transform operation.
Example usage:
.. code-block:: python
im = load_and_transform('cat.jpg', 256, 224, True)
:param filename: The file name of input image.
:type filename: string
:param resize_size: The shorter edge length of the resized image.
......
add_python_test(test_v2_api test_data_feeder.py test_parameters.py
test_layer.py test_rnn_layer.py test_topology.py test_image)
test_layer.py test_rnn_layer.py test_topology.py test_image.py)
......@@ -26,7 +26,7 @@ class Image(unittest.TestCase):
self.assertEqual(3, im.shape[2])
# flip
im = left_right_flip(im)
im = image.left_right_flip(im)
im2 = np.flip(im, 1)
self.assertEqual(im.all(), im2.all())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册