{"cells":[{"metadata":{},"cell_type":"markdown","source":"I made a [notebook](https://www.kaggle.com/shumpeiabe/show-image-and-landmark-id) that shows a image when you give a row number.\n\nBut in this competition, I thought displaying image from landmark_id is more useful than it. So, this is it.","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\n%matplotlib inline","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_dir = '/kaggle/input/landmark-retrieval-2020/train/'\ntrain = pd.read_csv('/kaggle/input/landmark-retrieval-2020/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"def get_image_path(df, num, train_dir):\n    folder = []\n    for i in range(3):\n        folder.append(df['id'][num][i])\n        \n    _path = train_dir + '{}/{}/{}/'.format(folder[0], folder[1], folder[2]) \n    file_name = df['id'][num] + '.jpg'\n    image_path = _path + file_name\n    return image_path","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def get_img_from_landmark_id(df, landmark_id, train_dir):\n    landmark_df = df[df['landmark_id']==landmark_id]\n    \n    if len(landmark_df)==0:\n        return \"no picture of landmark_id={}\".format(landmark_id)\n    image_path = []\n    for i in range(len(landmark_df)):\n        image_path.append(get_image_path(df, i, train_dir))\n    \n    print(\"pictures of landmark_id={}\".format(landmark_id))\n    plt.figure(figsize=(8.0, 20.0))\n    plt.subplots_adjust(wspace=0.6, hspace=1)\n    for i, file_name in enumerate(image_path):\n        display_image = plt.imread(file_name)\n        plt.title(landmark_df['id'][i])\n        plt.subplot(len(image_path),2,i+1)\n        plt.imshow(display_image)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"get_img_from_landmark_id(train, 1, train_dir)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}