-
Notifications
You must be signed in to change notification settings - Fork 949
Conversation
This program converts input images into a format suitable for use with deeplearnjs. Before running this program: - Create a directory structure as follows: <topDir> preprocess.py <yourProjectDir> <yourImageDir> # default to 'images' <yourImageDir2> - Put all images under <yourImageDir> (or if using your own directory name, i.e., <yourImageDir>) specify it using the --path parameter from command line). - You may have <yourImageDir2>, <yourImageDir3>, etc., to facilitate experimentations. - Each image must be prefixed with its class label, followed by '_'. For example, cat_image00005.jpg To run: 1. $ cd <yourProjectDir> 2a. $ python ../preprocess.py; or 2b. $ python ../preprocess.py --outimgs newimgs #if prefering non-default parameters Results: find in the current directoty an image file 'images.png' (extension '.png' added automatically), and a labels file 'labels' (or per command line options) Note: - Make sure that the model-builder-datasets-configuration's data.labels.shape matches the number of classes found in data - Make sure that the NN model's output layer matches the number of classes To-do: - This code is not suitable for processing large number of images. - Tested with python v2.7. Saw some problem with V3.5
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
Wow. This is fantastic. Thank you so much for spending the time on this. A couple high level suggestions:
Some minor nits inline! Thanks again!! Review status: 0 of 1 files reviewed at latest revision, 10 unresolved discussions, some commit checks failed. scripts/preprocess.py, line 2 at r1 (raw file):
Some laywercat will find this and yell at us for this :/ Feel free to add yourself a little lower at the top of the file, though (not in the license). scripts/preprocess.py, line 16 at r1 (raw file):
Can you actually change this to say the model builder demo? We're going to be thinking hard about the data API at the library level at some point in the near future, and the model builder format might not be here to stay. scripts/preprocess.py, line 69 at r1 (raw file):
remove this line scripts/preprocess.py, line 71 at r1 (raw file):
use 2 space indentation throughout this file (we dont have a py linter set up yet but this is what it would say) scripts/preprocess.py, line 95 at r1 (raw file):
remove trailing spaces on this line scripts/preprocess.py, line 108 at r1 (raw file):
remove comment scripts/preprocess.py, line 116 at r1 (raw file):
remove this line scripts/preprocess.py, line 127 at r1 (raw file):
remove trailing whitespaces scripts/preprocess.py, line 141 at r1 (raw file):
remove trailing whitespaces scripts/preprocess.py, line 197 at r1 (raw file):
remove trailing spaces Comments from Reviewable |
Done as suggested. Do I need to submit a new pull request for the changes?
…On 9/20/2017 6:52 PM, Nikhil Thorat wrote:
Wow. This is fantastic. Thank you so much for spending the time on this.
A couple high level suggestions:
* Can we make it so the preprocess.py doesn't have to be in the
directory? It'd be nice to run it like ./scripts/preprocess
/abs/path/to/image/dir
* Can you rename it to something more descriptive, how about
something like process_images_for_training.py or something like
that? I like mile long descriptive names :)
Some minor nits inline! Thanks again!!
------------------------------------------------------------------------
Review status: 0 of 1 files reviewed at latest revision, 10 unresolved
discussions, some commit checks failed.
------------------------------------------------------------------------
/scripts/preprocess.py, line 2 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWSSNDHRs_E5MJK563:-KuWSSNDHRs_E5MJK564:b-k2nm0>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L2>):/
# Copyright 2017 Smesh LLC. All Rights Reserved.
# http://smesh.net/labs
Some laywercat will find this and yell at us for this :/
Feel free to add yourself a little lower at the top of the file,
though (not in the license).
------------------------------------------------------------------------
/scripts/preprocess.py, line 16 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTNHJ_prt96WB02I9:-KuWTNHJ_prt96WB02IA:b-8bvzfc>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L16>):/
# limitations under the License.
#
======================================================================
# This program converts input images into a format suitable for
use with deeplearnjs.
Can you actually change this to say the model builder demo?
We're going to be thinking hard about the data API at the library
level at some point in the near future, and the model builder format
might not be here to stay.
------------------------------------------------------------------------
/scripts/preprocess.py, line 69 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTaaglUqRDL5cLPyX:-KuWTaaglUqRDL5cLPyY:b-mu0t41>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L69>):/
delimiter= '_'
#---------------------------------------
remove this line
------------------------------------------------------------------------
/scripts/preprocess.py, line 71 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTuDPPu5my43abibe:-KuWTuDPPu5my43abibf:b-bajhtf>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L71>):/
#---------------------------------------
def preprocessImages(FLAGS):
path= FLAGS.path
use 2 space indentation throughout this file (we dont have a py linter
set up yet but this is what it would say)
------------------------------------------------------------------------
/scripts/preprocess.py, line 95 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTdwVP3k7YJfo6dQk:-KuWTdwVP3k7YJfo6dQl:b-clf9hh>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L95>):/
fileList= np.tile(fileList,FLAGS.replicate)
print('...Dataset has been replicated',FLAGS.replicate,'times')
remove trailing spaces on this line
------------------------------------------------------------------------
/scripts/preprocess.py, line 108 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWUIQObl-eJdzRFB8q:-KuWUIQObl-eJdzRFB8r:b-u9p8mw>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L108>):/
a= imageList
print('...Created', a.shape[0],'images')
#print('min/max pixel values: ', a.min(), '/', a.max())
remove comment
------------------------------------------------------------------------
/scripts/preprocess.py, line 116 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTd5xJFBZ3-tLAjb6:-KuWTd5xJFBZ3-tLAjb7:b-mu0t41>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L116>):/
print('...Saved composed image to:', outImageFile+'.png')
#-------------
remove this line
------------------------------------------------------------------------
/scripts/preprocess.py, line 127 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWUKCzIcF-cXdK5r5y:-KuWUKD-PBV1BdlZbXhx:b-s01ojb>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L127>):/
FLAGS.nClassesIn= len(classesClearText)
labels5= pack(classesClearText.tolist(), labels,FLAGS)
remove trailing whitespaces
------------------------------------------------------------------------
/scripts/preprocess.py, line 141 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWULj65lUL03XtWyHw:-KuWULj65lUL03XtWyHx:b-s01ojb>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L141>):/
length= len(labels)
result= [ np.NaN ]* length* nClasses
remove trailing whitespaces
------------------------------------------------------------------------
/scripts/preprocess.py, line 197 at r1
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-KuWTp3DIVGQS9NfmGaT:-KuWTp3DIVGQS9NfmGaU:b-uyx1gm>
(raw file
<https://github.com/pair-code/deeplearnjs/blob/9b01ed9f1b99baa3ac7288f22f75675768400148/scripts/preprocess.py#L197>):/
print('Error, unrecognized flags:', unparsed)
exit(-1)
remove trailing spaces
------------------------------------------------------------------------
/Comments from Reviewable
<https://reviewable.io:443/reviews/pair-code/deeplearnjs/136#-:-KuWSLUq0640zzoJVBkg:b-x1h5ij>/
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#136 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANDUKw2dKgQOdQK5ceLAnit55W1QdSUeks5skZcigaJpZM4PaX7->.
|
You just need to commit those changes to this branch and I'll see them. I'll then be able to merge! |
The requested changes have been committed. |
Hi Kaihu, It looks like the changes didn't get committed (I still see some lines with just white space), was it committed to another branch? Thanks! :) Review status: 0 of 1 files reviewed at latest revision, 10 unresolved discussions, some commit checks failed. Comments from Reviewable |
My bad! Commited again, please check. |
Reviewed 1 of 2 files at r2, 1 of 1 files at r3. Comments from Reviewable |
* Create preprocess.py This program converts input images into a format suitable for use with deeplearnjs. Before running this program: - Create a directory structure as follows: <topDir> preprocess.py <yourProjectDir> <yourImageDir> # default to 'images' <yourImageDir2> - Put all images under <yourImageDir> (or if using your own directory name, i.e., <yourImageDir>) specify it using the --path parameter from command line). - You may have <yourImageDir2>, <yourImageDir3>, etc., to facilitate experimentations. - Each image must be prefixed with its class label, followed by '_'. For example, cat_image00005.jpg To run: 1. $ cd <yourProjectDir> 2a. $ python ../preprocess.py; or 2b. $ python ../preprocess.py --outimgs newimgs #if prefering non-default parameters Results: find in the current directoty an image file 'images.png' (extension '.png' added automatically), and a labels file 'labels' (or per command line options) Note: - Make sure that the model-builder-datasets-configuration's data.labels.shape matches the number of classes found in data - Make sure that the NN model's output layer matches the number of classes To-do: - This code is not suitable for processing large number of images. - Tested with python v2.7. Saw some problem with V3.5 * Update and rename preprocess.py to process_images_for_training.py * Update process_images_for_training.py * Updated process_images_for_training.py * Merge branch 'master' into patch-1 * Update process_images_for_training.py
This program converts input images into a format suitable for use with deeplearnjs.
Before running this program:
<topDir>
<yourProjectDir>
<yourImageDir>
# default to 'images'<yourImageDir2>
<yourImageDir>
(or if using your own directory name, i.e.,
<yourImageDir>
)specify it using the --path parameter from command line).
<yourImageDir2>
,<yourImageDir3
>, etc., to facilitate experimentations.For example, cat_image00005.jpg
To run:
<yourProjectDir>
$ python ../preprocess.py --outimgs newimgs #if prefering non-default parameters
Results: find in the current directoty an image file 'images.png' (extension '.png' added automatically), and a labels file 'labels' (or per command line options)
Note:
To-do:
This change is