|
43 | 43 | "cell_type": "markdown",
|
44 | 44 | "metadata": {},
|
45 | 45 | "source": [
|
46 |
| - "In this sample notebook, we will be using `ArcGIS API for Python` for training an object classification model on image data from an external source and using that model for inferencing in ArcGIS Pro. \n", |
47 |
| - "For this example, we will be using the [RESISC45 Dataset](https://arxiv.org/abs/1703.00121) which is a publicly available benchmark for Remote Sensing Image Scene Classification (RESISC), created by Northwestern Polytechnical University (NWPU). This dataset contains 31,500 images, covering 45 scene classes with 700 images in each class. \n", |
48 |
| - "We will be using this dataset to train a `FeatureClassifier` model which will classify satellite images tile in 45 scene classes specified in the dataset." |
| 46 | + "In this sample notebook, we will be using the `ArcGIS API for Python` for training an object classification model on image data from an external source and using that model for inferencing in ArcGIS Pro.\n", |
| 47 | + "\n", |
| 48 | + "For this example, we will be using the [RESISC45 Dataset](https://arxiv.org/abs/1703.00121), which is a publicly available benchmark for Remote Sensing Image Scene Classification (RESISC) created by Northwestern Polytechnical University (NWPU). This dataset contains 31,500 images covering 45 scene classes, with 700 images in each class.\n", |
| 49 | + "\n", |
| 50 | + "We will be using this dataset to train a `FeatureClassifier` model that will classify satellite image tiles in the 45 scene classes specified in the dataset.\n", |
| 51 | + "\n" |
49 | 52 | ]
|
50 | 53 | },
|
51 | 54 | {
|
|
76 | 79 | "cell_type": "markdown",
|
77 | 80 | "metadata": {},
|
78 | 81 | "source": [
|
79 |
| - "Since [RESISC45 Dataset](https://arxiv.org/abs/1703.00121) is publically available data so we will be downloading the data available on the [Tensorflow website](https://www.tensorflow.org/datasets/catalog/resisc45).<br>\n", |
80 |
| - "The data will be downloaded by the name of <b>NWPU-RESISC45.rar</b> <br>\n", |
| 82 | + "Since the [RESISC45 Dataset](https://arxiv.org/abs/1703.00121) is publically available, we will download the data from the [Tensorflow website](https://www.tensorflow.org/datasets/catalog/resisc45).\n", |
| 83 | + "The name of the dataset we will be downloading is <b>NWPU-RESISC45.rar</b> <br>\n", |
81 | 84 | "- Citation : `@article{cheng2017remote,\n",
|
82 | 85 | " title={Remote sensing image scene classification: Benchmark and state of the art},\n",
|
83 | 86 | " author={Cheng, Gong and Han, Junwei and Lu, Xiaoqiang},\n",
|
|
94 | 97 | "cell_type": "markdown",
|
95 | 98 | "metadata": {},
|
96 | 99 | "source": [
|
97 |
| - "After the data is downloaded then follow the following steps to prepare the model for the `FeatureClassifier`. \n", |
98 |
| - "- Extract the rar file\n", |
99 |
| - "- Create a folder named <b>images</b> and move all the 45 folders (correspoding to each class in the dataset) in images\n", |
| 100 | + "After the data has been downloaded, follow the steps below to prepare the model for the `FeatureClassifier`. \n", |
| 101 | + "- Extract the .rar file\n", |
| 102 | + "- Create a folder named <b>images</b> and move all the 45 folders (correspoding to each class in the dataset) into the images folder\n", |
100 | 103 | "\n",
|
101 | 104 | "<img src=\"..\\..\\static\\video\\image_scene_classification_using_FeatureClassifier_data.gif\" width=\"750\" align=\"center\">"
|
102 | 105 | ]
|
|
105 | 108 | "cell_type": "markdown",
|
106 | 109 | "metadata": {},
|
107 | 110 | "source": [
|
108 |
| - "We will set the path of the folder containing the <b>images</b> in the <b>output_path</b> variable" |
| 111 | + "Next, we will create an output_path variable containing the path of the images folder." |
109 | 112 | ]
|
110 | 113 | },
|
111 | 114 | {
|
|
128 | 131 | "cell_type": "markdown",
|
129 | 132 | "metadata": {},
|
130 | 133 | "source": [
|
131 |
| - "`arcgis.learn` provides the ability to determine the class of each feature in the form of a `FeatureClassifier` model. To learn more about it's workings and use cases, see this guide - [\"How feature classifier works?\"](https://developers.arcgis.com/python/guide/how-feature-categorization-works/)." |
| 134 | + "`arcgis.learn` provides the ability to determine the class of each feature in the form of a `FeatureClassifier` model. To learn more about how it works and its potential use cases, see this guide - [\"How feature classifier works?\"](https://developers.arcgis.com/python/guide/how-feature-categorization-works/).\n" |
132 | 135 | ]
|
133 | 136 | },
|
134 | 137 | {
|
|
146 | 149 | "\n",
|
147 | 150 | "- `path`: path of the folder/list of folders containing training data.\n",
|
148 | 151 | "- `dataset_type` : The type of dataset getting passed to the Feature Classifier.\n",
|
149 |
| - "- `batch_size`: Number of images your model will train on each step inside an epoch, it directly depends on the memory of your graphic card. 128 worked for us on a 32GB GPU.\n", |
| 152 | + "- `batch_size`: Number of images your model will train on each step inside an epoch. <b>This directly depends on the memory of your graphic card</b>. 128 worked for us on a 32GB GPU.\n", |
150 | 153 | "\n",
|
151 |
| - "Since we are using the dataset from external source for training our `FeatureClassifier` we will be using <b>Imagenet</b> as dataset_type." |
| 154 | + "Since we are using the dataset from external source for training our `FeatureClassifier`, we will be using <b>Imagenet</b> as dataset_type." |
152 | 155 | ]
|
153 | 156 | },
|
154 | 157 | {
|
|
228 | 231 | "cell_type": "markdown",
|
229 | 232 | "metadata": {},
|
230 | 233 | "source": [
|
231 |
| - "[Learning rate](https://en.wikipedia.org/wiki/Stochastic_gradient_descent) is one of the most important hyperparameters in model training. `ArcGIS API for Python` provides a learning rate finder that automatically chooses the optimal learning rate for you." |
| 234 | + "[Learning rate](https://en.wikipedia.org/wiki/Stochastic_gradient_descent) is one of the most important hyperparameters in model training. The `ArcGIS API for Python` provides a learning rate finder that automatically chooses the optimal learning rate for you." |
232 | 235 | ]
|
233 | 236 | },
|
234 | 237 | {
|
|
445 | 448 | "cell_type": "markdown",
|
446 | 449 | "metadata": {},
|
447 | 450 | "source": [
|
448 |
| - "Here, with only 20 epochs, we can see reasonable results — both training and validation losses have gone down considerably, indicating that the model is learning to classify image scenes." |
| 451 | + "Here, with only 20 epochs, we can see reasonable results, as both training and validation losses have decreased considerably, indicating that the model is learning to classify image scenes." |
449 | 452 | ]
|
450 | 453 | },
|
451 | 454 | {
|
|
459 | 462 | "cell_type": "markdown",
|
460 | 463 | "metadata": {},
|
461 | 464 | "source": [
|
462 |
| - "It is a good practice to see the results of the model viz-a-viz ground truth. The code below picks random samples and shows us ground truth and model predictions, side by side. This enables us to preview the results of the model within the notebook." |
| 465 | + "It is a good practice to see the results of the model viz-a-viz ground truth. The code below picks random samples and shows us ground truth and model predictions side by side. This enables us to preview the results of the model within the notebook." |
463 | 466 | ]
|
464 | 467 | },
|
465 | 468 | {
|
|
495 | 498 | "cell_type": "markdown",
|
496 | 499 | "metadata": {},
|
497 | 500 | "source": [
|
498 |
| - "`arcgis.learn` provides `plot_confusion_matrix()` that plots a confusion matrix of the model predictions to evaluate its accuracy." |
| 501 | + "`arcgis.learn` provides the `plot_confusion_matrix()` function that plots a confusion matrix of the model predictions to evaluate the model's accuracy." |
499 | 502 | ]
|
500 | 503 | },
|
501 | 504 | {
|
|
534 | 537 | "cell_type": "markdown",
|
535 | 538 | "metadata": {},
|
536 | 539 | "source": [
|
537 |
| - "The confusion matrix validates that the trained model is learning to classify coastlines. The diagonal numbers show the number of scenes correctly classified to the respective categories." |
| 540 | + "The confusion matrix validates that the trained model is learning to classify coastlines. The diagonal numbers show the number of scenes correctly classified as their respective categories." |
538 | 541 | ]
|
539 | 542 | },
|
540 | 543 | {
|
|
585 | 588 | "cell_type": "markdown",
|
586 | 589 | "metadata": {},
|
587 | 590 | "source": [
|
588 |
| - "Before using the model for inference we need to make some changes in the <b>model_name.emd</b> file. You can learn more about this file at this [link](https://github.com/Esri/raster-deep-learning/blob/master/docs/writing_model_definition.md)" |
| 591 | + "Before using the model for inference, we need to make some changes in the <b>model_name.emd</b> file. You can learn more about this file [here](https://github.com/Esri/raster-deep-learning/blob/master/docs/writing_model_definition.md)." |
589 | 592 | ]
|
590 | 593 | },
|
591 | 594 | {
|
592 | 595 | "cell_type": "markdown",
|
593 | 596 | "metadata": {},
|
594 | 597 | "source": [
|
595 |
| - "By default in EMD the `CropSizeFixed` : 1. Here we need to change the `CropSizeFixed` : 0 so that the size of tile cropped around the feature is not fixed." |
| 598 | + "By default, in the EMD file, the `CropSizeFixed` is set to 1. We need to change the `CropSizeFixed` to 0 so that the size of tiles cropped around the feature are not fixed." |
596 | 599 | ]
|
597 | 600 | },
|
598 | 601 | {
|
|
615 | 618 | "cell_type": "markdown",
|
616 | 619 | "metadata": {},
|
617 | 620 | "source": [
|
618 |
| - "For us to perform inferencing in ArcGIS Pro, we need to create a feature class on the map using `Create Feature Class` or `Create Fishnet` tool, for an area that is not already seen by the model.\n", |
| 621 | + "For us to perform inferencing in ArcGIS Pro, we need to create a feature class on the map using either the `Create Feature Class` tool or the `Create Fishnet` tool, for an area that has not already seen by the model.\n", |
619 | 622 | "\n",
|
620 |
| - "We have also provided the Feature Class and the Model trained on NWPU Dataset for reference. You can directly download those to run experiments from the links given below.\n", |
621 |
| - "- Feature Class : [\"Link\"](https://pythonapi.playground.esri.com/portal/home/item.html?id=bb6645d6c7664a4c9d878d03e611107d)\n", |
622 |
| - "- NWPU Model : [\"Link\"](https://pythonapi.playground.esri.com/portal/home/item.html?id=5e18839f2fee4449ad9b486c0bf2cbb0)\n" |
| 623 | + "We have also provided the Feature Class and the Model trained on the NWPU Dataset for reference. You can directly download these to run your own experiments from the links below.\n", |
| 624 | + "- [Feature Class](https://pythonapi.playground.esri.com/portal/home/item.html?id=bb6645d6c7664a4c9d878d03e611107d)\n", |
| 625 | + "- [NWPU Model](https://pythonapi.playground.esri.com/portal/home/item.html?id=5e18839f2fee4449ad9b486c0bf2cbb0)\n" |
623 | 626 | ]
|
624 | 627 | },
|
625 | 628 | {
|
|
635 | 638 | "- `Class Label Field`: Field name that will contain the detected class number.\n",
|
636 | 639 | "- `Environments`: Set optimum `Cell Size`, `Processing Extent` and `Processor Type`.\n",
|
637 | 640 | "\n",
|
638 |
| - "We have investigated and found out that a `Cell Size` of 1m/pixel works best for this model. " |
| 641 | + "We have investigated and found that a `Cell Size` of 1m/pixel works best for this model. " |
639 | 642 | ]
|
640 | 643 | },
|
641 | 644 | {
|
|
656 | 659 | "cell_type": "markdown",
|
657 | 660 | "metadata": {},
|
658 | 661 | "source": [
|
659 |
| - "We selected an area unseen (by the model) and generated the features in it using the `Create Feature Class` tool. We then used our model for classification. Below are the results that we got." |
| 662 | + "We selected an area that had not been seen by the model and generated the features in it using the `Create Feature Class` tool. We then used our model for classification. Below are the results." |
660 | 663 | ]
|
661 | 664 | },
|
662 | 665 | {
|
|
670 | 673 | "cell_type": "markdown",
|
671 | 674 | "metadata": {},
|
672 | 675 | "source": [
|
673 |
| - "We also created a fishnet using the `Create Fishnet` tool. We then used our model for classification on that fishnet. We can use this technique to create preliminary data about the image. Based on the output we can get much inferences out of the image such as total residential, an industrial area in an image etc. Below is the map which we created from the results." |
| 676 | + "We also created a fishnet using the `Create Fishnet` tool that we then fed to our model for classification. We can use this technique to create preliminary data about the image. Based on the output, we can make inferences about the image, such as the total of residential areas, industrial areas in an image, etc. Below is the map that we created from the results." |
674 | 677 | ]
|
675 | 678 | },
|
676 | 679 | {
|
|
0 commit comments