szha closed pull request #9652: Fallout from simplifying/fixing im2rec.py 
commandline boolean options.
URL: https://github.com/apache/incubator-mxnet/pull/9652
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/faq/finetune.md b/docs/faq/finetune.md
index 2c6c7e3402..8650f3ef59 100644
--- a/docs/faq/finetune.md
+++ b/docs/faq/finetune.md
@@ -61,8 +61,8 @@ for i in 256_ObjectCategories/*; do
     done
 done
 
-python ~/mxnet/tools/im2rec.py --list True --recursive True 
caltech-256-60-train caltech_256_train_60/
-python ~/mxnet/tools/im2rec.py --list True --recursive True caltech-256-60-val 
256_ObjectCategories/
+python ~/mxnet/tools/im2rec.py --list --recursive caltech-256-60-train 
caltech_256_train_60/
+python ~/mxnet/tools/im2rec.py --list --recursive caltech-256-60-val 
256_ObjectCategories/
 python ~/mxnet/tools/im2rec.py --resize 256 --quality 90 --num-thread 16 
caltech-256-60-val 256_ObjectCategories/
 python ~/mxnet/tools/im2rec.py --resize 256 --quality 90 --num-thread 16 
caltech-256-60-train caltech_256_train_60/
 ```
diff --git a/docs/tutorials/basic/data.md b/docs/tutorials/basic/data.md
index 66479d5acc..1a88242592 100644
--- a/docs/tutorials/basic/data.md
+++ b/docs/tutorials/basic/data.md
@@ -392,7 +392,7 @@ Now let's convert them into record io format using the 
`im2rec.py` utility scrip
 First, we need to make a list that contains all the image files and their 
categories:
 
 ```python
-os.system('python %s/tools/im2rec.py --list=1 --recursive=1 --shuffle=1 
--test-ratio=0.2 data/caltech 
data/101_ObjectCategories'%os.environ['MXNET_HOME'])
+os.system('python %s/tools/im2rec.py --list --recursive --test-ratio=0.2 
data/caltech data/101_ObjectCategories'%os.environ['MXNET_HOME'])
 ```
 
 The resulting list file (./data/caltech_train.lst) is in the format 
`index\t(one or more label)\tpath`. In this case, there is only one label for 
each image but you can modify the list to add in more for multi-label training.
@@ -401,7 +401,7 @@ Then we can use this list to create our record io file:
 
 
 ```python
-os.system("python %s/tools/im2rec.py --num-thread=4 --pass-through=1 
data/caltech data/101_ObjectCategories"%os.environ['MXNET_HOME'])
+os.system("python %s/tools/im2rec.py --num-thread=4 --pass-through 
data/caltech data/101_ObjectCategories"%os.environ['MXNET_HOME'])
 ```
 
 The record io files are now saved at here (./data)
diff --git a/docs/tutorials/basic/image_io.md b/docs/tutorials/basic/image_io.md
index e6434257b7..8d60ee8fc0 100644
--- a/docs/tutorials/basic/image_io.md
+++ b/docs/tutorials/basic/image_io.md
@@ -55,7 +55,7 @@ contains all the image files and their categories:
 
 ```python
 assert(MXNET_HOME != '/scratch/mxnet'), "Please update your MXNet location"
-os.system('python %s/tools/im2rec.py --list=1 --recursive=1 --shuffle=1 
--test-ratio=0.2 data/caltech data/101_ObjectCategories'%MXNET_HOME)
+os.system('python %s/tools/im2rec.py --list --recursive --test-ratio=0.2 
data/caltech data/101_ObjectCategories'%MXNET_HOME)
 ```
 
 The resulting [list file](./data/caltech_train.lst) is in the format
@@ -66,7 +66,7 @@ Then we can use this list to create our record io file:
 
 
 ```python
-os.system("python %s/tools/im2rec.py --num-thread=4 --pass-through=1 
data/caltech data/101_ObjectCategories"%MXNET_HOME)
+os.system("python %s/tools/im2rec.py --num-thread=4 --pass-through 
data/caltech data/101_ObjectCategories"%MXNET_HOME)
 ```
 
 The record io files are now saved in the "data" directory.
diff --git a/docs/tutorials/vision/large_scale_classification.md 
b/docs/tutorials/vision/large_scale_classification.md
index 17701e6047..089f55b871 100644
--- a/docs/tutorials/vision/large_scale_classification.md
+++ b/docs/tutorials/vision/large_scale_classification.md
@@ -105,7 +105,7 @@ To create the recordIO files, we first create a list of 
images we want in the re
 
 ```
 mkdir -p train_meta
-python ${MXNET}/tools/im2rec.py --list True --chunks 8 --recursive True \
+python ${MXNET}/tools/im2rec.py --list --chunks 8 --recursive \
 train_meta/${NAME} ${ROOT}
 ```
 
@@ -127,7 +127,7 @@ We do similar preprocessing for the validation set.
 
 ```
 mkdir -p val_meta
-python ${MXNET}/tools/im2rec.py --list True --recursive True \
+python ${MXNET}/tools/im2rec.py --list --recursive \
 val_meta/${NAME} ${VAL_ROOT}
 python ${MXNET}/tools/im2rec.py --resize 480 --quality 90 \
 --num-thread 16 val_meta/${NAME} ${VAL_ROOT}
diff --git a/example/image-classification/README.md 
b/example/image-classification/README.md
index 296760590f..d0ffa3f72a 100644
--- a/example/image-classification/README.md
+++ b/example/image-classification/README.md
@@ -68,7 +68,7 @@ We first prepare two `.lst` files, which consist of the 
labels and image paths
 can be used for generating `rec` files.
 
 ```bash
-python tools/im2rec.py --list True --recursive True --train-ratio 0.95 mydata 
img_data
+python tools/im2rec.py --list --recursive --train-ratio 0.95 mydata img_data
 ```
 
 Then we generate the `.rec` files. We resize the images such that the short 
edge
diff --git a/tools/im2rec.py b/tools/im2rec.py
old mode 100644
new mode 100755
index 5547c534d8..ef3e3f3cf7
--- a/tools/im2rec.py
+++ b/tools/im2rec.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -15,7 +17,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# -*- coding: utf-8 -*-
 from __future__ import print_function
 import os
 import sys
@@ -229,7 +230,6 @@ def parse_args():
     cgroup.add_argument('--no-shuffle', dest='shuffle', action='store_false',
                         help='If this is passed, \
         im2rec will not randomize the image order in <prefix>.lst')
-
     rgroup = parser.add_argument_group('Options for creating database')
     rgroup.add_argument('--pass-through', action='store_true',
                         help='whether to skip transformation and save image as 
is')


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to