{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":127282,"databundleVersionId":15520105,"isSourceIdPinned":false,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"# Individual Differences in AnimalCLEF26","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport random\nimport os\nimport cv2\nimport matplotlib.pyplot as plt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:48:53.707151Z","iopub.execute_input":"2025-03-19T16:48:53.707489Z","iopub.status.idle":"2025-03-19T16:48:53.711853Z","shell.execute_reply.started":"2025-03-19T16:48:53.707462Z","shell.execute_reply":"2025-03-19T16:48:53.710711Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/competitions/animal-clef-2026/metadata.csv')\nprint(df.columns.tolist())\ndisplay(df[0:2].T)\nprint(df['dataset'].unique().tolist())\ncols=['identity', 'path',  'dataset']\ndf=df[cols]\ndir0='/kaggle/input/competitions/animal-clef-2026'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:48:53.713194Z","iopub.execute_input":"2025-03-19T16:48:53.713499Z","iopub.status.idle":"2025-03-19T16:48:53.781571Z","shell.execute_reply.started":"2025-03-19T16:48:53.713475Z","shell.execute_reply":"2025-03-19T16:48:53.780581Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def dataset2show16(df0,dataset):\n    \n    df=df0[df0['dataset']==dataset]\n    names0 = df['identity'].value_counts()\n    valid_names = names0[names0 >= 4].index.tolist()\n    names = random.sample(valid_names, 8)\n    \n    selected_images = []\n    grouped_images = {}  # Dictionary to store images grouped by name\n    for name in names:\n        paths = df[df['identity'] == name]['path'].tolist()\n        paths2 = random.sample(paths, 4)  # Select 4 random images per individual\n        grouped_images[name] = [os.path.join(dir0, p) for p in paths2]\n    \n    fig, axes = plt.subplots(8, 4, figsize=(10, 20))\n    \n    for row, (name, images) in enumerate(grouped_images.items()):\n        # Set row title\n        axes[row, 0].set_title(name, fontsize=12, loc='left', pad=10)\n        \n        for col, img_path in enumerate(images):\n            img = cv2.imread(img_path)\n            if img is not None:\n                img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)  # Convert BGR to RGB for correct colors\n                axes[row, col].imshow(img)\n            axes[row, col].axis(\"off\")\n    \n    plt.tight_layout()\n    plt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:48:53.783863Z","iopub.execute_input":"2025-03-19T16:48:53.784165Z","iopub.status.idle":"2025-03-19T16:48:53.791773Z","shell.execute_reply.started":"2025-03-19T16:48:53.78414Z","shell.execute_reply":"2025-03-19T16:48:53.790444Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset2show16(df,'LynxID2025')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:48:53.79332Z","iopub.execute_input":"2025-03-19T16:48:53.793714Z","iopub.status.idle":"2025-03-19T16:49:01.550259Z","shell.execute_reply.started":"2025-03-19T16:48:53.793674Z","shell.execute_reply":"2025-03-19T16:49:01.54905Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset2show16(df,'SalamanderID2025')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:49:01.551401Z","iopub.execute_input":"2025-03-19T16:49:01.551821Z","iopub.status.idle":"2025-03-19T16:49:07.030583Z","shell.execute_reply.started":"2025-03-19T16:49:01.551781Z","shell.execute_reply":"2025-03-19T16:49:07.028784Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset2show16(df,'SeaTurtleID2022')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-19T16:49:07.031788Z","iopub.execute_input":"2025-03-19T16:49:07.032117Z","iopub.status.idle":"2025-03-19T16:49:08.273229Z","shell.execute_reply.started":"2025-03-19T16:49:07.032087Z","shell.execute_reply":"2025-03-19T16:49:08.271641Z"}},"outputs":[],"execution_count":null}]}