{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import os, glob, math, cv2, time\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport pylab as plb\nfrom joblib import Parallel, delayed\n\nimg_size = 50\nsz = (img_size, img_size)\nnprocs = 2\n\ndef process_image(img_file):\n    img = cv2.imread(img_file)\n    img = cv2.resize(img, sz).transpose((2,0,1)).astype('float32') / 255.0\n    return img\n\n#Training\nstart = time.time()\n\nX_train = []\nY_train = []\n\nfor j in range(10):\n    print('Load folder c{}'.format(j))\n    path = os.path.join('../input/train', 'c' + str(j), '*.jpg')\n    files = glob.glob(path)\n    X_train.extend(Parallel(n_jobs=nprocs)(delayed(process_image)(im_file) for im_file in files))\n    Y_train.extend([j]*len(files))\n    \nend = time.time() - start\nprint(\"Time: %.2f seconds\" % end)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "Y_train[1]"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": ""
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}