Datasets:
remove checksum duplicates (incl. mislabel)
Browse filesOne image was duplicated with two different labels and both copies were removed
notebooks/lilabc_test-ohio-small-animal.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [],
|
| 8 |
"source": [
|
|
@@ -1739,6 +1739,594 @@
|
|
| 1739 |
"Rerun the balanced set part as well."
|
| 1740 |
]
|
| 1741 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1742 |
{
|
| 1743 |
"cell_type": "code",
|
| 1744 |
"execution_count": null,
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 12,
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [],
|
| 8 |
"source": [
|
|
|
|
| 1739 |
"Rerun the balanced set part as well."
|
| 1740 |
]
|
| 1741 |
},
|
| 1742 |
+
{
|
| 1743 |
+
"cell_type": "markdown",
|
| 1744 |
+
"metadata": {},
|
| 1745 |
+
"source": [
|
| 1746 |
+
"## After download, duplicate images were detected\n",
|
| 1747 |
+
"\n",
|
| 1748 |
+
"Need to analyze and remove."
|
| 1749 |
+
]
|
| 1750 |
+
},
|
| 1751 |
+
{
|
| 1752 |
+
"cell_type": "code",
|
| 1753 |
+
"execution_count": 13,
|
| 1754 |
+
"metadata": {},
|
| 1755 |
+
"outputs": [],
|
| 1756 |
+
"source": [
|
| 1757 |
+
"df = pd.read_csv(\"../data/potential-test-sets/filtered/ohio-small-animals-upper-bound.csv\", low_memory=False)\n",
|
| 1758 |
+
"df_checksums = pd.read_csv(\"../data/potential-test-sets/filtered/ohio-small-animals-upper-bound_checksums.csv\", low_memory=False)"
|
| 1759 |
+
]
|
| 1760 |
+
},
|
| 1761 |
+
{
|
| 1762 |
+
"cell_type": "code",
|
| 1763 |
+
"execution_count": 14,
|
| 1764 |
+
"metadata": {},
|
| 1765 |
+
"outputs": [
|
| 1766 |
+
{
|
| 1767 |
+
"name": "stdout",
|
| 1768 |
+
"output_type": "stream",
|
| 1769 |
+
"text": [
|
| 1770 |
+
"70848 70848\n",
|
| 1771 |
+
"70848 filename 70848\n",
|
| 1772 |
+
"md5 70836\n",
|
| 1773 |
+
"dtype: int64\n"
|
| 1774 |
+
]
|
| 1775 |
+
}
|
| 1776 |
+
],
|
| 1777 |
+
"source": [
|
| 1778 |
+
"print(df.shape[0], df[\"filename\"].nunique())\n",
|
| 1779 |
+
"print(df_checksums.shape[0], df_checksums[[\"filename\", \"md5\"]].nunique())"
|
| 1780 |
+
]
|
| 1781 |
+
},
|
| 1782 |
+
{
|
| 1783 |
+
"cell_type": "code",
|
| 1784 |
+
"execution_count": 15,
|
| 1785 |
+
"metadata": {},
|
| 1786 |
+
"outputs": [
|
| 1787 |
+
{
|
| 1788 |
+
"data": {
|
| 1789 |
+
"text/plain": [
|
| 1790 |
+
"(70848, 22)"
|
| 1791 |
+
]
|
| 1792 |
+
},
|
| 1793 |
+
"execution_count": 15,
|
| 1794 |
+
"metadata": {},
|
| 1795 |
+
"output_type": "execute_result"
|
| 1796 |
+
}
|
| 1797 |
+
],
|
| 1798 |
+
"source": [
|
| 1799 |
+
"df_full = pd.merge(df,\n",
|
| 1800 |
+
" df_checksums,\n",
|
| 1801 |
+
" on = \"filename\",\n",
|
| 1802 |
+
" how = \"inner\"\n",
|
| 1803 |
+
" )\n",
|
| 1804 |
+
"df_full.shape"
|
| 1805 |
+
]
|
| 1806 |
+
},
|
| 1807 |
+
{
|
| 1808 |
+
"cell_type": "code",
|
| 1809 |
+
"execution_count": 17,
|
| 1810 |
+
"metadata": {},
|
| 1811 |
+
"outputs": [
|
| 1812 |
+
{
|
| 1813 |
+
"data": {
|
| 1814 |
+
"text/plain": [
|
| 1815 |
+
"scientific_name\n",
|
| 1816 |
+
"coluber constrictor 12\n",
|
| 1817 |
+
"thamnophis sirtalis sirtalis 10\n",
|
| 1818 |
+
"peromyscus leucopus 1\n",
|
| 1819 |
+
"napaeozapus insignis 1\n",
|
| 1820 |
+
"Name: count, dtype: int64"
|
| 1821 |
+
]
|
| 1822 |
+
},
|
| 1823 |
+
"execution_count": 17,
|
| 1824 |
+
"metadata": {},
|
| 1825 |
+
"output_type": "execute_result"
|
| 1826 |
+
}
|
| 1827 |
+
],
|
| 1828 |
+
"source": [
|
| 1829 |
+
"df_full[\"dupe_img\"] = df_full.duplicated([\"md5\"], keep = False)\n",
|
| 1830 |
+
"df_full.loc[df_full[\"dupe_img\"], \"scientific_name\"].value_counts()"
|
| 1831 |
+
]
|
| 1832 |
+
},
|
| 1833 |
+
{
|
| 1834 |
+
"cell_type": "markdown",
|
| 1835 |
+
"metadata": {},
|
| 1836 |
+
"source": [
|
| 1837 |
+
"Do these have conflicting labels?\n",
|
| 1838 |
+
"\n",
|
| 1839 |
+
"It would seem so, since [napaeozapus insignis](https://eol.org/pages/328468) and [peromyscus leucopus](https://eol.org/pages/310653) are quite similar in appearance (little brown mice)."
|
| 1840 |
+
]
|
| 1841 |
+
},
|
| 1842 |
+
{
|
| 1843 |
+
"cell_type": "code",
|
| 1844 |
+
"execution_count": 19,
|
| 1845 |
+
"metadata": {},
|
| 1846 |
+
"outputs": [
|
| 1847 |
+
{
|
| 1848 |
+
"data": {
|
| 1849 |
+
"text/plain": [
|
| 1850 |
+
"array(['58e0d98fdc5bbe326a0dfb0656b5910b',\n",
|
| 1851 |
+
" '58e0d98fdc5bbe326a0dfb0656b5910b'], dtype=object)"
|
| 1852 |
+
]
|
| 1853 |
+
},
|
| 1854 |
+
"execution_count": 19,
|
| 1855 |
+
"metadata": {},
|
| 1856 |
+
"output_type": "execute_result"
|
| 1857 |
+
}
|
| 1858 |
+
],
|
| 1859 |
+
"source": [
|
| 1860 |
+
"df_full.loc[(df_full[\"dupe_img\"]) & (df_full[\"scientific_name\"].isin([\"napaeozapus insignis\", \"peromyscus leucopus\"])), \"md5\"].values"
|
| 1861 |
+
]
|
| 1862 |
+
},
|
| 1863 |
+
{
|
| 1864 |
+
"cell_type": "code",
|
| 1865 |
+
"execution_count": 20,
|
| 1866 |
+
"metadata": {},
|
| 1867 |
+
"outputs": [
|
| 1868 |
+
{
|
| 1869 |
+
"data": {
|
| 1870 |
+
"text/plain": [
|
| 1871 |
+
"array(['http://us-west-2.opendata.source.coop.s3.amazonaws.com/agentmorris/lila-wildlife/osu-small-animals/Images/Sorted_by_species/Mammalia/White-footed Mouse/YWS3_peromyscus_leucopus (37).JPG',\n",
|
| 1872 |
+
" 'http://us-west-2.opendata.source.coop.s3.amazonaws.com/agentmorris/lila-wildlife/osu-small-animals/Images/Sorted_by_species/Mammalia/Woodland Jumping Mouse/YWS3_napaeozapus_insignis (5).JPG'],\n",
|
| 1873 |
+
" dtype=object)"
|
| 1874 |
+
]
|
| 1875 |
+
},
|
| 1876 |
+
"execution_count": 20,
|
| 1877 |
+
"metadata": {},
|
| 1878 |
+
"output_type": "execute_result"
|
| 1879 |
+
}
|
| 1880 |
+
],
|
| 1881 |
+
"source": [
|
| 1882 |
+
"df_full.loc[(df_full[\"dupe_img\"]) & (df_full[\"scientific_name\"].isin([\"napaeozapus insignis\", \"peromyscus leucopus\"])), \"url_aws\"].values"
|
| 1883 |
+
]
|
| 1884 |
+
},
|
| 1885 |
+
{
|
| 1886 |
+
"cell_type": "code",
|
| 1887 |
+
"execution_count": 18,
|
| 1888 |
+
"metadata": {},
|
| 1889 |
+
"outputs": [
|
| 1890 |
+
{
|
| 1891 |
+
"data": {
|
| 1892 |
+
"text/plain": [
|
| 1893 |
+
"scientific_name\n",
|
| 1894 |
+
"peromyscus leucopus 10000\n",
|
| 1895 |
+
"thamnophis sirtalis sirtalis 10000\n",
|
| 1896 |
+
"napaeozapus insignis 1510\n",
|
| 1897 |
+
"coluber constrictor 293\n",
|
| 1898 |
+
"Name: count, dtype: int64"
|
| 1899 |
+
]
|
| 1900 |
+
},
|
| 1901 |
+
"execution_count": 18,
|
| 1902 |
+
"metadata": {},
|
| 1903 |
+
"output_type": "execute_result"
|
| 1904 |
+
}
|
| 1905 |
+
],
|
| 1906 |
+
"source": [
|
| 1907 |
+
"duplicated_sci_names = [\"coluber constrictor\",\n",
|
| 1908 |
+
" \"thamnophis sirtalis sirtalis\",\n",
|
| 1909 |
+
" \"peromyscus leucopus\",\n",
|
| 1910 |
+
" \"napaeozapus insignis\"]\n",
|
| 1911 |
+
"df_full.loc[df_full[\"scientific_name\"].isin(duplicated_sci_names), \"scientific_name\"].value_counts()"
|
| 1912 |
+
]
|
| 1913 |
+
},
|
| 1914 |
+
{
|
| 1915 |
+
"cell_type": "markdown",
|
| 1916 |
+
"metadata": {},
|
| 1917 |
+
"source": [
|
| 1918 |
+
"They are all well-enough represented to still be in all datasets if we remove the duplicates. We'll drop both mice since we don't know which is the correct species classification ([image](http://us-west-2.opendata.source.coop.s3.amazonaws.com/agentmorris/lila-wildlife/osu-small-animals/Images/Sorted_by_species/Mammalia/White-footed%20Mouse/YWS3_peromyscus_leucopus%20(37).JPG) is basically a tail)."
|
| 1919 |
+
]
|
| 1920 |
+
},
|
| 1921 |
+
{
|
| 1922 |
+
"cell_type": "code",
|
| 1923 |
+
"execution_count": 22,
|
| 1924 |
+
"metadata": {},
|
| 1925 |
+
"outputs": [
|
| 1926 |
+
{
|
| 1927 |
+
"data": {
|
| 1928 |
+
"text/plain": [
|
| 1929 |
+
"(70846, 23)"
|
| 1930 |
+
]
|
| 1931 |
+
},
|
| 1932 |
+
"execution_count": 22,
|
| 1933 |
+
"metadata": {},
|
| 1934 |
+
"output_type": "execute_result"
|
| 1935 |
+
}
|
| 1936 |
+
],
|
| 1937 |
+
"source": [
|
| 1938 |
+
"df_filter = df_full.loc[df_full[\"md5\"] != '58e0d98fdc5bbe326a0dfb0656b5910b'].copy()\n",
|
| 1939 |
+
"df_filter.shape"
|
| 1940 |
+
]
|
| 1941 |
+
},
|
| 1942 |
+
{
|
| 1943 |
+
"cell_type": "code",
|
| 1944 |
+
"execution_count": 23,
|
| 1945 |
+
"metadata": {},
|
| 1946 |
+
"outputs": [
|
| 1947 |
+
{
|
| 1948 |
+
"data": {
|
| 1949 |
+
"text/plain": [
|
| 1950 |
+
"(70835, 23)"
|
| 1951 |
+
]
|
| 1952 |
+
},
|
| 1953 |
+
"execution_count": 23,
|
| 1954 |
+
"metadata": {},
|
| 1955 |
+
"output_type": "execute_result"
|
| 1956 |
+
}
|
| 1957 |
+
],
|
| 1958 |
+
"source": [
|
| 1959 |
+
"df_filter[\"dupe_img\"] = df_filter.duplicated([\"md5\"], keep = \"first\")\n",
|
| 1960 |
+
"df_reduced = df_filter.loc[~df_filter[\"dupe_img\"]].copy()\n",
|
| 1961 |
+
"df_reduced.shape"
|
| 1962 |
+
]
|
| 1963 |
+
},
|
| 1964 |
+
{
|
| 1965 |
+
"cell_type": "code",
|
| 1966 |
+
"execution_count": 27,
|
| 1967 |
+
"metadata": {},
|
| 1968 |
+
"outputs": [
|
| 1969 |
+
{
|
| 1970 |
+
"data": {
|
| 1971 |
+
"text/plain": [
|
| 1972 |
+
"Index(['dataset_name', 'url_gcp', 'url_aws', 'url_azure', 'image_id',\n",
|
| 1973 |
+
" 'sequence_id', 'location_id', 'frame_num', 'original_label',\n",
|
| 1974 |
+
" 'scientific_name', 'common_name', 'kingdom', 'phylum', 'class', 'order',\n",
|
| 1975 |
+
" 'family', 'genus', 'species', 'num_sp_images', 'filename', 'filepath',\n",
|
| 1976 |
+
" 'md5', 'dupe_img'],\n",
|
| 1977 |
+
" dtype='object')"
|
| 1978 |
+
]
|
| 1979 |
+
},
|
| 1980 |
+
"execution_count": 27,
|
| 1981 |
+
"metadata": {},
|
| 1982 |
+
"output_type": "execute_result"
|
| 1983 |
+
}
|
| 1984 |
+
],
|
| 1985 |
+
"source": [
|
| 1986 |
+
"df_reduced.columns"
|
| 1987 |
+
]
|
| 1988 |
+
},
|
| 1989 |
+
{
|
| 1990 |
+
"cell_type": "markdown",
|
| 1991 |
+
"metadata": {},
|
| 1992 |
+
"source": [
|
| 1993 |
+
"Update Number of Species images counts"
|
| 1994 |
+
]
|
| 1995 |
+
},
|
| 1996 |
+
{
|
| 1997 |
+
"cell_type": "code",
|
| 1998 |
+
"execution_count": 28,
|
| 1999 |
+
"metadata": {},
|
| 2000 |
+
"outputs": [],
|
| 2001 |
+
"source": [
|
| 2002 |
+
"for sci_name in duplicated_sci_names:\n",
|
| 2003 |
+
" df_reduced.loc[df_reduced[\"scientific_name\"] == sci_name, \"num_sp_images\"] = df_reduced.loc[df_reduced[\"scientific_name\"] == sci_name].shape[0]"
|
| 2004 |
+
]
|
| 2005 |
+
},
|
| 2006 |
+
{
|
| 2007 |
+
"cell_type": "markdown",
|
| 2008 |
+
"metadata": {},
|
| 2009 |
+
"source": [
|
| 2010 |
+
"#### Now save and reduce other two files\n",
|
| 2011 |
+
"Don't need the `dupe_img` column."
|
| 2012 |
+
]
|
| 2013 |
+
},
|
| 2014 |
+
{
|
| 2015 |
+
"cell_type": "code",
|
| 2016 |
+
"execution_count": 29,
|
| 2017 |
+
"metadata": {},
|
| 2018 |
+
"outputs": [
|
| 2019 |
+
{
|
| 2020 |
+
"data": {
|
| 2021 |
+
"text/html": [
|
| 2022 |
+
"<div>\n",
|
| 2023 |
+
"<style scoped>\n",
|
| 2024 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 2025 |
+
" vertical-align: middle;\n",
|
| 2026 |
+
" }\n",
|
| 2027 |
+
"\n",
|
| 2028 |
+
" .dataframe tbody tr th {\n",
|
| 2029 |
+
" vertical-align: top;\n",
|
| 2030 |
+
" }\n",
|
| 2031 |
+
"\n",
|
| 2032 |
+
" .dataframe thead th {\n",
|
| 2033 |
+
" text-align: right;\n",
|
| 2034 |
+
" }\n",
|
| 2035 |
+
"</style>\n",
|
| 2036 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 2037 |
+
" <thead>\n",
|
| 2038 |
+
" <tr style=\"text-align: right;\">\n",
|
| 2039 |
+
" <th></th>\n",
|
| 2040 |
+
" <th>dataset_name</th>\n",
|
| 2041 |
+
" <th>url_gcp</th>\n",
|
| 2042 |
+
" <th>url_aws</th>\n",
|
| 2043 |
+
" <th>url_azure</th>\n",
|
| 2044 |
+
" <th>image_id</th>\n",
|
| 2045 |
+
" <th>sequence_id</th>\n",
|
| 2046 |
+
" <th>location_id</th>\n",
|
| 2047 |
+
" <th>frame_num</th>\n",
|
| 2048 |
+
" <th>original_label</th>\n",
|
| 2049 |
+
" <th>scientific_name</th>\n",
|
| 2050 |
+
" <th>...</th>\n",
|
| 2051 |
+
" <th>phylum</th>\n",
|
| 2052 |
+
" <th>class</th>\n",
|
| 2053 |
+
" <th>order</th>\n",
|
| 2054 |
+
" <th>family</th>\n",
|
| 2055 |
+
" <th>genus</th>\n",
|
| 2056 |
+
" <th>species</th>\n",
|
| 2057 |
+
" <th>num_sp_images</th>\n",
|
| 2058 |
+
" <th>filename</th>\n",
|
| 2059 |
+
" <th>filepath</th>\n",
|
| 2060 |
+
" <th>md5</th>\n",
|
| 2061 |
+
" </tr>\n",
|
| 2062 |
+
" </thead>\n",
|
| 2063 |
+
" <tbody>\n",
|
| 2064 |
+
" <tr>\n",
|
| 2065 |
+
" <th>0</th>\n",
|
| 2066 |
+
" <td>Ohio Small Animals</td>\n",
|
| 2067 |
+
" <td>https://storage.googleapis.com/public-datasets...</td>\n",
|
| 2068 |
+
" <td>http://us-west-2.opendata.source.coop.s3.amazo...</td>\n",
|
| 2069 |
+
" <td>https://lilawildlife.blob.core.windows.net/lil...</td>\n",
|
| 2070 |
+
" <td>Ohio Small Animals : Images/Sorted_by_species/...</td>\n",
|
| 2071 |
+
" <td>Ohio Small Animals : location_BIWA3N_sequence_...</td>\n",
|
| 2072 |
+
" <td>Ohio Small Animals : BIWA3N</td>\n",
|
| 2073 |
+
" <td>0</td>\n",
|
| 2074 |
+
" <td>american_bullfrog</td>\n",
|
| 2075 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2076 |
+
" <td>...</td>\n",
|
| 2077 |
+
" <td>chordata</td>\n",
|
| 2078 |
+
" <td>amphibia</td>\n",
|
| 2079 |
+
" <td>anura</td>\n",
|
| 2080 |
+
" <td>ranidae</td>\n",
|
| 2081 |
+
" <td>lithobates</td>\n",
|
| 2082 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2083 |
+
" <td>12.0</td>\n",
|
| 2084 |
+
" <td>OH_sm_animals_BIWA3N_2020-07-12_06-50-28.JPG</td>\n",
|
| 2085 |
+
" <td>ohio-small-animals/lithobates catesbeianus/OH_...</td>\n",
|
| 2086 |
+
" <td>8dfcd2f7cf855b94c191baead05b904e</td>\n",
|
| 2087 |
+
" </tr>\n",
|
| 2088 |
+
" <tr>\n",
|
| 2089 |
+
" <th>1</th>\n",
|
| 2090 |
+
" <td>Ohio Small Animals</td>\n",
|
| 2091 |
+
" <td>https://storage.googleapis.com/public-datasets...</td>\n",
|
| 2092 |
+
" <td>http://us-west-2.opendata.source.coop.s3.amazo...</td>\n",
|
| 2093 |
+
" <td>https://lilawildlife.blob.core.windows.net/lil...</td>\n",
|
| 2094 |
+
" <td>Ohio Small Animals : Images/Sorted_by_species/...</td>\n",
|
| 2095 |
+
" <td>Ohio Small Animals : location_BIWA3N_sequence_...</td>\n",
|
| 2096 |
+
" <td>Ohio Small Animals : BIWA3N</td>\n",
|
| 2097 |
+
" <td>1</td>\n",
|
| 2098 |
+
" <td>american_bullfrog</td>\n",
|
| 2099 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2100 |
+
" <td>...</td>\n",
|
| 2101 |
+
" <td>chordata</td>\n",
|
| 2102 |
+
" <td>amphibia</td>\n",
|
| 2103 |
+
" <td>anura</td>\n",
|
| 2104 |
+
" <td>ranidae</td>\n",
|
| 2105 |
+
" <td>lithobates</td>\n",
|
| 2106 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2107 |
+
" <td>12.0</td>\n",
|
| 2108 |
+
" <td>OH_sm_animals_BIWA3N_2020-07-12_06-50-29.JPG</td>\n",
|
| 2109 |
+
" <td>ohio-small-animals/lithobates catesbeianus/OH_...</td>\n",
|
| 2110 |
+
" <td>7fb71f74e311bcc59d12a6c1d3a5f564</td>\n",
|
| 2111 |
+
" </tr>\n",
|
| 2112 |
+
" <tr>\n",
|
| 2113 |
+
" <th>2</th>\n",
|
| 2114 |
+
" <td>Ohio Small Animals</td>\n",
|
| 2115 |
+
" <td>https://storage.googleapis.com/public-datasets...</td>\n",
|
| 2116 |
+
" <td>http://us-west-2.opendata.source.coop.s3.amazo...</td>\n",
|
| 2117 |
+
" <td>https://lilawildlife.blob.core.windows.net/lil...</td>\n",
|
| 2118 |
+
" <td>Ohio Small Animals : Images/Sorted_by_species/...</td>\n",
|
| 2119 |
+
" <td>Ohio Small Animals : location_BIWA3N_sequence_...</td>\n",
|
| 2120 |
+
" <td>Ohio Small Animals : BIWA3N</td>\n",
|
| 2121 |
+
" <td>2</td>\n",
|
| 2122 |
+
" <td>american_bullfrog</td>\n",
|
| 2123 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2124 |
+
" <td>...</td>\n",
|
| 2125 |
+
" <td>chordata</td>\n",
|
| 2126 |
+
" <td>amphibia</td>\n",
|
| 2127 |
+
" <td>anura</td>\n",
|
| 2128 |
+
" <td>ranidae</td>\n",
|
| 2129 |
+
" <td>lithobates</td>\n",
|
| 2130 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2131 |
+
" <td>12.0</td>\n",
|
| 2132 |
+
" <td>OH_sm_animals_BIWA3N_2020-07-12_06-50-30.JPG</td>\n",
|
| 2133 |
+
" <td>ohio-small-animals/lithobates catesbeianus/OH_...</td>\n",
|
| 2134 |
+
" <td>599fd8843e098432bb1664c4366b4844</td>\n",
|
| 2135 |
+
" </tr>\n",
|
| 2136 |
+
" <tr>\n",
|
| 2137 |
+
" <th>3</th>\n",
|
| 2138 |
+
" <td>Ohio Small Animals</td>\n",
|
| 2139 |
+
" <td>https://storage.googleapis.com/public-datasets...</td>\n",
|
| 2140 |
+
" <td>http://us-west-2.opendata.source.coop.s3.amazo...</td>\n",
|
| 2141 |
+
" <td>https://lilawildlife.blob.core.windows.net/lil...</td>\n",
|
| 2142 |
+
" <td>Ohio Small Animals : Images/Sorted_by_species/...</td>\n",
|
| 2143 |
+
" <td>Ohio Small Animals : location_BIWA4N_sequence_...</td>\n",
|
| 2144 |
+
" <td>Ohio Small Animals : BIWA4N</td>\n",
|
| 2145 |
+
" <td>0</td>\n",
|
| 2146 |
+
" <td>american_bullfrog</td>\n",
|
| 2147 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2148 |
+
" <td>...</td>\n",
|
| 2149 |
+
" <td>chordata</td>\n",
|
| 2150 |
+
" <td>amphibia</td>\n",
|
| 2151 |
+
" <td>anura</td>\n",
|
| 2152 |
+
" <td>ranidae</td>\n",
|
| 2153 |
+
" <td>lithobates</td>\n",
|
| 2154 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2155 |
+
" <td>12.0</td>\n",
|
| 2156 |
+
" <td>OH_sm_animals_BIWA4N_2020-07-20_02-03-45.JPG</td>\n",
|
| 2157 |
+
" <td>ohio-small-animals/lithobates catesbeianus/OH_...</td>\n",
|
| 2158 |
+
" <td>6f7e9e8c72d2bbd1af3118e6058f321f</td>\n",
|
| 2159 |
+
" </tr>\n",
|
| 2160 |
+
" <tr>\n",
|
| 2161 |
+
" <th>4</th>\n",
|
| 2162 |
+
" <td>Ohio Small Animals</td>\n",
|
| 2163 |
+
" <td>https://storage.googleapis.com/public-datasets...</td>\n",
|
| 2164 |
+
" <td>http://us-west-2.opendata.source.coop.s3.amazo...</td>\n",
|
| 2165 |
+
" <td>https://lilawildlife.blob.core.windows.net/lil...</td>\n",
|
| 2166 |
+
" <td>Ohio Small Animals : Images/Sorted_by_species/...</td>\n",
|
| 2167 |
+
" <td>Ohio Small Animals : location_BIWA4N_sequence_...</td>\n",
|
| 2168 |
+
" <td>Ohio Small Animals : BIWA4N</td>\n",
|
| 2169 |
+
" <td>1</td>\n",
|
| 2170 |
+
" <td>american_bullfrog</td>\n",
|
| 2171 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2172 |
+
" <td>...</td>\n",
|
| 2173 |
+
" <td>chordata</td>\n",
|
| 2174 |
+
" <td>amphibia</td>\n",
|
| 2175 |
+
" <td>anura</td>\n",
|
| 2176 |
+
" <td>ranidae</td>\n",
|
| 2177 |
+
" <td>lithobates</td>\n",
|
| 2178 |
+
" <td>lithobates catesbeianus</td>\n",
|
| 2179 |
+
" <td>12.0</td>\n",
|
| 2180 |
+
" <td>OH_sm_animals_BIWA4N_2020-07-20_02-03-46.JPG</td>\n",
|
| 2181 |
+
" <td>ohio-small-animals/lithobates catesbeianus/OH_...</td>\n",
|
| 2182 |
+
" <td>8e77e782f40299f3d202c48aa42d6be6</td>\n",
|
| 2183 |
+
" </tr>\n",
|
| 2184 |
+
" </tbody>\n",
|
| 2185 |
+
"</table>\n",
|
| 2186 |
+
"<p>5 rows × 22 columns</p>\n",
|
| 2187 |
+
"</div>"
|
| 2188 |
+
],
|
| 2189 |
+
"text/plain": [
|
| 2190 |
+
" dataset_name url_gcp \\\n",
|
| 2191 |
+
"0 Ohio Small Animals https://storage.googleapis.com/public-datasets... \n",
|
| 2192 |
+
"1 Ohio Small Animals https://storage.googleapis.com/public-datasets... \n",
|
| 2193 |
+
"2 Ohio Small Animals https://storage.googleapis.com/public-datasets... \n",
|
| 2194 |
+
"3 Ohio Small Animals https://storage.googleapis.com/public-datasets... \n",
|
| 2195 |
+
"4 Ohio Small Animals https://storage.googleapis.com/public-datasets... \n",
|
| 2196 |
+
"\n",
|
| 2197 |
+
" url_aws \\\n",
|
| 2198 |
+
"0 http://us-west-2.opendata.source.coop.s3.amazo... \n",
|
| 2199 |
+
"1 http://us-west-2.opendata.source.coop.s3.amazo... \n",
|
| 2200 |
+
"2 http://us-west-2.opendata.source.coop.s3.amazo... \n",
|
| 2201 |
+
"3 http://us-west-2.opendata.source.coop.s3.amazo... \n",
|
| 2202 |
+
"4 http://us-west-2.opendata.source.coop.s3.amazo... \n",
|
| 2203 |
+
"\n",
|
| 2204 |
+
" url_azure \\\n",
|
| 2205 |
+
"0 https://lilawildlife.blob.core.windows.net/lil... \n",
|
| 2206 |
+
"1 https://lilawildlife.blob.core.windows.net/lil... \n",
|
| 2207 |
+
"2 https://lilawildlife.blob.core.windows.net/lil... \n",
|
| 2208 |
+
"3 https://lilawildlife.blob.core.windows.net/lil... \n",
|
| 2209 |
+
"4 https://lilawildlife.blob.core.windows.net/lil... \n",
|
| 2210 |
+
"\n",
|
| 2211 |
+
" image_id \\\n",
|
| 2212 |
+
"0 Ohio Small Animals : Images/Sorted_by_species/... \n",
|
| 2213 |
+
"1 Ohio Small Animals : Images/Sorted_by_species/... \n",
|
| 2214 |
+
"2 Ohio Small Animals : Images/Sorted_by_species/... \n",
|
| 2215 |
+
"3 Ohio Small Animals : Images/Sorted_by_species/... \n",
|
| 2216 |
+
"4 Ohio Small Animals : Images/Sorted_by_species/... \n",
|
| 2217 |
+
"\n",
|
| 2218 |
+
" sequence_id \\\n",
|
| 2219 |
+
"0 Ohio Small Animals : location_BIWA3N_sequence_... \n",
|
| 2220 |
+
"1 Ohio Small Animals : location_BIWA3N_sequence_... \n",
|
| 2221 |
+
"2 Ohio Small Animals : location_BIWA3N_sequence_... \n",
|
| 2222 |
+
"3 Ohio Small Animals : location_BIWA4N_sequence_... \n",
|
| 2223 |
+
"4 Ohio Small Animals : location_BIWA4N_sequence_... \n",
|
| 2224 |
+
"\n",
|
| 2225 |
+
" location_id frame_num original_label \\\n",
|
| 2226 |
+
"0 Ohio Small Animals : BIWA3N 0 american_bullfrog \n",
|
| 2227 |
+
"1 Ohio Small Animals : BIWA3N 1 american_bullfrog \n",
|
| 2228 |
+
"2 Ohio Small Animals : BIWA3N 2 american_bullfrog \n",
|
| 2229 |
+
"3 Ohio Small Animals : BIWA4N 0 american_bullfrog \n",
|
| 2230 |
+
"4 Ohio Small Animals : BIWA4N 1 american_bullfrog \n",
|
| 2231 |
+
"\n",
|
| 2232 |
+
" scientific_name ... phylum class order family \\\n",
|
| 2233 |
+
"0 lithobates catesbeianus ... chordata amphibia anura ranidae \n",
|
| 2234 |
+
"1 lithobates catesbeianus ... chordata amphibia anura ranidae \n",
|
| 2235 |
+
"2 lithobates catesbeianus ... chordata amphibia anura ranidae \n",
|
| 2236 |
+
"3 lithobates catesbeianus ... chordata amphibia anura ranidae \n",
|
| 2237 |
+
"4 lithobates catesbeianus ... chordata amphibia anura ranidae \n",
|
| 2238 |
+
"\n",
|
| 2239 |
+
" genus species num_sp_images \\\n",
|
| 2240 |
+
"0 lithobates lithobates catesbeianus 12.0 \n",
|
| 2241 |
+
"1 lithobates lithobates catesbeianus 12.0 \n",
|
| 2242 |
+
"2 lithobates lithobates catesbeianus 12.0 \n",
|
| 2243 |
+
"3 lithobates lithobates catesbeianus 12.0 \n",
|
| 2244 |
+
"4 lithobates lithobates catesbeianus 12.0 \n",
|
| 2245 |
+
"\n",
|
| 2246 |
+
" filename \\\n",
|
| 2247 |
+
"0 OH_sm_animals_BIWA3N_2020-07-12_06-50-28.JPG \n",
|
| 2248 |
+
"1 OH_sm_animals_BIWA3N_2020-07-12_06-50-29.JPG \n",
|
| 2249 |
+
"2 OH_sm_animals_BIWA3N_2020-07-12_06-50-30.JPG \n",
|
| 2250 |
+
"3 OH_sm_animals_BIWA4N_2020-07-20_02-03-45.JPG \n",
|
| 2251 |
+
"4 OH_sm_animals_BIWA4N_2020-07-20_02-03-46.JPG \n",
|
| 2252 |
+
"\n",
|
| 2253 |
+
" filepath \\\n",
|
| 2254 |
+
"0 ohio-small-animals/lithobates catesbeianus/OH_... \n",
|
| 2255 |
+
"1 ohio-small-animals/lithobates catesbeianus/OH_... \n",
|
| 2256 |
+
"2 ohio-small-animals/lithobates catesbeianus/OH_... \n",
|
| 2257 |
+
"3 ohio-small-animals/lithobates catesbeianus/OH_... \n",
|
| 2258 |
+
"4 ohio-small-animals/lithobates catesbeianus/OH_... \n",
|
| 2259 |
+
"\n",
|
| 2260 |
+
" md5 \n",
|
| 2261 |
+
"0 8dfcd2f7cf855b94c191baead05b904e \n",
|
| 2262 |
+
"1 7fb71f74e311bcc59d12a6c1d3a5f564 \n",
|
| 2263 |
+
"2 599fd8843e098432bb1664c4366b4844 \n",
|
| 2264 |
+
"3 6f7e9e8c72d2bbd1af3118e6058f321f \n",
|
| 2265 |
+
"4 8e77e782f40299f3d202c48aa42d6be6 \n",
|
| 2266 |
+
"\n",
|
| 2267 |
+
"[5 rows x 22 columns]"
|
| 2268 |
+
]
|
| 2269 |
+
},
|
| 2270 |
+
"execution_count": 29,
|
| 2271 |
+
"metadata": {},
|
| 2272 |
+
"output_type": "execute_result"
|
| 2273 |
+
}
|
| 2274 |
+
],
|
| 2275 |
+
"source": [
|
| 2276 |
+
"df_reduced.drop(columns = [\"dupe_img\"], inplace=True)\n",
|
| 2277 |
+
"df_reduced.head()"
|
| 2278 |
+
]
|
| 2279 |
+
},
|
| 2280 |
+
{
|
| 2281 |
+
"cell_type": "code",
|
| 2282 |
+
"execution_count": 30,
|
| 2283 |
+
"metadata": {},
|
| 2284 |
+
"outputs": [],
|
| 2285 |
+
"source": [
|
| 2286 |
+
"df_reduced.to_csv(\"../data/potential-test-sets/filtered/ohio-small-animals-upper-bound.csv\", index = False)\n",
|
| 2287 |
+
"df_reduced_upper_lower = df_reduced.loc[df_reduced[\"num_sp_images\"] >= 10].copy()\n",
|
| 2288 |
+
"df_reduced_upper_lower.to_csv(\"../data/potential-test-sets/filtered/ohio-small-animals-upper-lower-bound.csv\", index = False)"
|
| 2289 |
+
]
|
| 2290 |
+
},
|
| 2291 |
+
{
|
| 2292 |
+
"cell_type": "code",
|
| 2293 |
+
"execution_count": 31,
|
| 2294 |
+
"metadata": {},
|
| 2295 |
+
"outputs": [
|
| 2296 |
+
{
|
| 2297 |
+
"data": {
|
| 2298 |
+
"text/plain": [
|
| 2299 |
+
"468"
|
| 2300 |
+
]
|
| 2301 |
+
},
|
| 2302 |
+
"execution_count": 31,
|
| 2303 |
+
"metadata": {},
|
| 2304 |
+
"output_type": "execute_result"
|
| 2305 |
+
}
|
| 2306 |
+
],
|
| 2307 |
+
"source": [
|
| 2308 |
+
"balanced_set = []\n",
|
| 2309 |
+
"for sci_name in list(df_reduced[\"scientific_name\"].unique()):\n",
|
| 2310 |
+
" temp = df_reduced.loc[df_reduced[\"scientific_name\"] == sci_name].copy()\n",
|
| 2311 |
+
" if temp.shape[0] < 12:\n",
|
| 2312 |
+
" continue\n",
|
| 2313 |
+
" sample_set = list(temp.sample(12, random_state = 614)[\"image_id\"])\n",
|
| 2314 |
+
" balanced_set = balanced_set + sample_set\n",
|
| 2315 |
+
"\n",
|
| 2316 |
+
"len(balanced_set)"
|
| 2317 |
+
]
|
| 2318 |
+
},
|
| 2319 |
+
{
|
| 2320 |
+
"cell_type": "code",
|
| 2321 |
+
"execution_count": 32,
|
| 2322 |
+
"metadata": {},
|
| 2323 |
+
"outputs": [],
|
| 2324 |
+
"source": [
|
| 2325 |
+
"df_balanced = df_reduced.loc[df_reduced[\"image_id\"].isin(balanced_set)].copy()\n",
|
| 2326 |
+
"df_balanced.drop(columns = [\"num_sp_images\"], inplace = True)\n",
|
| 2327 |
+
"df_balanced.to_csv(\"../data/potential-test-sets/filtered/ohio-small-animals-balanced.csv\", index = False)"
|
| 2328 |
+
]
|
| 2329 |
+
},
|
| 2330 |
{
|
| 2331 |
"cell_type": "code",
|
| 2332 |
"execution_count": null,
|