{"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":"# Ovarian Train Thumbnails in Label Folder ","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-09T03:29:15.066917Z","iopub.execute_input":"2023-10-09T03:29:15.067272Z","iopub.status.idle":"2023-10-09T03:29:15.500386Z","shell.execute_reply.started":"2023-10-09T03:29:15.067242Z","shell.execute_reply":"2023-10-09T03:29:15.499275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/UBC-OCEAN/train.csv')\ndisplay(train)\nnames=train['label'].unique().tolist()","metadata":{"execution":{"iopub.status.busy":"2023-10-09T03:30:07.067472Z","iopub.execute_input":"2023-10-09T03:30:07.067902Z","iopub.status.idle":"2023-10-09T03:30:07.094834Z","shell.execute_reply.started":"2023-10-09T03:30:07.067872Z","shell.execute_reply":"2023-10-09T03:30:07.094101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir datasets\nfor name in names:\n    !mkdir datasets/{name}\n!ls datasets","metadata":{"execution":{"iopub.status.busy":"2023-10-09T03:29:15.536018Z","iopub.execute_input":"2023-10-09T03:29:15.536444Z","iopub.status.idle":"2023-10-09T03:29:23.481527Z","shell.execute_reply.started":"2023-10-09T03:29:15.536408Z","shell.execute_reply":"2023-10-09T03:29:23.480157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths=[]\nfor dirname, _, filenames in os.walk('/kaggle/input/UBC-OCEAN/train_thumbnails'):\n    for filename in filenames:\n        paths+=[(os.path.join(dirname, filename))]\nprint(paths[0:3])","metadata":{"execution":{"iopub.status.busy":"2023-10-09T03:29:23.484086Z","iopub.execute_input":"2023-10-09T03:29:23.485428Z","iopub.status.idle":"2023-10-09T03:29:23.571877Z","shell.execute_reply.started":"2023-10-09T03:29:23.485391Z","shell.execute_reply":"2023-10-09T03:29:23.570662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for path in paths:\n    strid=path.split('/')[-1].split('_')[0]\n    datai=train[train['image_id']==int(strid)]\n    #display(datai)\n    label=datai.iloc[0,1]\n    !cp {path} datasets/{label}","metadata":{"execution":{"iopub.status.busy":"2023-10-09T03:31:26.765227Z","iopub.execute_input":"2023-10-09T03:31:26.765705Z","iopub.status.idle":"2023-10-09T03:31:28.013496Z","shell.execute_reply.started":"2023-10-09T03:31:26.765671Z","shell.execute_reply":"2023-10-09T03:31:28.012277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}