{"cells":[{"metadata":{},"cell_type":"markdown","source":"Importing Libraries","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport cv2\n\nimport glob","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Reading Dataset","execution_count":null},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train_data = pd.read_csv(\"/kaggle/input/landmark-retrieval-2020/train.csv\")\nTRAIN_FOLDER = '/kaggle/input/landmark-retrieval-2020/train/'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_data.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_data.landmark_id.nunique(),train_data.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"no_of_images = train_data.groupby(\"landmark_id\").agg(count_images = (\"id\",\"nunique\")).reset_index()\nsns.distplot(no_of_images.count_images,kde = False,bins = 60)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"no_of_images.count_images.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"no_of_images.sort_values(by = [\"count_images\"]).head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We have 10-20 images for a landmark on an average","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"Landmark 183721 has one of the lowest count_images (2) and 138982 has the highest number of images (6272)","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"def plot_images(image_list,rows,cols,title):\n    fig,ax = plt.subplots(rows,cols,figsize = (25,5*rows))\n    ax = ax.flatten()\n    for i, image_id in enumerate(image_list):\n        image = cv2.imread(TRAIN_FOLDER+'{}/{}/{}/{}.jpg'.format(image_id[0],image_id[1],image_id[2],image_id))\n        image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)\n        ax[i].imshow(image)\n        ax[i].set_axis_off()\n        ax[i].set_title(image_id)\n    plt.suptitle(title)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_images(train_data.loc[train_data.landmark_id==183721,\"id\"].values,1,2,\"Images of Landmark - 183721 (Only 2 images for this landmark)\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_images(train_data.loc[train_data.landmark_id==103191,\"id\"].values[:5],1,5,\"Images of Landmark - 103191 (5 out of 13 images of this landmark)\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_images(train_data.loc[train_data.landmark_id==138982,\"id\"].values[:10],2,5,\"Images of Landmark - 138982 (10 out of 6k images of this landmark)\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_list = glob.glob('../input/landmark-retrieval-2020/test/*/*/*/*')\nindex_list = glob.glob('../input/landmark-retrieval-2020/index/*/*/*/*')\n\nprint( 'Images in Text Folder:', len(test_list))\nprint( 'Images in Index Folder:', len(index_list))","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}