{"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":91448,"databundleVersionId":11249847,"isSourceIdPinned":false,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Fungi Photo Gallery","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport random\nimport os\nimport cv2\nimport matplotlib.pyplot as plt\nimport requests","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-20T06:22:01.662879Z","iopub.execute_input":"2025-03-20T06:22:01.663251Z","iopub.status.idle":"2025-03-20T06:22:01.668414Z","shell.execute_reply.started":"2025-03-20T06:22:01.663223Z","shell.execute_reply":"2025-03-20T06:22:01.667117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/fungi-clef-2025/metadata/FungiTastic-FewShot/FungiTastic-FewShot-Train.csv',sep=',')\nprint(df.columns.tolist())\ndisplay(df[0:2].T)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-20T06:22:01.669862Z","iopub.execute_input":"2025-03-20T06:22:01.670162Z","iopub.status.idle":"2025-03-20T06:22:01.763648Z","shell.execute_reply.started":"2025-03-20T06:22:01.670137Z","shell.execute_reply":"2025-03-20T06:22:01.762404Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dir0='/kaggle/input/fungi-clef-2025/images/FungiTastic-FewShot/train/720p'\ncols=['species', 'filename']\ndf=df[cols]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-20T06:22:01.765901Z","iopub.execute_input":"2025-03-20T06:22:01.766226Z","iopub.status.idle":"2025-03-20T06:22:01.774447Z","shell.execute_reply.started":"2025-03-20T06:22:01.766199Z","shell.execute_reply":"2025-03-20T06:22:01.773137Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def dataset2show16(df):\n\n    names0 = df['species'].value_counts()\n    valid_names = names0[names0 >= 4].index.tolist()\n    names = random.sample(valid_names,16)\n    \n    selected_images = []\n    grouped_images = {}  # Dictionary to store images grouped by name\n    for name in names:\n        paths = df[df['species'] == name]['filename'].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(16, 4, figsize=(10, 40))\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        axes[row, 0].annotate(name, xy=(0, 1), xycoords=\"axes fraction\",fontsize=12, ha=\"left\", va=\"bottom\")\n        \n        for col, path in enumerate(images):\n            img = cv2.imread(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-20T06:22:01.775829Z","iopub.execute_input":"2025-03-20T06:22:01.776206Z","iopub.status.idle":"2025-03-20T06:22:01.798347Z","shell.execute_reply.started":"2025-03-20T06:22:01.776168Z","shell.execute_reply":"2025-03-20T06:22:01.797201Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset2show16(df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-20T06:22:01.799484Z","iopub.execute_input":"2025-03-20T06:22:01.799821Z","iopub.status.idle":"2025-03-20T06:22:09.853136Z","shell.execute_reply.started":"2025-03-20T06:22:01.799788Z","shell.execute_reply":"2025-03-20T06:22:09.851267Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}