{"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":"markdown","source":"# ASL Superimposed Image Showing Sign\n","metadata":{"papermill":{"duration":0.006545,"end_time":"2023-04-07T14:31:40.434181","exception":false,"start_time":"2023-04-07T14:31:40.427636","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"## Whether the sign is shown when the paraquett plot information showing one sign is superimposed on one motionless image.","metadata":{}},{"cell_type":"code","source":"import os\nimport random\nimport numpy as np\nimport pandas as pd\nimport cv2\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"papermill":{"duration":2.855174,"end_time":"2023-04-07T14:31:43.294813","exception":false,"start_time":"2023-04-07T14:31:40.439639","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-08T10:22:38.525746Z","iopub.execute_input":"2023-04-08T10:22:38.527167Z","iopub.status.idle":"2023-04-08T10:22:38.539085Z","shell.execute_reply.started":"2023-04-08T10:22:38.527106Z","shell.execute_reply":"2023-04-08T10:22:38.537797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_paths=[]\nfiles=[]\nfor dirname, _, filenames in os.walk('/kaggle/input/create-00-images-from-asl-signs/data'):\n    for filename in filenames:\n        if filename[-4:]=='.png':\n            image_paths+=[(os.path.join(dirname, filename))]\n            files+=[filename]\ntrain2=pd.DataFrame(columns=['img_path','file'])\ntrain2['img_path']=image_paths\ntrain2['file']=files","metadata":{"execution":{"iopub.status.busy":"2023-04-08T10:22:38.842144Z","iopub.execute_input":"2023-04-08T10:22:38.843094Z","iopub.status.idle":"2023-04-08T10:22:41.690077Z","shell.execute_reply.started":"2023-04-08T10:22:38.843035Z","shell.execute_reply":"2023-04-08T10:22:41.688461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/asl-signs/train.csv')\ntrain['file']=train['participant_id'].astype(str)+'_'+train['sequence_id'].astype(str)+'.png'\ntrain3=train2.merge(train,on='file',how='left')\ndf=train3[['img_path','sign']]\nnames=sorted(df['sign'].unique().tolist())","metadata":{"papermill":{"duration":0.012563,"end_time":"2023-04-07T14:31:43.685055","exception":false,"start_time":"2023-04-07T14:31:43.672492","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-08T10:22:41.691446Z","iopub.execute_input":"2023-04-08T10:22:41.691750Z","iopub.status.idle":"2023-04-08T10:22:42.017882Z","shell.execute_reply.started":"2023-04-08T10:22:41.691722Z","shell.execute_reply":"2023-04-08T10:22:42.016061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Images and Labels","metadata":{"papermill":{"duration":0.004987,"end_time":"2023-04-07T14:31:43.716739","exception":false,"start_time":"2023-04-07T14:31:43.711752","status":"completed"},"tags":[]}},{"cell_type":"code","source":"fig, axs = plt.subplots(20,3, figsize=(8,60))\nt=0\nfor i,name in enumerate(names):\n    dfi=df[df['sign']==name].reset_index(drop=True)\n    if len(dfi)>=3 and t<20:\n        t+=1\n        for j in range(3):\n            img_path = dfi['img_path'][j]\n            img = cv2.imread(img_path)\n            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n            img = cv2.resize(img, (150,150))\n            label_text = f\"{dfi['sign'][j]}\"\n            row = t-1\n            col = j\n            axs[row, col].imshow(img)\n            axs[row, col].set_title(label_text, fontsize=12)\n            axs[row, col].axis('off')\n\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":0.026349,"end_time":"2023-04-07T15:14:39.251399","exception":false,"start_time":"2023-04-07T15:14:39.22505","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-08T10:22:42.375649Z","iopub.execute_input":"2023-04-08T10:22:42.376409Z","iopub.status.idle":"2023-04-08T10:22:46.866861Z","shell.execute_reply.started":"2023-04-08T10:22:42.376370Z","shell.execute_reply":"2023-04-08T10:22:46.864907Z"},"trusted":true},"execution_count":null,"outputs":[]}]}