upate plant species sample
"* [Get the data for analysis](#Get-the-data-for-analysis)\n",
"* [Train an image classification model](#Train-an-image-classification-model)\n",
" * [Necessary imports](#Necessary-imports)\n",
+ " * [Download Dataset](#Download-Dataset)\n",
+ " * [Filter out non RGB Images](#Filter-out-non-RGB-Images)\n",
" * [Prepare data](#Prepare-data)\n",
" * [Visualize a few samples from your training data](#Visualize-a-few-samples-from-your-training-data)\n",
" * [Load model architecture](#Load-model-architecture)\n",
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Prepare data"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "We will now use the `prepare_data()` function to apply various types of transformations and augmentations on the training data. These augmentations enable us to train a better model with limited data and also prevent the model from overfitting. \n",
- "\n",
- "Here, we are passing 3 parameters to the `prepare_data()` function.\n",
- " - `path`: path of folder containing training data.\n",
- " - `chip_size`: Same as per specified while exporting training data.\n",
- " - `batch_size`: No. of images your model will train on each step inside an epoch, it directly depends on the memory of your graphic card and the type of model which you are working with. For this sample, a batch size of 64 worked for us on a GPU with 11GB memory."
+ "### Download Dataset"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
- "scrolled": true
+ "scrolled": false
},
"outputs": [
{
"data_path = Path(os.path.join(filepath.split('.')[0]))"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Filter out non RGB Images"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from glob import glob\n",
+ "from PIL import Image"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "for image_filepath in glob(os.path.join(data_path, 'images', '**','*.jpg')):\n",
+ " if Image.open(image_filepath).mode != 'RGB':\n",
+ " os.remove(image_filepath)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Prepare data"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We will now use the `prepare_data()` function to apply various types of transformations and augmentations on the training data. These augmentations enable us to train a better model with limited data and also prevent the model from overfitting. \n",
+ "\n",
+ "Here, we are passing 3 parameters to the `prepare_data()` function.\n",
+ " - `path`: path of folder containing training data.\n",
+ " - `chip_size`: Same as per specified while exporting training data.\n",
+ " - `batch_size`: No. of images your model will train on each step inside an epoch, it directly depends on the memory of your graphic card and the type of model which you are working with. For this sample, a batch size of 64 worked for us on a GPU with 11GB memory."
+ ]
+ },
{
"cell_type": "code",
"execution_count": 3,
