{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"7fa62780-2d9c-153b-ea3d-2e0be0754468"},"outputs":[],"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 os\nfrom keras.models import Sequential\nfrom keras.preprocessing.image import ImageDataGenerator,array_to_img,img_to_array,load_img\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."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0467b1e5-f015-f7f8-46c9-7fd525492bf6"},"outputs":[],"source":"import pdb"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"e9e6eb75-8294-0a13-d572-b477c49431ba"},"outputs":[],"source":"# can't use this, can read in all images at the same time, need to process in batches\ndef read_image_batch(image_dir=\"../input\"):\n    image_list = []\n    for imageName in sorted(os.listdir(image_dir)):\n        image_pil = load_img(image_dir+os.sep+imageName)\n        image_array = img_to_array(image_pil)\n        image_list.append(image_array.transpose)\n    image_tensor = np.concatenate(image_list).astype(\"uint8\")\n    return image_tensor\n    "},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"2f17735d-39e9-40e2-e734-d0565e31bda7"},"outputs":[],"source":"train_datagen = ImageDataGenerator(\n        rescale=1./255,\n        shear_range=0.2,\n        zoom_range=0.2,\n        horizontal_flip=True)\ntest_datagen = ImageDataGenerator(\n        rescale=1./255)\ntrain_generator = train_datagen.flow_from_directory(\n        '../input/train',\n        target_size=(150,150),\n        batch_size=32,\n        class_mode='binary')\n"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"018a2394-860a-973a-6e43-16a249fb07b3"},"outputs":[],"source":""}],"metadata":{"_change_revision":0,"_is_fork":false,"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0}