{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-output":true},"cell_type":"code","source":"!pip uninstall fastai -y\n!pip install fastai","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"from fastai.vision.all import *","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path = Path('../input/landmark-recognition-2020/')\nPath.BASE_PATH = path\npath.ls()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Add paths to csv file","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"df = pd.read_csv(path/'train.csv', low_memory=False)\ndf.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def add_path(s):\n    x = s[:3]\n    return f'{x[0]}/{x[1]}/{x[2]}/{s}.jpg'\ndf['id'] = df['id'].apply(add_path)\n\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Setup fastai dataloader","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"gld = DataBlock(blocks=(ImageBlock, CategoryBlock),\n                splitter=RandomSplitter(),\n                get_x=ColReader('id', pref='../input/landmark-recognition-2020/train/'),\n                get_y=ColReader('landmark_id'),\n                item_tfms=Resize(448),\n                batch_tfms=aug_transforms(size=224))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dls = gld.dataloaders(df, bs=32)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dls.show_batch(max_n=9)","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}