{"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# Neural Networks\n# Computer Vision\n# Tensorflow and Keras\n# HEX value 0-255 for black=255, white=0\n# Color pixels = Red, Green, and Blue - RGB Color Scale\n# Scalar = One Number that describes something (height, length, grade)\n# Vector = a list of numbers, like multiple scalars\n# Matrix - a grid of rows and columns\n# Tensor - Multiple matrices stacked on top of each other, 3d items\n# Convolutions - Considered a filter to identify patterns in an image\n# Output tensor\n# Layered Convolutions","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-15T23:30:08.548005Z","iopub.execute_input":"2023-10-15T23:30:08.548713Z","iopub.status.idle":"2023-10-15T23:30:08.579176Z","shell.execute_reply.started":"2023-10-15T23:30:08.548674Z","shell.execute_reply":"2023-10-15T23:30:08.578135Z"},"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\"\nimageFilepaths = [join(fp, filename) for filename in [\n    \"000bec180eb18c7604dcecc8fe0dba07.jpg\",\n    \"001513dfcb2ffafc82cccf4d8bbaba97.jpg\",\n    \"001cdf01b096e06d78e9e5112d419397.jpg\",\n    \"0075dc49dab4024d12fafe67074d8a81.jpg\"\n]]","metadata":{"execution":{"iopub.status.busy":"2023-10-15T23:30:08.580690Z","iopub.execute_input":"2023-10-15T23:30:08.581119Z","iopub.status.idle":"2023-10-15T23:30:08.946271Z","shell.execute_reply.started":"2023-10-15T23:30:08.581094Z","shell.execute_reply":"2023-10-15T23:30:08.944988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import 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-10-15T23:30:08.947994Z","iopub.execute_input":"2023-10-15T23:30:08.948561Z","iopub.status.idle":"2023-10-15T23:30:18.909609Z","shell.execute_reply.started":"2023-10-15T23:30:08.948522Z","shell.execute_reply":"2023-10-15T23:30:18.908219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import the model\nfrom tensorflow.keras.applications import ResNet50\nmodel = ResNet50()","metadata":{"execution":{"iopub.status.busy":"2023-10-15T23:37:30.811888Z","iopub.execute_input":"2023-10-15T23:37:30.812332Z","iopub.status.idle":"2023-10-15T23:37:33.321699Z","shell.execute_reply.started":"2023-10-15T23:37:30.812299Z","shell.execute_reply":"2023-10-15T23:37:33.320257Z"},"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-10-15T23:39:46.130394Z","iopub.execute_input":"2023-10-15T23:39:46.130852Z","iopub.status.idle":"2023-10-15T23:58:58.048458Z","shell.execute_reply.started":"2023-10-15T23:39:46.130817Z","shell.execute_reply":"2023-10-15T23:58:58.047141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nimg = mpimg.imread(\"/kaggle/input/dog-breed-identification/train/0042188c895a2f14ef64a918ed9c7b64.jpg\")\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-10-15T23:59:38.996861Z","iopub.execute_input":"2023-10-15T23:59:38.997344Z","iopub.status.idle":"2023-10-15T23:59:39.548455Z","shell.execute_reply.started":"2023-10-15T23:59:38.997306Z","shell.execute_reply":"2023-10-15T23:59:39.547467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.applications.resnet50 import decode_predictions\ndecoded_predictions = decode_predictions(predictions, top=1)\ndecoded_predictions","metadata":{"execution":{"iopub.status.busy":"2023-10-16T00:01:30.366162Z","iopub.execute_input":"2023-10-16T00:01:30.366597Z","iopub.status.idle":"2023-10-16T00:01:32.795899Z","shell.execute_reply.started":"2023-10-16T00:01:30.366570Z","shell.execute_reply":"2023-10-16T00:01:32.794636Z"},"trusted":true},"execution_count":null,"outputs":[]}]}