{"nbformat_minor": 0, "cells": [{"metadata": {"_uuid": "b26e1a34a46eb1df1fdddecc5ee7629f429627c8", "collapsed": false, "_cell_guid": "52424e47-eb7e-489f-8568-aa92e67d8798", "_execution_state": "idle", "trusted": false}, "outputs": [], "source": "import os\nimport glob\n\nimport numpy as np\nimport pandas as pd\n\nfrom PIL import Image\nimport cv2\nimport matplotlib.pyplot as plt\n\nmetadata = pd.read_csv('../input/metadata.csv')\n\n\ndef image_open(dname, car_id, idx):    \n    i = cv2.cvtColor(cv2.imread('../input/{}/{}_{}.jpg'.format(dname, car_id, idx)), cv2.COLOR_BGR2RGB)\n    if dname == 'train':\n        m = Image.open('../input/{}_masks/{}_{}_mask.gif'.format(dname, car_id, idx))\n        m = np.array(m.getdata()).reshape(i.shape[:2])\n        for c in range(3):\n            i[:,:,c] = np.bitwise_and(i[:,:,c], 255*m)\n    return i\n\n    \ndef display(dname, car_id):\n    plt.figure(figsize=(20, 10))\n    plt.imshow(np.hstack([image_open(dname, car_id, str(x).zfill(2)) for x in range(1, 8)]))\n    \n    plt.figure(figsize=(20, 10))\n    plt.imshow(np.hstack([image_open(dname, car_id, str(x).zfill(2)) for x in range(8, 17)]))\n\ntrain_ids = set([os.path.basename(x).split('_')[0] for x in glob.glob('../input/train/*jpg')])\nprint('train ids: ', len(train_ids))\n\nexample = list(train_ids)[0]\ndisplay('train', example)\n", "cell_type": "code", "execution_count": 2}, {"metadata": {"_uuid": "748950cc1c246976315993f03f6371c1e6c31f65", "collapsed": false, "_cell_guid": "d68b3783-fa89-49c6-bff1-9c8bd8bae8e3", "_execution_state": "idle", "trusted": false}, "outputs": [], "source": "\ntest_ids = set([os.path.basename(x).split('_')[0] for x in glob.glob('../input/test/*jpg')])\nprint('test ids: ', len(test_ids))\n\nexample = list(test_ids)[0]\ndisplay('test', example)\n  ", "cell_type": "code", "execution_count": 3}, {"metadata": {"_uuid": "e20e6b7f640e5b942433be27b1e9b184860698d8", "collapsed": false, "_cell_guid": "1bcf556a-956d-4e2b-b500-ddb80120c781", "_execution_state": "idle", "trusted": false}, "outputs": [], "source": "example = list(test_ids)[1]\ndisplay('test', example)", "cell_type": "code", "execution_count": 4}, {"metadata": {"_uuid": "14b0cbf276f88733db2eecc13f4510db5f8f2f8e", "collapsed": false, "_execution_state": "idle"}, "outputs": [], "cell_type": "code", "source": "", "execution_count": null}], "metadata": {"language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "codemirror_mode": {"version": 3, "name": "ipython"}, "file_extension": ".py", "name": "python", "pygments_lexer": "ipython3", "version": "3.6.1"}, "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}}, "nbformat": 4}