{"cells":[{"metadata":{},"cell_type":"markdown","source":"\n\nhttp://labs.eecs.tottori-u.ac.jp/sd/Member/oyamada/OpenCV/html/py_tutorials/py_feature2d/py_table_of_contents_feature2d/py_table_of_contents_feature2d.html\n","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","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)\nimport os\nimport glob\nimport cv2\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport math\nimport random\n\nfrom scipy import stats\n\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n#    for filename in filenames:\n#        print(os.path.join(dirname, filename))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/landmark-retrieval-2020/train.csv\")\ntrain.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## type of landmark_id","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"landmark_id_list = train.landmark_id.unique()\nlen(train.landmark_id.unique())\nprint(landmark_id_list)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## axesのarrayについてはこちら\n\nhttp://nekoyukimmm.hatenablog.com/entry/2015/03/31/231019\n\nhttps://www.kaggle.com/seriousran/google-landmark-retrieval-2020-eda\n\n\n","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"path='../input/landmark-retrieval-2020/train/'\n\ndef plot_landmarks(landmark_id, df, ncolumns=4, max_figs = 96):\n    landmark_df = df[df['landmark_id']==landmark_id]\n    nrows = int(math.ceil(len(landmark_df)/ncolumns))\n    plt.rcParams[\"axes.grid\"] = False\n    f, ax = plt.subplots(ncols=ncolumns, nrows=nrows, figsize=(int(max_figs/ncolumns), int(max_figs/ncolumns)), squeeze=False)\n    f.set_size_inches(18, 6*nrows)\n    \n    pos = 0\n    count = 0\n    for i, row in landmark_df.iterrows():\n        image_id =  row['id']\n        img = cv2.imread(path+'/'+image_id[0]+'/'+image_id[1]+'/'+image_id[2]+'/'+image_id+'.jpg')\n        img = img[:,:,::-1]\n        \n        col = count%ncolumns\n        ax[pos,col].imshow(img)\n        if col == int(ncolumns - 1):\n            pos += 1\n        count += 1","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_landmarks(landmark_id=183115, df=train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_landmarks(landmark_id=1, df=train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"random_id = landmark_id_list[random.randrange(len(train.landmark_id.unique()))]\nprint(random_id)\nplot_landmarks(landmark_id=random_id, df=train)","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}