{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\n# import os\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"data = pd.read_csv('../input/landmark-retrieval-2020/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(f\"Columns that we are using are :- {data.columns[0]}, {data.columns[1]}\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(f\"Total Numbers of the id or images {data.shape[0]}, with unique Landmarks {len(set(data['landmark_id']))}\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we are having nearly 1.58 Million images and 81.3k LandMark ids","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"landmarks = data['landmark_id']\nids = data['id']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#ids, landmarks","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data['count'] = data[\"landmark_id\"].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data_count=data['count'].dropna()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"xval = data_count.values","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"yval = np.array(list(set(landmarks)))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(xval[:20]), len(yval[:20])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"type(xval), type(yval)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nax = plt.figure(figsize=(30, 10))\nplt.hist(xval, bins='auto')\nax.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = plt.figure(figsize=(30, 10))\nplt.plot(yval, xval, c = 'r', lw=2)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**See Images How it is**\n\nThis list will Exaplain about the normal Looping or Manual Inputs\nHere you can see images of the 0 class","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\n\nimages = ['../input/landmark-retrieval-2020/index/0/0/0/'+i for i in os.listdir('../input/landmark-retrieval-2020/index/0/0/0') if i.endswith('.jpg')]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"images","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import cv2\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nw=10\nh=10\nfig=plt.figure(figsize=(10, 8))\ncolumns = 4\nrows = 5\nfor i in range(1, len(images)):\n    img = cv2.imread(images[i])\n    fig.add_subplot(rows, columns, i)\n    plt.imshow(img)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Automated Images Looping**\n\n\nHere learn about the How to loop automatically through the images \n\nJust go through the Nested list","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"lis = [f'../input/landmark-retrieval-2020/index/{l}/{j}/{k}/'+ i for l in range(2) for j in range(2) for k in range(1) for i in os.listdir(f'../input/landmark-retrieval-2020/index/{l}/{j}/{k}') if i.endswith(\".jpg\")]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(lis)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import cv2\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nw=10\nh=10\nfig=plt.figure(figsize=(15, 15))\ncolumns = 10\nrows = 8\nfor i in range(1, len(lis)):\n    img = cv2.imread(lis[i])\n    fig.add_subplot(rows, columns, i)\n    plt.imshow(img)\n    plt.title(lis[i])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Printing images with the Title**\n\nLearn how to print images with the title \n\nHere i gave image name as the title","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import cv2\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nw=10\nh=10\nfig=plt.figure(figsize=(15, 15))\ncolumns = 4\nrows = 4\nfor i in range(1, len(lis[:9])):\n    img = cv2.imread(lis[i])\n    fig.add_subplot(rows, columns, i)\n    plt.imshow(img)\n    plt.title(lis[i][-20:])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","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}