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

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


The following commit(s) were added to refs/heads/master by this push:
     new c7d18e0  fix py3 compatibilities (#7305)
c7d18e0 is described below

commit c7d18e077d149784feaf08ad3d41d8302eb8e929
Author: MinWoo Byeon <[email protected]>
AuthorDate: Fri Aug 4 05:05:42 2017 +0900

    fix py3 compatibilities (#7305)
    
    * fix py3 compatibilities
    
    * fix py3 compatibilities
---
 tools/im2rec.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/tools/im2rec.py b/tools/im2rec.py
index a05bfb0..30ee3ec 100644
--- a/tools/im2rec.py
+++ b/tools/im2rec.py
@@ -11,9 +11,7 @@ import argparse
 import cv2
 import time
 import traceback
-
-if sys.version_info[0] == 3:
-    xrange = range
+from builtins import range
 
 try:
     import multiprocessing
@@ -61,8 +59,8 @@ def make_list(args):
         random.seed(100)
         random.shuffle(image_list)
     N = len(image_list)
-    chunk_size = (N + args.chunks - 1) / args.chunks
-    for i in xrange(args.chunks):
+    chunk_size = (N + args.chunks - 1) // args.chunks
+    for i in range(args.chunks):
         chunk = image_list[i * chunk_size:(i + 1) * chunk_size]
         if args.chunks > 1:
             str_chunk = '_%d' % i
@@ -130,16 +128,16 @@ def image_encode(args, i, item, q_out):
         return
     if args.center_crop:
         if img.shape[0] > img.shape[1]:
-            margin = (img.shape[0] - img.shape[1]) / 2;
+            margin = (img.shape[0] - img.shape[1]) // 2;
             img = img[margin:margin + img.shape[1], :]
         else:
-            margin = (img.shape[1] - img.shape[0]) / 2;
+            margin = (img.shape[1] - img.shape[0]) // 2;
             img = img[:, margin:margin + img.shape[0]]
     if args.resize:
         if img.shape[0] > img.shape[1]:
-            newsize = (args.resize, img.shape[0] * args.resize / img.shape[1])
+            newsize = (args.resize, img.shape[0] * args.resize // img.shape[1])
         else:
-            newsize = (img.shape[1] * args.resize / img.shape[0], args.resize)
+            newsize = (img.shape[1] * args.resize // img.shape[0], args.resize)
         img = cv2.resize(img, newsize)
 
     try:

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to