You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/01/22 19:13:48 UTC

[incubator-mxnet] branch vision updated (ed9ab63 -> c9034f1)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a change to branch vision
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git.


    omit ed9ab63  lint
     new c9034f1  lint

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (ed9ab63)
            \
             N -- N -- N   refs/heads/vision (c9034f1)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tests/python/unittest/test_gluon_data.py        | 21 -----------------
 tests/python/unittest/test_gluon_data_vision.py | 31 +++++++++++++++++++++----
 2 files changed, 26 insertions(+), 26 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 01/01: lint

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch vision
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit c9034f1942ab3b15d10f228ea375c69b9902a9da
Author: Junyuan Xie <er...@gmail.com>
AuthorDate: Thu Jan 18 17:00:39 2018 -0800

    lint
---
 docker/install/python.sh                        |  4 ++--
 python/mxnet/gluon/data/vision/__init__.py      |  2 ++
 python/mxnet/gluon/data/vision/transforms.py    |  7 +++---
 python/mxnet/ndarray/__init__.py                |  3 ++-
 src/operator/image/image_random-inl.h           |  2 +-
 tests/python/unittest/test_gluon_data.py        | 21 -----------------
 tests/python/unittest/test_gluon_data_vision.py | 31 +++++++++++++++++++++----
 7 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/docker/install/python.sh b/docker/install/python.sh
index 763f27b..ba71246 100755
--- a/docker/install/python.sh
+++ b/docker/install/python.sh
@@ -24,5 +24,5 @@ apt-get update && apt-get install -y python-dev python3-dev
 # the version of the pip shipped with ubuntu may be too lower, install a recent version here
 cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && python2 get-pip.py
 
-pip2 install nose pylint numpy nose-timer requests
-pip3 install nose pylint numpy nose-timer requests
+pip2 install nose pylint numpy nose-timer requests Pillow
+pip3 install nose pylint numpy nose-timer requests Pillow
diff --git a/python/mxnet/gluon/data/vision/__init__.py b/python/mxnet/gluon/data/vision/__init__.py
index 8837984..1c2b7ba 100644
--- a/python/mxnet/gluon/data/vision/__init__.py
+++ b/python/mxnet/gluon/data/vision/__init__.py
@@ -16,6 +16,8 @@
 # under the License.
 
 # coding: utf-8
+# pylint: disable=wildcard-import
+"""Vision utilities."""
 
 from .datasets import *
 
diff --git a/python/mxnet/gluon/data/vision/transforms.py b/python/mxnet/gluon/data/vision/transforms.py
index 38eb690..8a87f37 100644
--- a/python/mxnet/gluon/data/vision/transforms.py
+++ b/python/mxnet/gluon/data/vision/transforms.py
@@ -16,12 +16,13 @@
 # under the License.
 
 # coding: utf-8
+# pylint: disable= arguments-differ
+"Image transforms."
 
-from .. import dataset
 from ...block import Block, HybridBlock
 from ...nn import Sequential, HybridSequential
-from .... import ndarray, initializer, image
-from ....base import _Null, numeric_types
+from .... import image
+from ....base import numeric_types
 
 
 class Compose(Sequential):
diff --git a/python/mxnet/ndarray/__init__.py b/python/mxnet/ndarray/__init__.py
index 86a3a20..fc4a55d 100644
--- a/python/mxnet/ndarray/__init__.py
+++ b/python/mxnet/ndarray/__init__.py
@@ -31,4 +31,5 @@ from .utils import load, save, zeros, empty, array
 from .sparse import _ndarray_cls
 from .ndarray import _GRAD_REQ_MAP
 
