{"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":"# This notebook is for someone who want to use function to plot multiple images \n# maybe for trying to create your own test set for classification","metadata":{}},{"cell_type":"code","source":"import cv2\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nfrom glob import glob\nimport numpy as np\nfrom matplotlib import pyplot as plt\nimport gc\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\noutside_path ='../input/happy-whale-and-dolphin/'\npath = '../input/happy-whale-and-dolphin/train_images/*.jpg' \nfiles = glob(path)\nprint(os.listdir(outside_path))\nprint(files[:10])","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:42.649881Z","iopub.execute_input":"2022-02-16T16:31:42.650105Z","iopub.status.idle":"2022-02-16T16:31:42.865712Z","shell.execute_reply.started":"2022-02-16T16:31:42.650077Z","shell.execute_reply":"2022-02-16T16:31:42.864810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntrain_data = pd.read_csv(outside_path+'train.csv')\nsamp_subm = pd.read_csv(outside_path+'sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:42.867158Z","iopub.execute_input":"2022-02-16T16:31:42.867459Z","iopub.status.idle":"2022-02-16T16:31:42.981019Z","shell.execute_reply.started":"2022-02-16T16:31:42.867418Z","shell.execute_reply":"2022-02-16T16:31:42.980051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Number train samples:', len(train_data))\nprint('Number train images:', len(os.listdir(outside_path+'train_images/')))\nprint('Number test images:', len(os.listdir(outside_path+'test_images/')))","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:42.983224Z","iopub.execute_input":"2022-02-16T16:31:42.983578Z","iopub.status.idle":"2022-02-16T16:31:43.026557Z","shell.execute_reply.started":"2022-02-16T16:31:42.983533Z","shell.execute_reply":"2022-02-16T16:31:43.025758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot multiple whales\ndef plot_examples(category = 'bottlenose_dolphin'):\n    \"\"\" Plot 5 images of a given category \"\"\"\n    \n    fig, axs = plt.subplots(1, 5, figsize=(25, 20))\n    fig.subplots_adjust(hspace = .1, wspace=.1)\n    axs = axs.ravel()\n    temp = train_data[train_data['species']==category].copy()\n    temp.index = range(len(temp.index))\n    for i in range(5):\n        file = temp.loc[i, 'image']\n        species = temp.loc[i, 'species']\n        img = cv2.imread(outside_path+'train_images/'+file)\n        axs[i].imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\n        axs[i].set_title(species)\n        axs[i].set_xticklabels([])\n        axs[i].set_yticklabels([])\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:43.028071Z","iopub.execute_input":"2022-02-16T16:31:43.028686Z","iopub.status.idle":"2022-02-16T16:31:43.040168Z","shell.execute_reply.started":"2022-02-16T16:31:43.028638Z","shell.execute_reply":"2022-02-16T16:31:43.039260Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'beluga')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:43.041551Z","iopub.execute_input":"2022-02-16T16:31:43.042162Z","iopub.status.idle":"2022-02-16T16:31:44.527425Z","shell.execute_reply.started":"2022-02-16T16:31:43.042121Z","shell.execute_reply":"2022-02-16T16:31:44.523240Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'blue_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:44.528604Z","iopub.execute_input":"2022-02-16T16:31:44.528922Z","iopub.status.idle":"2022-02-16T16:31:45.735379Z","shell.execute_reply.started":"2022-02-16T16:31:44.528881Z","shell.execute_reply":"2022-02-16T16:31:45.734450Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'bottlenose_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:45.736803Z","iopub.execute_input":"2022-02-16T16:31:45.737094Z","iopub.status.idle":"2022-02-16T16:31:51.059534Z","shell.execute_reply.started":"2022-02-16T16:31:45.737057Z","shell.execute_reply":"2022-02-16T16:31:51.058869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'bottlenose_dolpin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:51.061719Z","iopub.execute_input":"2022-02-16T16:31:51.062090Z","iopub.status.idle":"2022-02-16T16:31:52.392114Z","shell.execute_reply.started":"2022-02-16T16:31:51.062054Z","shell.execute_reply":"2022-02-16T16:31:52.391480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'brydes_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:52.393288Z","iopub.execute_input":"2022-02-16T16:31:52.393657Z","iopub.status.idle":"2022-02-16T16:31:54.994633Z","shell.execute_reply.started":"2022-02-16T16:31:52.393612Z","shell.execute_reply":"2022-02-16T16:31:54.993608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'commersons_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:54.995905Z","iopub.execute_input":"2022-02-16T16:31:54.996135Z","iopub.status.idle":"2022-02-16T16:31:59.777375Z","shell.execute_reply.started":"2022-02-16T16:31:54.996106Z","shell.execute_reply":"2022-02-16T16:31:59.776498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'common_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:31:59.778661Z","iopub.execute_input":"2022-02-16T16:31:59.779367Z","iopub.status.idle":"2022-02-16T16:32:03.221623Z","shell.execute_reply.started":"2022-02-16T16:31:59.779332Z","shell.execute_reply":"2022-02-16T16:32:03.220866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'cuviers_beaked_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:03.223023Z","iopub.execute_input":"2022-02-16T16:32:03.223891Z","iopub.status.idle":"2022-02-16T16:32:08.184540Z","shell.execute_reply.started":"2022-02-16T16:32:03.223844Z","shell.execute_reply":"2022-02-16T16:32:08.183661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'dusky_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:08.185687Z","iopub.execute_input":"2022-02-16T16:32:08.185920Z","iopub.status.idle":"2022-02-16T16:32:09.316706Z","shell.execute_reply.started":"2022-02-16T16:32:08.185893Z","shell.execute_reply":"2022-02-16T16:32:09.315896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'false_killer_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:09.317756Z","iopub.execute_input":"2022-02-16T16:32:09.317967Z","iopub.status.idle":"2022-02-16T16:32:12.486514Z","shell.execute_reply.started":"2022-02-16T16:32:09.317942Z","shell.execute_reply":"2022-02-16T16:32:12.485677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'fin_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:12.487777Z","iopub.execute_input":"2022-02-16T16:32:12.488077Z","iopub.status.idle":"2022-02-16T16:32:17.108376Z","shell.execute_reply.started":"2022-02-16T16:32:12.488038Z","shell.execute_reply":"2022-02-16T16:32:17.107697Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'frasiers_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:17.109538Z","iopub.execute_input":"2022-02-16T16:32:17.109889Z","iopub.status.idle":"2022-02-16T16:32:17.910426Z","shell.execute_reply.started":"2022-02-16T16:32:17.109842Z","shell.execute_reply":"2022-02-16T16:32:17.909800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'globis')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:17.911455Z","iopub.execute_input":"2022-02-16T16:32:17.912123Z","iopub.status.idle":"2022-02-16T16:32:18.995532Z","shell.execute_reply.started":"2022-02-16T16:32:17.912086Z","shell.execute_reply":"2022-02-16T16:32:18.994565Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'gray_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:18.996644Z","iopub.execute_input":"2022-02-16T16:32:18.996877Z","iopub.status.idle":"2022-02-16T16:32:24.377469Z","shell.execute_reply.started":"2022-02-16T16:32:18.996850Z","shell.execute_reply":"2022-02-16T16:32:24.375235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'humpback_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:24.378637Z","iopub.execute_input":"2022-02-16T16:32:24.379281Z","iopub.status.idle":"2022-02-16T16:32:29.087189Z","shell.execute_reply.started":"2022-02-16T16:32:24.379245Z","shell.execute_reply":"2022-02-16T16:32:29.086539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'kiler_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:29.088138Z","iopub.execute_input":"2022-02-16T16:32:29.089112Z","iopub.status.idle":"2022-02-16T16:32:34.920866Z","shell.execute_reply.started":"2022-02-16T16:32:29.089058Z","shell.execute_reply":"2022-02-16T16:32:34.920004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'killer_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:34.922199Z","iopub.execute_input":"2022-02-16T16:32:34.922551Z","iopub.status.idle":"2022-02-16T16:32:39.955574Z","shell.execute_reply.started":"2022-02-16T16:32:34.922511Z","shell.execute_reply":"2022-02-16T16:32:39.954908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'long_finned_pilot_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:39.956655Z","iopub.execute_input":"2022-02-16T16:32:39.956996Z","iopub.status.idle":"2022-02-16T16:32:43.317589Z","shell.execute_reply.started":"2022-02-16T16:32:39.956966Z","shell.execute_reply":"2022-02-16T16:32:43.316824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'melon_headed_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:43.322178Z","iopub.execute_input":"2022-02-16T16:32:43.323019Z","iopub.status.idle":"2022-02-16T16:32:44.368483Z","shell.execute_reply.started":"2022-02-16T16:32:43.322972Z","shell.execute_reply":"2022-02-16T16:32:44.367642Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'minke_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:44.369942Z","iopub.execute_input":"2022-02-16T16:32:44.370168Z","iopub.status.idle":"2022-02-16T16:32:49.997100Z","shell.execute_reply.started":"2022-02-16T16:32:44.370139Z","shell.execute_reply":"2022-02-16T16:32:49.996331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'humpback_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:49.998373Z","iopub.execute_input":"2022-02-16T16:32:49.998823Z","iopub.status.idle":"2022-02-16T16:32:54.482841Z","shell.execute_reply.started":"2022-02-16T16:32:49.998788Z","shell.execute_reply":"2022-02-16T16:32:54.482125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'kiler_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:54.483853Z","iopub.execute_input":"2022-02-16T16:32:54.484590Z","iopub.status.idle":"2022-02-16T16:32:59.876878Z","shell.execute_reply.started":"2022-02-16T16:32:54.484550Z","shell.execute_reply":"2022-02-16T16:32:59.875952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'killer_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:32:59.878191Z","iopub.execute_input":"2022-02-16T16:32:59.878419Z","iopub.status.idle":"2022-02-16T16:33:04.744707Z","shell.execute_reply.started":"2022-02-16T16:32:59.878390Z","shell.execute_reply":"2022-02-16T16:33:04.743781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'long_finned_pilot_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:04.746010Z","iopub.execute_input":"2022-02-16T16:33:04.746345Z","iopub.status.idle":"2022-02-16T16:33:08.090093Z","shell.execute_reply.started":"2022-02-16T16:33:04.746298Z","shell.execute_reply":"2022-02-16T16:33:08.089309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'melon_headed_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:08.091136Z","iopub.execute_input":"2022-02-16T16:33:08.091672Z","iopub.status.idle":"2022-02-16T16:33:09.314961Z","shell.execute_reply.started":"2022-02-16T16:33:08.091642Z","shell.execute_reply":"2022-02-16T16:33:09.314197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'minke_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:09.316344Z","iopub.execute_input":"2022-02-16T16:33:09.317220Z","iopub.status.idle":"2022-02-16T16:33:14.704255Z","shell.execute_reply.started":"2022-02-16T16:33:09.317169Z","shell.execute_reply":"2022-02-16T16:33:14.703251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'pantropic_spotted_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:14.705635Z","iopub.execute_input":"2022-02-16T16:33:14.705999Z","iopub.status.idle":"2022-02-16T16:33:15.812048Z","shell.execute_reply.started":"2022-02-16T16:33:14.705962Z","shell.execute_reply":"2022-02-16T16:33:15.811244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'pilot_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:15.813470Z","iopub.execute_input":"2022-02-16T16:33:15.813994Z","iopub.status.idle":"2022-02-16T16:33:19.717678Z","shell.execute_reply.started":"2022-02-16T16:33:15.813959Z","shell.execute_reply":"2022-02-16T16:33:19.716821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'pygmy_killer_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:19.718833Z","iopub.execute_input":"2022-02-16T16:33:19.719555Z","iopub.status.idle":"2022-02-16T16:33:20.708753Z","shell.execute_reply.started":"2022-02-16T16:33:19.719520Z","shell.execute_reply":"2022-02-16T16:33:20.707943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'rough_toothed_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:20.709820Z","iopub.execute_input":"2022-02-16T16:33:20.710021Z","iopub.status.idle":"2022-02-16T16:33:22.389795Z","shell.execute_reply.started":"2022-02-16T16:33:20.709995Z","shell.execute_reply":"2022-02-16T16:33:22.388930Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'sei_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:22.391192Z","iopub.execute_input":"2022-02-16T16:33:22.391522Z","iopub.status.idle":"2022-02-16T16:33:25.683305Z","shell.execute_reply.started":"2022-02-16T16:33:22.391477Z","shell.execute_reply":"2022-02-16T16:33:25.682506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'short_finned_pilot_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:25.684583Z","iopub.execute_input":"2022-02-16T16:33:25.684881Z","iopub.status.idle":"2022-02-16T16:33:29.585565Z","shell.execute_reply.started":"2022-02-16T16:33:25.684840Z","shell.execute_reply":"2022-02-16T16:33:29.584986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'southern_right_whale')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:29.586481Z","iopub.execute_input":"2022-02-16T16:33:29.587173Z","iopub.status.idle":"2022-02-16T16:33:32.702401Z","shell.execute_reply.started":"2022-02-16T16:33:29.587136Z","shell.execute_reply":"2022-02-16T16:33:32.701871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'spinner_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:32.703397Z","iopub.execute_input":"2022-02-16T16:33:32.703969Z","iopub.status.idle":"2022-02-16T16:33:34.793256Z","shell.execute_reply.started":"2022-02-16T16:33:32.703934Z","shell.execute_reply":"2022-02-16T16:33:34.792435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'spotted_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:34.794568Z","iopub.execute_input":"2022-02-16T16:33:34.794811Z","iopub.status.idle":"2022-02-16T16:33:36.412094Z","shell.execute_reply.started":"2022-02-16T16:33:34.794780Z","shell.execute_reply":"2022-02-16T16:33:36.411253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_examples(category = 'white_sided_dolphin')","metadata":{"execution":{"iopub.status.busy":"2022-02-16T16:33:36.413582Z","iopub.execute_input":"2022-02-16T16:33:36.413863Z","iopub.status.idle":"2022-02-16T16:33:40.848075Z","shell.execute_reply.started":"2022-02-16T16:33:36.413831Z","shell.execute_reply":"2022-02-16T16:33:40.847214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"If you like this please help to thumb up , thank you","metadata":{}}]}