{"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":"data_path = \"/kaggle/input/asl-signs/train.csv\"\nsign_to_index_map = \"/kaggle/input/asl-signs/sign_to_prediction_index_map.json\"\n","metadata":{"execution":{"iopub.status.busy":"2023-04-01T20:15:40.713085Z","iopub.execute_input":"2023-04-01T20:15:40.714654Z","iopub.status.idle":"2023-04-01T20:15:40.719406Z","shell.execute_reply.started":"2023-04-01T20:15:40.714586Z","shell.execute_reply":"2023-04-01T20:15:40.718685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport os\nimport cv2\nimport matplotlib.pyplot as plt\nimport tensorflow as tf\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.applications import MobileNetV2\nfrom tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout\nfrom tensorflow.keras.models import Model\nfrom sklearn.model_selection import train_test_split\n","metadata":{"execution":{"iopub.status.busy":"2023-04-01T20:16:45.007365Z","iopub.execute_input":"2023-04-01T20:16:45.007756Z","iopub.status.idle":"2023-04-01T20:16:56.561914Z","shell.execute_reply.started":"2023-04-01T20:16:45.007725Z","shell.execute_reply":"2023-04-01T20:16:56.560082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import json\n\nwith open(sign_to_index_map) as f:\n    label_map = json.load(f)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-01T20:15:57.585737Z","iopub.execute_input":"2023-04-01T20:15:57.587043Z","iopub.status.idle":"2023-04-01T20:15:57.599627Z","shell.execute_reply.started":"2023-04-01T20:15:57.586963Z","shell.execute_reply":"2023-04-01T20:15:57.59771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_data(data_path, label_map):\n    df = pd.read_csv(data_path)\n    images = []\n    labels = []\n    \n    for index, row in df.iterrows():\n        img_path = row['path']  # Replace 'path' with the correct column name in the CSV file\n        label = row['sign']  # Replace 'sign' with the correct column name in the CSV file\n        img = cv2.imread(img_path)\n        img = cv2.resize(img, (224, 224))\n        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n        images.append(img)\n        labels.append(label_map[label])\n\n    images = np.array(images, dtype=\"float32\")\n    labels = tf.keras.utils.to_categorical(labels, num_classes=len(label_map))\n    return images, labels\n\nimages, labels = load_data(data_path, label_map)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-01T20:17:04.728587Z","iopub.execute_input":"2023-04-01T20:17:04.729382Z","iopub.status.idle":"2023-04-01T20:17:05.213882Z","shell.execute_reply.started":"2023-04-01T20:17:04.729345Z","shell.execute_reply":"2023-04-01T20:17:05.212194Z"},"trusted":true},"execution_count":null,"outputs":[]}]}