{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# Deep Learning\n# HW #1 - Watch Transcendence\n# Convolutional Neural Networks\n# 1. Look at tiny, simply pieces of information in an image\n# 2. Gradually combine that information to understand more complex patterns\n# 3. Use all the recognized patterns to understand the big picture\n\n# Tensorflow\n# Keras in Tensorflow\n# HEX values for gray are 0-255\n# Color Images\n# RGB Scale\n# Tensors\n# Convlutions\n# Output Convolutions\n# Layered Convolutions\n# Use a Pretrained Model","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-09T00:36:12.715690Z","iopub.execute_input":"2023-11-09T00:36:12.716059Z","iopub.status.idle":"2023-11-09T00:36:12.722636Z","shell.execute_reply.started":"2023-11-09T00:36:12.716031Z","shell.execute_reply":"2023-11-09T00:36:12.720695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nfrom os.path import join\nfp = \"/kaggle/input/dog-breed-identification/train\"\n\nimageFilepaths = [join(fp, filename) for filename in [\n    \"000bec180eb18c7604dcecc8fe0dba07.jpg\",\n    \"001513dfcb2ffafc82cccf4d8bbaba97.jpg\",\n    \"001cdf01b096e06d78e9e5112d419397.jpg\",\n    \"00214f311d5d2247d5dfe4fe24b2303d.jpg\"\n]]\n\nimageFilepaths","metadata":{"execution":{"iopub.status.busy":"2023-11-09T00:36:12.725571Z","iopub.execute_input":"2023-11-09T00:36:12.726031Z","iopub.status.idle":"2023-11-09T00:36:12.745106Z","shell.execute_reply.started":"2023-11-09T00:36:12.725997Z","shell.execute_reply":"2023-11-09T00:36:12.743567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preprocess the images\nimport numpy as np\nfrom tensorflow.keras.applications.resnet50 import preprocess_input\nfrom tensorflow.keras.preprocessing.image import load_img, img_to_array\n\ndef preprocessImages(imageFilepaths, imageHeight=224, imageWidth=224):\n    images = [load_img(path, target_size=(imageHeight, imageWidth)) for path in imageFilepaths]\n    return images\n\nimageArray = np.array([img_to_array(image) for image in preprocessImages(imageFilepaths)])\n\noutput = preprocess_input(imageArray)\noutput","metadata":{"execution":{"iopub.status.busy":"2023-11-09T00:36:12.746989Z","iopub.execute_input":"2023-11-09T00:36:12.747317Z","iopub.status.idle":"2023-11-09T00:36:12.776791Z","shell.execute_reply.started":"2023-11-09T00:36:12.747289Z","shell.execute_reply":"2023-11-09T00:36:12.775087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.applications import ResNet50\nmodel = ResNet50()","metadata":{"execution":{"iopub.status.busy":"2023-11-09T00:36:12.779405Z","iopub.execute_input":"2023-11-09T00:36:12.779711Z","iopub.status.idle":"2023-11-09T00:36:14.981529Z","shell.execute_reply.started":"2023-11-09T00:36:12.779685Z","shell.execute_reply":"2023-11-09T00:36:14.980386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fp = \"/kaggle/input/dog-breed-identification/test\"\nimport os\nX_test = []\n\nfor filename in os.listdir(fp):\n    filepath = os.path.join(fp, filename)\n    X_test.append(filepath)\n    \nX_test_preprocessed = preprocessImages(X_test)\nX_test_array = np.array([img_to_array(image) for image in X_test_preprocessed])\nX_test_output = preprocess_input(X_test_array)\n\npredictions = model.predict(X_test_output)\npredictions","metadata":{"execution":{"iopub.status.busy":"2023-11-09T00:36:42.882358Z","iopub.execute_input":"2023-11-09T00:36:42.883701Z"},"trusted":true},"execution_count":null,"outputs":[]}]}