{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["# Feature Extraction"],"metadata":{"id":"ZwcjPKTRf88I"}},{"cell_type":"code","execution_count":null,"metadata":{"id":"TU2H_jK-2tUV"},"outputs":[],"source":["import pandas as pd\n","from glob import glob\n","import matplotlib.pyplot as plt\n","import cv2\n","import numpy as np\n","import os\n","from tqdm.auto import tqdm\n","import shutil\n","\n","# path for current files\n","BASE_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY\"\n","DATA_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/shared/data\"\n","\n","# paths for future data\n","DATA_MASK_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask\"\n","DATA_CROPPED_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/data_cropped\"\n","DATA_CROPPED_WB_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/data_cropped_wb\"\n","FEATURES_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/features\"\n","FEATURES_WB_PATH = \"/content/drive/MyDrive/AI_DM_ECOLOGY/features_wb\"\n","\n","! cp /content/drive/MyDrive/AI_DM_ECOLOGY/shared/code/utils.py ."]},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"kQnm4toJcRhb","outputId":"23af7b1b-19d7-4576-aaf5-e3fb1d139350"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n"]}]},{"cell_type":"code","source":["df = pd.read_csv(DATA_PATH+\"/info.csv\")\n","df"],"metadata":{"id":"1nGSJKJT8zFx","colab":{"base_uri":"https://localhost:8080/","height":1000},"outputId":"c1dbe89e-1462-4d16-b6fd-2aff78db6bb3"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":[" img_id img_name label location\n","0 0 0000.jpg 0 0\n","1 1 0001.jpg 0 0\n","2 2 0002.jpg 0 0\n","3 3 0003.jpg 0 0\n","4 4 0004.jpg 0 0\n","... ... ... ... ...\n","1614 1614 1614.jpg 1 22\n","1615 1615 1615.jpg 1 22\n","1616 1616 1616.jpg 1 22\n","1617 1617 1617.jpg 1 22\n","1618 1618 1618.jpg 1 22\n","\n","[1619 rows x 4 columns]"],"text/html":["\n","
| \n"," | img_id | \n","img_name | \n","label | \n","location | \n","
|---|---|---|---|---|
| 0 | \n","0 | \n","0000.jpg | \n","0 | \n","0 | \n","
| 1 | \n","1 | \n","0001.jpg | \n","0 | \n","0 | \n","
| 2 | \n","2 | \n","0002.jpg | \n","0 | \n","0 | \n","
| 3 | \n","3 | \n","0003.jpg | \n","0 | \n","0 | \n","
| 4 | \n","4 | \n","0004.jpg | \n","0 | \n","0 | \n","
| ... | \n","... | \n","... | \n","... | \n","... | \n","
| 1614 | \n","1614 | \n","1614.jpg | \n","1 | \n","22 | \n","
| 1615 | \n","1615 | \n","1615.jpg | \n","1 | \n","22 | \n","
| 1616 | \n","1616 | \n","1616.jpg | \n","1 | \n","22 | \n","
| 1617 | \n","1617 | \n","1617.jpg | \n","1 | \n","22 | \n","
| 1618 | \n","1618 | \n","1618.jpg | \n","1 | \n","22 | \n","
1619 rows × 4 columns
\n","| \n"," | img_id | \n","img_name | \n","label | \n","location | \n","path | \n","
|---|---|---|---|---|---|
| 0 | \n","0 | \n","0000.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 1 | \n","1 | \n","0001.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 2 | \n","2 | \n","0002.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 3 | \n","3 | \n","0003.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 4 | \n","4 | \n","0004.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| ... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","
| 1614 | \n","1614 | \n","1614.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 1615 | \n","1615 | \n","1615.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 1616 | \n","1616 | \n","1616.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 1617 | \n","1617 | \n","1617.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
| 1618 | \n","1618 | \n","1618.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","
1619 rows × 5 columns
\n","| \n"," | ch0 | \n","
|---|---|
| 0 | \n","NaN | \n","
| 1 | \n","NaN | \n","
| 2 | \n","NaN | \n","
| 3 | \n","NaN | \n","
| 4 | \n","NaN | \n","
| ... | \n","... | \n","
| 251 | \n","0.000801 | \n","
| 252 | \n","0.001612 | \n","
| 253 | \n","0.002196 | \n","
| 254 | \n","0.005746 | \n","
| 255 | \n","0.400245 | \n","
256 rows × 1 columns
\n","| \n"," | img_id | \n","img_name | \n","label | \n","location | \n","path | \n","cropped_path | \n","mask_path | \n","
|---|---|---|---|---|---|---|---|
| 0 | \n","0 | \n","0000.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 1 | \n","1 | \n","0001.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 2 | \n","2 | \n","0002.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 3 | \n","3 | \n","0003.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 4 | \n","4 | \n","0004.jpg | \n","0 | \n","0 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| ... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","
| 1614 | \n","1614 | \n","1614.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 1615 | \n","1615 | \n","1615.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 1616 | \n","1616 | \n","1616.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 1617 | \n","1617 | \n","1617.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
| 1618 | \n","1618 | \n","1618.jpg | \n","1 | \n","22 | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/shared/da... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_crop... | \n","/content/drive/MyDrive/AI_DM_ECOLOGY/data_mask... | \n","
1619 rows × 7 columns
\n","