{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-08-04T10:31:55.061691Z","iopub.execute_input":"2023-08-04T10:31:55.062188Z","iopub.status.idle":"2023-08-04T10:31:55.098241Z","shell.execute_reply.started":"2023-08-04T10:31:55.062143Z","shell.execute_reply":"2023-08-04T10:31:55.097002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install numpy>=1.16.5","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:31:55.100166Z","iopub.execute_input":"2023-08-04T10:31:55.101051Z","iopub.status.idle":"2023-08-04T10:32:10.190532Z","shell.execute_reply.started":"2023-08-04T10:31:55.100982Z","shell.execute_reply":"2023-08-04T10:32:10.189334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install --upgrade pip ","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:10.193578Z","iopub.execute_input":"2023-08-04T10:32:10.193967Z","iopub.status.idle":"2023-08-04T10:32:39.998999Z","shell.execute_reply.started":"2023-08-04T10:32:10.193922Z","shell.execute_reply":"2023-08-04T10:32:39.997536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nsns.set(style='ticks')\nfrom tqdm.notebook import tqdm","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:40.000613Z","iopub.execute_input":"2023-08-04T10:32:40.000958Z","iopub.status.idle":"2023-08-04T10:32:40.689708Z","shell.execute_reply.started":"2023-08-04T10:32:40.000925Z","shell.execute_reply":"2023-08-04T10:32:40.68814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install nb-black","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:40.691668Z","iopub.execute_input":"2023-08-04T10:32:40.692322Z","iopub.status.idle":"2023-08-04T10:32:47.243075Z","shell.execute_reply.started":"2023-08-04T10:32:40.692282Z","shell.execute_reply":"2023-08-04T10:32:47.24197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dir=\"/kaggle/input/asl-fingerspelling\"\ntrain=pd.read_csv(f'{dir}/train.csv')","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:47.244462Z","iopub.execute_input":"2023-08-04T10:32:47.2448Z","iopub.status.idle":"2023-08-04T10:32:47.422598Z","shell.execute_reply.started":"2023-08-04T10:32:47.244769Z","shell.execute_reply":"2023-08-04T10:32:47.421724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:47.425468Z","iopub.execute_input":"2023-08-04T10:32:47.42664Z","iopub.status.idle":"2023-08-04T10:32:47.435589Z","shell.execute_reply.started":"2023-08-04T10:32:47.42659Z","shell.execute_reply":"2023-08-04T10:32:47.434464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head(10) #this csv file contains path,file_id,sequence_id,participant_id and phrase","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:47.46795Z","iopub.execute_input":"2023-08-04T10:32:47.468726Z","iopub.status.idle":"2023-08-04T10:32:47.481329Z","shell.execute_reply.started":"2023-08-04T10:32:47.468691Z","shell.execute_reply":"2023-08-04T10:32:47.48019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.phrase.value_counts()\n","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:47.483237Z","iopub.execute_input":"2023-08-04T10:32:47.483942Z","iopub.status.idle":"2023-08-04T10:32:47.549248Z","shell.execute_reply.started":"2023-08-04T10:32:47.4839Z","shell.execute_reply":"2023-08-04T10:32:47.548104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.phrase.value_counts().head(20).sort_values(ascending=True).plot(kind=\"barh\",figsize=(10,10),title=\"TOP 20 SIGNS\")","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:47.550786Z","iopub.execute_input":"2023-08-04T10:32:47.551224Z","iopub.status.idle":"2023-08-04T10:32:48.219412Z","shell.execute_reply.started":"2023-08-04T10:32:47.551192Z","shell.execute_reply":"2023-08-04T10:32:48.218483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Parquet Landmark Data**","metadata":{}},{"cell_type":"code","source":"train.query('phrase==\"surprise az\"')","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:48.221302Z","iopub.execute_input":"2023-08-04T10:32:48.221949Z","iopub.status.idle":"2023-08-04T10:32:48.248506Z","shell.execute_reply.started":"2023-08-04T10:32:48.221915Z","shell.execute_reply":"2023-08-04T10:32:48.247306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"*Path are found to be overlapping*","metadata":{}},{"cell_type":"markdown","source":"# **Landmark for Suprize az**","metadata":{}},{"cell_type":"code","source":"train.query('phrase==\"surprise az\"')[\"path\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:48.25009Z","iopub.execute_input":"2023-08-04T10:32:48.250669Z","iopub.status.idle":"2023-08-04T10:32:48.266421Z","shell.execute_reply.started":"2023-08-04T10:32:48.250635Z","shell.execute_reply":"2023-08-04T10:32:48.264864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"path\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:48.268515Z","iopub.execute_input":"2023-08-04T10:32:48.269081Z","iopub.status.idle":"2023-08-04T10:32:48.288718Z","shell.execute_reply.started":"2023-08-04T10:32:48.269036Z","shell.execute_reply":"2023-08-04T10:32:48.287438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example=train.query('phrase==\"surprise az\"')[\"path\"].values[0]\nexample_landmark=pd.read_parquet(f\"{dir}/{example}\")","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:32:48.290692Z","iopub.execute_input":"2023-08-04T10:32:48.29124Z","iopub.status.idle":"2023-08-04T10:33:04.324914Z","shell.execute_reply.started":"2023-08-04T10:32:48.291159Z","shell.execute_reply":"2023-08-04T10:33:04.32379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example_landmark","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:33:04.327461Z","iopub.execute_input":"2023-08-04T10:33:04.327964Z","iopub.status.idle":"2023-08-04T10:33:04.387829Z","shell.execute_reply.started":"2023-08-04T10:33:04.327908Z","shell.execute_reply":"2023-08-04T10:33:04.386903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example_landmark[\"frame\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:33:04.389227Z","iopub.execute_input":"2023-08-04T10:33:04.390468Z","iopub.status.idle":"2023-08-04T10:33:04.403295Z","shell.execute_reply.started":"2023-08-04T10:33:04.39043Z","shell.execute_reply":"2023-08-04T10:33:04.401989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_frames=example_landmark[\"frame\"].value_counts().nunique()\nprint(f\"The total number of unique frames = {unique_frames}\")","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:33:04.408809Z","iopub.execute_input":"2023-08-04T10:33:04.40927Z","iopub.status.idle":"2023-08-04T10:33:04.421231Z","shell.execute_reply.started":"2023-08-04T10:33:04.409235Z","shell.execute_reply":"2023-08-04T10:33:04.419767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Create metadata for training data**","metadata":{}},{"cell_type":"code","source":"for i,d in tqdm(train.iterrows(),total=len(train)):\n    file_path=d[\"path\"]\n    example_landmark=pd.read_parquet(f\"{dir}/{file_path}\")\n    \n    break","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:43:35.275965Z","iopub.execute_input":"2023-08-04T10:43:35.277133Z","iopub.status.idle":"2023-08-04T10:43:37.682106Z","shell.execute_reply.started":"2023-08-04T10:43:35.27709Z","shell.execute_reply":"2023-08-04T10:43:37.681235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example_landmark","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:43:39.021488Z","iopub.execute_input":"2023-08-04T10:43:39.021914Z","iopub.status.idle":"2023-08-04T10:43:39.081308Z","shell.execute_reply.started":"2023-08-04T10:43:39.021871Z","shell.execute_reply":"2023-08-04T10:43:39.080178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Using Mediapipe**","metadata":{}},{"cell_type":"code","source":"!pip install mediapipe --quiet","metadata":{"execution":{"iopub.status.busy":"2023-08-04T10:59:00.077087Z","iopub.execute_input":"2023-08-04T10:59:00.077599Z","iopub.status.idle":"2023-08-04T10:59:16.307112Z","shell.execute_reply.started":"2023-08-04T10:59:00.077558Z","shell.execute_reply":"2023-08-04T10:59:16.305731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! wget https://previews.123rf.com/images/piksel/piksel1204/piksel120400014/13063142-casual-man-standing.jpg","metadata":{"execution":{"iopub.status.busy":"2023-08-04T11:00:30.902121Z","iopub.execute_input":"2023-08-04T11:00:30.902616Z","iopub.status.idle":"2023-08-04T11:00:32.768835Z","shell.execute_reply.started":"2023-08-04T11:00:30.902575Z","shell.execute_reply":"2023-08-04T11:00:32.767096Z"},"trusted":true},"execution_count":null,"outputs":[]}]}