{"cells":[{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2023-01-08T12:23:54.650306Z","iopub.status.busy":"2023-01-08T12:23:54.649487Z","iopub.status.idle":"2023-01-08T12:23:55.519375Z","shell.execute_reply":"2023-01-08T12:23:55.518243Z","shell.execute_reply.started":"2023-01-08T12:23:54.650185Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["Device: cuda\n"]}],"source":["import torch\n","import torch.nn as nn\n","import torch.nn.functional as F\n","import torch.optim as optim\n","from torchvision import transforms as T\n","import numpy as np\n","import pandas as pd\n","from PIL import Image\n","import matplotlib.pyplot as plt\n","from tqdm import tqdm\n","import os\n","\n","BASE_DIR = \"/kaggle/input/100-bird-species\"\n","device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n","print(\"Device:\", device)"]},{"cell_type":"code","execution_count":4,"metadata":{"execution":{"iopub.execute_input":"2023-01-08T12:23:55.523152Z","iopub.status.busy":"2023-01-08T12:23:55.522749Z","iopub.status.idle":"2023-01-08T12:23:55.887456Z","shell.execute_reply":"2023-01-08T12:23:55.886417Z","shell.execute_reply.started":"2023-01-08T12:23:55.523125Z"},"trusted":true},"outputs":[],"source":["paths_df = pd.read_csv(os.path.join(BASE_DIR, \"birds.csv\"))\n","paths_df.drop(46620, axis= 0, inplace=True)\n","labels = paths_df[\"class id\"].unique()\n","bird_name_map = {int(i): paths_df[paths_df[\"class id\"] == i][\"labels\"].values[0] for i in labels}"]},{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2023-01-08T12:23:55.889322Z","iopub.status.busy":"2023-01-08T12:23:55.888912Z","iopub.status.idle":"2023-01-08T12:23:55.909493Z","shell.execute_reply":"2023-01-08T12:23:55.908557Z","shell.execute_reply.started":"2023-01-08T12:23:55.889283Z"},"trusted":true},"outputs":[{"data":{"text/html":["
\n"," | class id | \n","filepaths | \n","labels | \n","scientific label | \n","data set | \n","
---|---|---|---|---|---|
0 | \n","0 | \n","train/ABBOTTS BABBLER/001.jpg | \n","ABBOTTS BABBLER | \n","Malacocincla abbotti | \n","train | \n","
1 | \n","0 | \n","train/ABBOTTS BABBLER/002.jpg | \n","ABBOTTS BABBLER | \n","Malacocincla abbotti | \n","train | \n","
2 | \n","0 | \n","train/ABBOTTS BABBLER/003.jpg | \n","ABBOTTS BABBLER | \n","Malacocincla abbotti | \n","train | \n","
3 | \n","0 | \n","train/ABBOTTS BABBLER/004.jpg | \n","ABBOTTS BABBLER | \n","Malacocincla abbotti | \n","train | \n","
4 | \n","0 | \n","train/ABBOTTS BABBLER/005.jpg | \n","ABBOTTS BABBLER | \n","Malacocincla abbotti | \n","train | \n","