-__all__ = op.__all__ + ndarray.__all__ + utils.__all__ + ['contrib', 'linalg', 'random', 'sparse', 'image']
+__all__ = op.__all__ + ndarray.__all__ + utils.__all__ + \
+          ['contrib', 'linalg', 'random', 'sparse', 'image']
diff --git a/src/operator/image/image_random-inl.h b/src/operator/image/image_random-inl.h
index ec96149..47beca1 100644
--- a/src/operator/image/image_random-inl.h
+++ b/src/operator/image/image_random-inl.h
@@ -175,7 +175,7 @@ template<typename DType, int axis>
 void FlipImpl(const TShape &shape, DType *src, DType *dst) {
   int head = 1, mid = shape[axis], tail = 1;
   for (int i = 0; i < axis; ++i) head *= shape[i];
-  for (int i = axis+1; i < shape.ndim(); ++i) tail *= shape[i];
+  for (uint32_t i = axis+1; i < shape.ndim(); ++i) tail *= shape[i];
 
   for (int i = 0; i < head; ++i) {
     for (int j = 0; j < (mid >> 1); ++j) {
diff --git a/tests/python/unittest/test_gluon_data.py b/tests/python/unittest/test_gluon_data.py
index c72ef7c..63c5d28 100644
--- a/tests/python/unittest/test_gluon_data.py
+++ b/tests/python/unittest/test_gluon_data.py
@@ -107,27 +107,6 @@ def test_multi_worker():
         assert (batch.asnumpy() == i).all()
 
 
-def test_transformer():
-    from mxnet.gluon.data.vision import transforms
-
-    transform = transforms.Compose([
-		transforms.Resize(300),
-		transforms.CenterCrop(256),
-		transforms.RandomResizedCrop(224),
-		transforms.RandomHorizontalFlip(),
-		transforms.RandomColorJitter(0.1, 0.1, 0.1, 0.1),
-		transforms.RandomBrightness(0.1),
-		transforms.RandomContrast(0.1),
-		transforms.RandomSaturation(0.1),
-		transforms.RandomHue(0.1),
-		transforms.RandomLighting(0.1),
-		transforms.ToTensor(),
-		transforms.Normalize([0, 0, 0], [1, 1, 1])])
-
-    transform(mx.nd.ones((245, 480, 3), dtype='uint8')).wait_to_read()
-
-
 if __name__ == '__main__':
-    test_transformer()
     import nose
     nose.runmodule()
diff --git a/tests/python/unittest/test_gluon_data_vision.py b/tests/python/unittest/test_gluon_data_vision.py
index 5e9ff87..52e9d4a 100644
--- a/tests/python/unittest/test_gluon_data_vision.py
+++ b/tests/python/unittest/test_gluon_data_vision.py
@@ -18,7 +18,6 @@ from __future__ import print_function
 import mxnet as mx
 import mxnet.ndarray as nd
 import numpy as np
-from PIL import Image
 from mxnet import gluon
 from mxnet.gluon.data.vision import transforms
 from mxnet.test_utils import assert_almost_equal
@@ -42,15 +41,37 @@ def test_normalize():
 
 def test_flip_left_right():
     data_in = np.random.uniform(0, 255, (300, 300, 3)).astype(dtype=np.uint8)
-    pil_img = Image.fromarray(data_in).transpose(Image.FLIP_LEFT_RIGHT)
+    flip_in = data_in[:, ::-1, :]
     data_trans = nd.image.flip_left_right(nd.array(data_in, dtype='uint8'))
-    assert_almost_equal(np.array(pil_img), data_trans.asnumpy())
+    assert_almost_equal(flip_in, data_trans.asnumpy())
 
 def test_flip_top_bottom():
     data_in = np.random.uniform(0, 255, (300, 300, 3)).astype(dtype=np.uint8)
-    pil_img = Image.fromarray(data_in).transpose(Image.FLIP_TOP_BOTTOM)
+    flip_in = data_in[::-1, :, :]
     data_trans = nd.image.flip_top_bottom(nd.array(data_in, dtype='uint8'))
-    assert_almost_equal(np.array(pil_img), data_trans.asnumpy())
+    assert_almost_equal(flip_in, data_trans.asnumpy())
+
+
+def test_transformer():
+    from mxnet.gluon.data.vision import transforms
+
+    transform = transforms.Compose([
+		transforms.Resize(300),
+		transforms.CenterCrop(256),
+		transforms.RandomResizedCrop(224),
+		transforms.RandomFlipLeftRight(),
+		transforms.RandomColorJitter(0.1, 0.1, 0.1, 0.1),
+		transforms.RandomBrightness(0.1),
+		transforms.RandomContrast(0.1),
+		transforms.RandomSaturation(0.1),
+		transforms.RandomHue(0.1),
+		transforms.RandomLighting(0.1),
+		transforms.ToTensor(),
+		transforms.Normalize([0, 0, 0], [1, 1, 1])])
+
+    transform(mx.nd.ones((245, 480, 3), dtype='uint8')).wait_to_read()
+
+
 
 if __name__ == '__main__':
     import nose

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.