{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"cell_type":"code","source":"import os\nfrom os.path import join\nimport numpy as np\nimport pandas as pd\nimport random\nfrom keras.preprocessing.image import load_img, img_to_array\nfrom keras.preprocessing.image import ImageDataGenerator\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.axes_grid1 import ImageGrid\nfrom keras.applications.inception_v3 import preprocess_input\n%matplotlib inline\n","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"labels = pd.read_csv('../input/labels.csv')\nprint(labels.shape)\nlabels.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"52240caf26334d840441be4f3d0caad01b5581d1"},"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nle = LabelEncoder()\ntrain_labels = le.fit_transform(labels['breed'])\nlabels['class'] = train_labels\nlabels.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"33391a983028a396594d509a1a45c9d7ff5fb4df"},"cell_type":"code","source":"#load first image fro labels.csv\ntrain_dir = '../input/train'\nids = labels.loc[0:4, 'id']\npil_imgs = [load_img(join(train_dir, id+'.jpg'), target_size=(299, 299)) for id in ids]\nimgs = [img_to_array(pil_img) for pil_img in pil_imgs]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c2839e1b0e687d2584b82238d74a826dac6a029f"},"cell_type":"code","source":"fig = plt.figure(1, figsize=(20, 4))\ngrid = ImageGrid(fig, 111, nrows_ncols=(1, 5), axes_pad=0.1)\n\nfor i in range(5):\n    grid[i].imshow(imgs[i].astype(np.uint8))\n    grid[i].set_title(labels.loc[i, 'breed'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a7014e1bc4f349f00d2275a1340df09987dee543"},"cell_type":"code","source":"#transform and show images\nfig = plt.figure(1, figsize=(16, 16))\ngrid = ImageGrid(fig, 111, nrows_ncols=(4, 4), axes_pad=0.1)\n\ndatagen = ImageDataGenerator(rotation_range=40, zoom_range=0.2)\nfor i in range(4):\n    for batch in datagen.flow(np.array(imgs), batch_size=4):\n        for j, img in enumerate(batch):\n            grid[j+i*4].imshow(img.astype(np.uint8)) \n        break","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"74d6c41aec49efecdb3a210415a506af557dcf98"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}},"nbformat":4,"nbformat_minor":1}