You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["# Use MMDetection with `arcgis.learn`"]}, {"cell_type": "markdown", "metadata": {"toc": true}, "source": ["<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n", "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Use-MMDetection-with-arcgis.learn\" data-toc-modified-id=\"Use-MMDetection-with-arcgis.learn-1\"><span class=\"toc-item-num\">1 </span>Use MMDetection with <code>arcgis.learn</code></a></span><ul class=\"toc-item\"><li><span><a href=\"#Introduction\" data-toc-modified-id=\"Introduction-1.1\"><span class=\"toc-item-num\">1.1 </span>Introduction</a></span></li><li><span><a href=\"#Setting-up-the-environment\" data-toc-modified-id=\"Setting-up-the-environment-1.2\"><span class=\"toc-item-num\">1.2 </span>Setting up the environment</a></span></li><li><span><a href=\"#Implementation-in-arcgis.learn\" data-toc-modified-id=\"Implementation-in-arcgis.learn-1.3\"><span class=\"toc-item-num\">1.3 </span>Implementation in <code>arcgis.learn</code></a></span></li><li><span><a href=\"#Training-and-inference\" data-toc-modified-id=\"Training-and-inference-1.4\"><span class=\"toc-item-num\">1.4 </span>Training and inference</a></span></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-1.5\"><span class=\"toc-item-num\">1.5 </span>References</a></span></li></ul></li></ul></div>"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Introduction"]}, {"cell_type": "markdown", "metadata": {}, "source": ["MMdetection is an open-source library containing many popular and state-of-the-art object detection models. Through `arcgis.learn` we have provided a bridge to use the growing list of models provided by the MMDetection library.\n", "\n", "In 2018, the MMdet team won the COCO object detection challenge. Their codebase, which is built with Pytorch, has gradually evolved to include various models and methods. Although the detection task can be complex, the creators of MMDetection decomposed the models into different general components - Backbone, Neck, DenseHead, ROIExtractor, and ROIHead. With this abstraction, the library is able to provide a multitude of single-stage (e.g. GHM, FCOS), two-stage (e.g. Double-Head R-CNN), multi-stage (e.g. Cascade R-CNN), and other detection models. This abstraction-based approach also allows the development of models either by changing the different components or even by adding new ones. Read the MMDetection [paper](https://arxiv.org/pdf/1906.07155.pdf) or checkout its [github repository](https://github.com/open-mmlab/mmdetection), for more details."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Setting up the environment"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Follow the steps [here](https://developers.arcgis.com/python/guide/install-and-set-up/#Install-deep-learning-dependencies) to install deep learning dependencies in ArcGIS Pro or the Anaconda environment respectively.\n", "\n", "ArcGIS Pro 2.8 users additionally need to install the CUDA toolkit (version 11), mmcv-full, and mmdet libraries. Follow these steps to do so:\n", "\n", "- Download and install the latest CUDA toolkit version from [here](https://developer.nvidia.com/cuda-downloads).\n", "- Add the installed CUDA toolkit's bin folder path (typically, C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.0\\bin) to the (user or system) Path Environment Variables.\n", "- Run the following command in a cloned environment: \n", "`conda install -c esri mmcv-full mmdet`"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Implementation in `arcgis.learn`"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Using MMDetection with arcgis.learn is as simple as using any other object detection model in the library. The only additional step is providing the name of the model to be used when initializing the MMDetection model object."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["model = MMDetection(data, model='dcn')"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The parameters required are:\n", "\n", "- `data` - the data object prepared using `prepare_data` \n", "- `model` - the name of the models from the list of supported models."]}, {"cell_type": "markdown", "metadata": {}, "source": ["The following MMDetection models are supported through `arcgis.learn`:"]}, {"cell_type": "code", "execution_count": 1, "metadata": {"scrolled": false}, "outputs": [{"data": {"text/plain": ["['atss',\n", " 'carafe',\n", " 'cascade_rcnn',\n", " 'cascade_rpn',\n", " 'dcn',\n", " 'detectors',\n", " 'double_heads',\n", " 'dynamic_rcnn',\n", " 'empirical_attention',\n", " 'fcos',\n", " 'foveabox',\n", " 'fsaf',\n", " 'ghm',\n", " 'hrnet',\n", " 'libra_rcnn',\n", " 'nas_fcos',\n", " 'pafpn',\n", " 'pisa',\n", " 'regnet',\n", " 'reppoints',\n", " 'res2net',\n", " 'sabl',\n", " 'vfnet']"]}, "execution_count": 1, "metadata": {}, "output_type": "execute_result"}], "source": ["MMDetection.supported_models"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The `model` argument can also accept the path to a config file for a variation of one of the supported models. These files can be found [here](https://github.com/open-mmlab/mmdetection/tree/master/configs). The [configs directory](https://github.com/open-mmlab/mmdetection/tree/master/configs) in the mmdetection repository needs to be downloaded for other model variants to work.\n", "\n", "Additionally, `model_weight` can be provided for these config files. The link to the corresponding weights can be found in the README file for each model."]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["cfg = r'C:\\mmdetection\\configs\\atss\\atss_r101_fpn_1x_coco.py'\n", "wts = r'C:\\mmdetection\\atss\\atss_r101_fpn_1x_coco\\atss_r101_fpn_1x_20200825-dfcadd6f.pth'\n", "model = MMDetection(data, model=cfg, model_weight=wts)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## Training and inference"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The MMdetection models can be trained using the `fit` method. "]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["model.fit()"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Alternatively, [Train Deep Learning Model](https://pro.arcgis.com/en/pro-app/latest/tool-reference/image-analyst/train-deep-learning-model.htm) tool in ArcGIS Pro can be used to train the models.\n", "Models trained through the API or ArcGIS Pro can be used for inferencing using the [Detect Objects Using Deep Learning](https://pro.arcgis.com/en/pro-app/latest/tool-reference/image-analyst/detect-objects-using-deep-learning.htm) tool in ArcGIS Pro."]}, {"cell_type": "markdown", "metadata": {}, "source": ["For more information about the API, visit the [API reference for MMDetection](https://developers.arcgis.com/python/api-reference/arcgis.learn.toc.html#mmdetection). For a detailed object detection workflow, refer to a sample [notebook](https://developers.arcgis.com/python/sample-notebooks/detecting-and-categorizing-brick-kilns-from-satellite-imagery/)."]}, {"cell_type": "markdown", "metadata": {}, "source": ["## References"]}, {"cell_type": "markdown", "metadata": {}, "source": ["[1] OpenMmlab, \u201copenmmlab/mmdetection: OpenMMLab Detection Toolbox and Benchmark.,\u201d GitHub. [Online]. Available: https://github.com/open-mmlab/mmdetection/ [Accessed: 20-Jul-2021]."]}], "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2"}, "toc": {"base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": true}}, "nbformat": 4, "nbformat_minor": 5}
1
+
{
2
+
"cells": [
3
+
{
4
+
"cell_type": "markdown",
5
+
"id": "67cca7a9",
6
+
"metadata": {},
7
+
"source": [
8
+
"# Use MMDetection with arcgis.learn"
9
+
]
10
+
},
11
+
{
12
+
"cell_type": "markdown",
13
+
"id": "52616695",
14
+
"metadata": {
15
+
"toc": true
16
+
},
17
+
"source": [
18
+
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
19
+
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Use-MMDetection-with-arcgis.learn\" data-toc-modified-id=\"Use-MMDetection-with-arcgis.learn-1\"><span class=\"toc-item-num\">1 </span>Use MMDetection with <code>arcgis.learn</code></a></span><ul class=\"toc-item\"><li><span><a href=\"#Introduction\" data-toc-modified-id=\"Introduction-1.1\"><span class=\"toc-item-num\">1.1 </span>Introduction</a></span></li><li><span><a href=\"#Setting-up-the-environment\" data-toc-modified-id=\"Setting-up-the-environment-1.2\"><span class=\"toc-item-num\">1.2 </span>Setting up the environment</a></span></li><li><span><a href=\"#Implementation-in-arcgis.learn\" data-toc-modified-id=\"Implementation-in-arcgis.learn-1.3\"><span class=\"toc-item-num\">1.3 </span>Implementation in <code>arcgis.learn</code></a></span></li><li><span><a href=\"#Training-and-inference\" data-toc-modified-id=\"Training-and-inference-1.4\"><span class=\"toc-item-num\">1.4 </span>Training and inference</a></span></li><li><span><a href=\"#References\" data-toc-modified-id=\"References-1.5\"><span class=\"toc-item-num\">1.5 </span>References</a></span></li></ul></li></ul></div>"
20
+
]
21
+
},
22
+
{
23
+
"cell_type": "markdown",
24
+
"id": "3b538f79",
25
+
"metadata": {},
26
+
"source": [
27
+
"## Introduction"
28
+
]
29
+
},
30
+
{
31
+
"cell_type": "markdown",
32
+
"id": "bbc5878b",
33
+
"metadata": {},
34
+
"source": [
35
+
"MMdetection is an open-source library containing many popular and state-of-the-art object detection models. Through `arcgis.learn` we have provided a bridge to use the growing list of models provided by the MMDetection library.\n",
36
+
"\n",
37
+
"In 2018, the MMdet team won the COCO object detection challenge. Their codebase, which is built with Pytorch, has gradually evolved to include various models and methods. Although the detection task can be complex, the creators of MMDetection decomposed the models into different general components - Backbone, Neck, DenseHead, ROIExtractor, and ROIHead. With this abstraction, the library is able to provide a multitude of single-stage (e.g. GHM, FCOS), two-stage (e.g. Double-Head R-CNN), multi-stage (e.g. Cascade R-CNN), and other detection models. This abstraction-based approach also allows the development of models either by changing the different components or even by adding new ones. Read the MMDetection [paper](https://arxiv.org/pdf/1906.07155.pdf) or checkout its [github repository](https://github.com/open-mmlab/mmdetection), for more details."
38
+
]
39
+
},
40
+
{
41
+
"cell_type": "markdown",
42
+
"id": "73e1efe5",
43
+
"metadata": {},
44
+
"source": [
45
+
"## Setting up the environment"
46
+
]
47
+
},
48
+
{
49
+
"cell_type": "markdown",
50
+
"id": "4569192b",
51
+
"metadata": {},
52
+
"source": [
53
+
"Follow the steps [here](https://developers.arcgis.com/python/guide/install-and-set-up/#Install-deep-learning-dependencies) to install deep learning dependencies in ArcGIS Pro or the Anaconda environment respectively.\n",
54
+
"\n",
55
+
"ArcGIS Pro 2.8 users additionally need to install the CUDA toolkit (version 11), mmcv-full, and mmdet libraries. Follow these steps to do so:\n",
56
+
"\n",
57
+
"- Download and install the latest CUDA toolkit version from [here](https://developer.nvidia.com/cuda-downloads).\n",
58
+
"- Add the installed CUDA toolkit's bin folder path (typically, C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.0\\bin) to the (user or system) Path Environment Variables.\n",
59
+
"- Run the following command in a cloned environment: \n",
60
+
"`conda install -c esri mmcv-full mmdet`"
61
+
]
62
+
},
63
+
{
64
+
"cell_type": "markdown",
65
+
"id": "90e51201",
66
+
"metadata": {},
67
+
"source": [
68
+
"## Implementation in `arcgis.learn`"
69
+
]
70
+
},
71
+
{
72
+
"cell_type": "markdown",
73
+
"id": "203e9ef5",
74
+
"metadata": {},
75
+
"source": [
76
+
"Using MMDetection with arcgis.learn is as simple as using any other object detection model in the library. The only additional step is providing the name of the model to be used when initializing the MMDetection model object."
77
+
]
78
+
},
79
+
{
80
+
"cell_type": "code",
81
+
"execution_count": null,
82
+
"id": "b5559f5b",
83
+
"metadata": {},
84
+
"outputs": [],
85
+
"source": [
86
+
"model = MMDetection(data, model='dcn')"
87
+
]
88
+
},
89
+
{
90
+
"cell_type": "markdown",
91
+
"id": "b0b2913d",
92
+
"metadata": {},
93
+
"source": [
94
+
"The parameters required are:\n",
95
+
"\n",
96
+
"- `data` - the data object prepared using `prepare_data` \n",
97
+
"- `model` - the name of the models from the list of supported models."
98
+
]
99
+
},
100
+
{
101
+
"cell_type": "markdown",
102
+
"id": "dd8c6596",
103
+
"metadata": {},
104
+
"source": [
105
+
"The following MMDetection models are supported through `arcgis.learn`:"
106
+
]
107
+
},
108
+
{
109
+
"cell_type": "code",
110
+
"execution_count": 1,
111
+
"id": "30813304",
112
+
"metadata": {
113
+
"scrolled": false
114
+
},
115
+
"outputs": [
116
+
{
117
+
"data": {
118
+
"text/plain": [
119
+
"['atss',\n",
120
+
" 'carafe',\n",
121
+
" 'cascade_rcnn',\n",
122
+
" 'cascade_rpn',\n",
123
+
" 'dcn',\n",
124
+
" 'detectors',\n",
125
+
" 'double_heads',\n",
126
+
" 'dynamic_rcnn',\n",
127
+
" 'empirical_attention',\n",
128
+
" 'fcos',\n",
129
+
" 'foveabox',\n",
130
+
" 'fsaf',\n",
131
+
" 'ghm',\n",
132
+
" 'hrnet',\n",
133
+
" 'libra_rcnn',\n",
134
+
" 'nas_fcos',\n",
135
+
" 'pafpn',\n",
136
+
" 'pisa',\n",
137
+
" 'regnet',\n",
138
+
" 'reppoints',\n",
139
+
" 'res2net',\n",
140
+
" 'sabl',\n",
141
+
" 'vfnet']"
142
+
]
143
+
},
144
+
"execution_count": 1,
145
+
"metadata": {},
146
+
"output_type": "execute_result"
147
+
}
148
+
],
149
+
"source": [
150
+
"MMDetection.supported_models"
151
+
]
152
+
},
153
+
{
154
+
"cell_type": "markdown",
155
+
"id": "17411f61",
156
+
"metadata": {},
157
+
"source": [
158
+
"The `model` argument can also accept the path to a config file for a variation of one of the supported models. These files can be found [here](https://github.com/open-mmlab/mmdetection/tree/master/configs). The [configs directory](https://github.com/open-mmlab/mmdetection/tree/master/configs) in the mmdetection repository needs to be downloaded for other model variants to work.\n",
159
+
"\n",
160
+
"Additionally, `model_weight` can be provided for these config files. The link to the corresponding weights can be found in the README file for each model."
"The MMdetection models can be trained using the `fit` method. "
189
+
]
190
+
},
191
+
{
192
+
"cell_type": "code",
193
+
"execution_count": null,
194
+
"id": "408ca615",
195
+
"metadata": {},
196
+
"outputs": [],
197
+
"source": [
198
+
"model.fit()"
199
+
]
200
+
},
201
+
{
202
+
"cell_type": "markdown",
203
+
"id": "3ad4a24e",
204
+
"metadata": {},
205
+
"source": [
206
+
"Alternatively, [Train Deep Learning Model](https://pro.arcgis.com/en/pro-app/latest/tool-reference/image-analyst/train-deep-learning-model.htm) tool in ArcGIS Pro can be used to train the models.\n",
207
+
"Models trained through the API or ArcGIS Pro can be used for inferencing using the [Detect Objects Using Deep Learning](https://pro.arcgis.com/en/pro-app/latest/tool-reference/image-analyst/detect-objects-using-deep-learning.htm) tool in ArcGIS Pro."
208
+
]
209
+
},
210
+
{
211
+
"cell_type": "markdown",
212
+
"id": "22976ebb",
213
+
"metadata": {},
214
+
"source": [
215
+
"For more information about the API, visit the [API reference for MMDetection](https://developers.arcgis.com/python/api-reference/arcgis.learn.toc.html#mmdetection). For a detailed object detection workflow, refer to a sample [notebook](https://developers.arcgis.com/python/sample-notebooks/detecting-and-categorizing-brick-kilns-from-satellite-imagery/)."
0 commit comments