Skip to content

Commit 8a1deee

Browse files
Updated with suggested changes
1 parent 77bdc8f commit 8a1deee

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

guide/14-deep-learning/model_extension_guide.ipynb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
"cell_type": "markdown",
1919
"metadata": {},
2020
"source": [
21-
"With `arcgis.learn`, there are a multitude of machine learning models available for different tasks. There are models for object detection, pixel classification, image translation, natural language processing, point-cloud data, etc. and the list keeps on growing. But what if you come across a deep learning model that is not yet a part of the `learn` module and you want to use it from its library or its open-source code on GitHub? What if you created your own deep learning model for a specific task you are working on? What if you want to use these new models with all the capabilities of the ArcGIS ecosystem?\n",
21+
"With arcgis.learn, there are a multitude of machine learning models available for many different tasks. There are models for object detection, pixel classification, image translation, natural language processing, point-cloud data, etc., and the list continues to grow.\n",
2222
"\n",
23-
"There is a solution - **Model Extension**, a general-purpose wrapper for any **object detection** and **pixel classification** model on top of our existing framework. It wraps all the details of our stack of PyTorch, Fastai, and the learn module and provides an easy to implement structure for the integration of a third-party deep learning model."
23+
"However, what if you come across a deep learning model that is not yet a part of the learn module, and you want to use it from its library or its open-source code on GitHub? What if you created your own deep learning model for a specific task you are working on? Finally, what if you want to use these new models with all the capabilities of the ArcGIS ecosystem?\n",
24+
"\n",
25+
"Fortunately, there is a solution - **Model Extension**, a general-purpose wrapper for any **object detection** and **pixel classification** model on top of our existing framework. It wraps all the details of our stack of PyTorch, Fastai, and the learn module and provides an easy to implement structure for the integration of a third-party deep learning model."
2426
]
2527
},
2628
{
@@ -34,17 +36,17 @@
3436
"cell_type": "markdown",
3537
"metadata": {},
3638
"source": [
37-
"Let's look at the important parts of a deep learning model first and then we will correlate them with model extension:\n",
39+
"Let's first look at the important parts of a deep learning model and then we will correlate them with model extension:\n",
3840
"\n",
39-
"1. **Preprocessing of input data** - The raw image pixels are usually not the best way to feed the model. You will require to transform the input data and the ground truth information in a way that the model can process. \n",
41+
"1. **Preprocessing of input data** - Raw image pixels are usually not the best way to feed the model. As such, we need to transform the input data and the ground truth information in a way that the model can process. \n",
4042
"\n",
4143
"2. **Model Architecture** - This part defines the actual model architecture with different types of neural network layers (convolutional layers, fully connected layers, batch-norm, dropout, etc.) and the connections between them.\n",
4244
"\n",
43-
"3. **Loss Calculation** - We need a loss function to calculate how much is the model deviating from the ground truth. This calculation helps in adjusting the weights of the layers which trains the model to make better predictions.\n",
45+
"3. **Loss Calculation** - A loss function is needed to calculate how much the model predictions are deviating from the ground truth. This calculation helps in adjusting the weights of the layers that train the model to make better predictions.\n",
4446
"\n",
45-
"4. **Postprocessing of the outputs** - This is where the output from the model is transformed in a way that it can be visualized or understood by a user.\n",
47+
"4. **Postprocessing of the outputs** - This step transforms the output from the model so that it can be visualized or understood by a user.\n",
4648
"\n",
47-
"A deep learning model is much more complex if delved deeper. The parts described above are from a higher level division and pertaining to our requirements for model integration."
49+
"The parts described provide a higher level perspective that only describes the aspects pertaining to our requirements for model integration. A deep learning model can be much more complex upon delving deeper."
4850
]
4951
},
5052
{
@@ -58,7 +60,7 @@
5860
"cell_type": "markdown",
5961
"metadata": {},
6062
"source": [
61-
"To be able to use Model Extension, a class needs to be created with a few specific functions. These functions will correspond to the different parts of a deep learning model we discussed earlier. The class can be given any name but the required functions need to have the exact names as we'll see ahead. All the libraries required need to be imported within this class and used in the functions with a `self` prefix."
63+
"To be able to use Model Extension, a class needs to be created with a few specific functions. These functions will correspond to the different parts of a deep learning model that we discussed earlier. The class can be given any name, but the required functions need to have the exact names. All of the libraries required need to be imported within this class and used in the functions with a `self` prefix."
6264
]
6365
},
6466
{
@@ -91,7 +93,7 @@
9193
"cell_type": "markdown",
9294
"metadata": {},
9395
"source": [
94-
"1. `on_batch_begin`: This function is required to transform the input data and the target (the ground truth) used for training the model. The transformation of inputs is in accordance to the model input requirements. This function is equivalent to the fastai on_batch_begin function, but is called in succession of it. Therefore, transformation of inputs is needed only if the format required by the model is different from what fastai transforms it into."
96+
"1. `on_batch_begin`: This function is required to transform the input data and the target (the ground truth) used for training the model. The transformation of inputs is in accordance to the model input requirements. This function is equivalent to the fastai on_batch_begin function, but it is called after it. Therefore, transformation of inputs is needed only if the format required by the model is different from what fastai transforms it into."
9597
]
9698
},
9799
{
@@ -211,7 +213,7 @@
211213
"cell_type": "markdown",
212214
"metadata": {},
213215
"source": [
214-
"Next comes the model architecture. The function `get_model` is used to define the model architecture. Here, you can either create the sequence of neural network layers or import the model defintion from libraries like torchvision, fastai or a third party repository built using Pytorch. \n",
216+
"Next comes the model architecture. The function `get_model` is used to define the model architecture. Here, you can either create the sequence of neural network layers or import the model defintion from libraries like torchvision, fastai, or a third party repository built using Pytorch. \n",
215217
"\n",
216218
"The required arguments are:\n",
217219
"+ `data` - This is the databunch created using the prepare_data function.\n",
@@ -280,7 +282,7 @@
280282
"cell_type": "markdown",
281283
"metadata": {},
282284
"source": [
283-
"The raw output of the model is usually not in the best descernible form. It needs to be post-processed to be understood by the user. The `post_process` function is used to transform the raw outputs of the model to a specific format for the final results and visualization pipeline to ingest."
285+
"Typically, the raw output of the model is not interpretable by the user and needs to be post-processed. The `post_process` function is used to transform the raw outputs of the model to a specific format for the final results and visualization pipeline to ingest."
284286
]
285287
},
286288
{
@@ -578,9 +580,9 @@
578580
"cell_type": "markdown",
579581
"metadata": {},
580582
"source": [
581-
"Once we have created our model class we need to save it as a Python script file. The model class will then be required to be imported from the file using the Python statement `from fasterrcnn import MyFasterRCNN`. Note, here the file `fasterrcnn.py` is present in the current working directory, which is suggested. We need to provide the correct path depending on where we saved the file.\n",
583+
"Once we have created our model class, we need to save it as a Python script file. The model class will then need to be imported from the file using the Python statement `from fasterrcnn import MyFasterRCNN`. Note, here the file `fasterrcnn.py` is present in the current working directory, which is suggested. We need to provide the correct path depending on where we saved the file.\n",
582584
"\n",
583-
"Next, we'll need to import `prepare_data` function and `ModelExtension` class from `arcgis.learn`. The `prepare_data` function will be used to create a fastai databunch and `ModelExtension` class will be used to initialize our custom model."
585+
"Next, we'll need to import `prepare_data` function and the `ModelExtension` class from `arcgis.learn`. The `prepare_data` function will be used to create a fastai databunch and `ModelExtension` class will be used to initialize our custom model."
584586
]
585587
},
586588
{
@@ -602,7 +604,7 @@
602604
"cell_type": "markdown",
603605
"metadata": {},
604606
"source": [
605-
"From here onwards, we can continue with the usual workflow of using an `arcgis.learn` deep learning model. Refer to [Detecting Swimming Pools using Deep Learning sample](https://developers.arcgis.com/python/sample-notebooks/detecting-swimming-pools-using-satellite-image-and-deep-learning/) sample notebook to see the workflow for an **object detection** model and the [Land Conver Classification using Satellite Imagery and Deep Learning](https://developers.arcgis.com/python/sample-notebooks/land-cover-classification-using-unet/) sample notebook for the workflow for a **pixel classification** model."
607+
"From here, we can continue with the usual workflow of using an `arcgis.learn` deep learning model. Refer to the [Detecting Swimming Pools using Deep Learning sample](https://developers.arcgis.com/python/sample-notebooks/detecting-swimming-pools-using-satellite-image-and-deep-learning/) sample notebook to see the workflow for an **object detection** model and the [Land Conver Classification using Satellite Imagery and Deep Learning](https://developers.arcgis.com/python/sample-notebooks/land-cover-classification-using-unet/) sample notebook for the workflow for a **pixel classification** model."
606608
]
607609
},
608610
{

0 commit comments

Comments
 (0)