{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"992ef1e4-760d-3f3f-536e-d7c27f88a388"},"outputs":[],"source":"import tensorflow as tf\nimport cv2                 # working with, mainly resizing, images\nimport numpy as np         # dealing with arrays\nimport os                  # dealing with directories\nfrom random import shuffle # mixing up or currently ordered data that might lead our network astray in training.\nfrom tqdm import tqdm  \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":"04863382-ce5e-acfe-1c0e-53a48b5afcd2"},"outputs":[],"source":"IMG_SIZE = 50 \ntraining_data = []"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"3faa3f62-413a-2dc9-29ff-d75ec15577c6"},"outputs":[],"source":"pixel_depth = 255.0 \ndef create_train_data(TRAIN_DIR, label):\n    for img in tqdm(os.listdir(TRAIN_DIR)):\n        if not img[0].isdigit():\n            continue\n        path = os.path.join(TRAIN_DIR,img)\n        img = (cv2.imread(path,cv2.IMREAD_GRAYSCALE) - pixel_depth / 2) / pixel_depth\n        # img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n        img = cv2.resize(img, (IMG_SIZE,IMG_SIZE))\n        training_data.append([np.array(img),np.array(label)])"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"572642f1-d3a2-d33f-96f4-88ae542c7282"},"outputs":[],"source":"create_train_data(\"../input/train/Type_1\", [1.0,0.0,0.0])\ncreate_train_data(\"../input/train/Type_2\", [0.0,1.0,0.0])\ncreate_train_data(\"../input/train/Type_3\", [0.0,0.0,1.0])"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"cefe7136-da96-8c8d-56c3-a9a84e615703"},"outputs":[],"source":"shuffle(training_data)"}],"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}