{"nbformat_minor":1,"nbformat":4,"cells":[{"source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)%%\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.axes_grid1 import ImageGrid\nfrom keras.preprocessing import image\nfrom os import listdir, makedirs\nfrom os.path import join, exists, expanduser\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output.","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"93336fe5-f58a-4870-af80-32716fdd380e","_uuid":"d287cca382eb6167729b73d3e42db177f67905ff"},"cell_type":"code"},{"source":"INPUT_SIZE = 224\nNUM_CLASSES = 120\nSEED = 1993\ndata_dir = '../input'\nlabels = pd.read_csv(join(data_dir, 'labels.csv'))\nsample_submission = pd.read_csv(join(data_dir, 'sample_submission.csv'))\nprint(len(listdir(join(data_dir, 'train'))), len(labels))\nprint(len(listdir(join(data_dir, 'test'))), len(sample_submission))","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"1c7dcfe2-acf3-4a15-96c6-6a1b4091542d","_uuid":"316fd3bdd569aff6c2bed3d2989ac709b746672a"},"cell_type":"code"},{"source":"labels.head(5)","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"53656a66-21ca-45a9-a425-904b80187160","_uuid":"7ebb3fc62ddc6f7607b85a1d668a84b4461b59e6"},"cell_type":"code"},{"source":"sample_submission.head(5).shape","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"028217e0-b3e5-4984-9cee-3335f57839aa","_uuid":"6c297fcae99601e46cd7bc1b836aebee1b0623cd"},"cell_type":"code"},{"source":"def read_img(img_id, train_or_test, size):\n    \"\"\"\n    Read and resize image.\n    # Arguments\n        img_id: string\n        train_or_test: string 'train' or 'test'\n        size: resize the original image.\n    # Returns\n        Image as numpy array\n    \"\"\"\n    img = image.load_img(join(data_dir, train_or_test, '%s.jpg' % img_id), target_size = size)\n    img = image.img_to_array(img)\n    return img","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"0443b1c5-6db5-49dd-87b2-1b0f5a71d981","_uuid":"8a2d33910c6043d2af2cfd29e669d32abea38991","collapsed":true},"cell_type":"code"},{"source":"fig = plt.figure(1, figsize=(16,16))\ngrid = ImageGrid(fig, 111, nrows_ncols=(4,4), axes_pad=0.05)\nfor i, img_id in enumerate(labels['id'].head(16)):\n    ax = grid[i]\n    img = read_img(img_id, 'train', (224,224))\n    ax.imshow(img / 255.)\n\nplt.show()","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"48df0569-24e5-4d2f-aa22-0fc04abe6d53","_uuid":"cfd5be56f6a06777f7cdb9e83658df2bc1f7d681"},"cell_type":"code"},{"source":"","outputs":[],"execution_count":null,"metadata":{"_cell_guid":"e045cd1f-19a1-4fdc-a10d-5df32421c883","_uuid":"6dcba6d733ad8bacff1b85ab9e2d8975fbc84320","collapsed":true},"cell_type":"code"},{"source":"","outputs":[],"execution_count":null,"metadata":{"collapsed":true},"cell_type":"code"}],"metadata":{"language_info":{"file_extension":".py","name":"python","version":"3.6.4","pygments_lexer":"ipython3","codemirror_mode":{"version":3,"name":"ipython"},"mimetype":"text/x-python","nbconvert_exporter":"python"},"kernelspec":{"language":"python","name":"python3","display_name":"Python 3"}}}