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
"This is a notebook for running the benchmark semantic segmentation network from the the [ADE20K MIT Scene Parsing Benchchmark](http://sceneparsing.csail.mit.edu/).\n",
"It can be run on Colab at this URL https://colab.research.google.com/github/davidbau/semantic-segmentation-pytorch/blob/tutorial/notebooks/DemoSegmenter.ipynb"
15
+
]
16
+
},
17
+
{
18
+
"cell_type": "markdown",
19
+
"metadata": {},
20
+
"source": [
21
+
"### Environment Setup\n",
22
+
"\n",
23
+
"First, download the code and pretrained models if we are on colab."
"Here we load a pretrained segmentation model. Like any pytorch model, we can call it like a function, or examine the parameters in all the layers.\n",
93
+
"\n",
94
+
"After loading, we put it on the GPU. And since we are doing inference, not training, we put the model in eval mode."
"Now we load and normalize a single test image. Here we use the commonplace convention of normalizing the image to a scale for which the RGB values of a large photo dataset would have zero mean and unit standard deviation. (These numbers come from the imagenet dataset.) With this normalization, the limiiting ranges of RGB values are within about (-2.2 to +2.7)."
128
+
]
129
+
},
130
+
{
131
+
"cell_type": "code",
132
+
"execution_count": null,
133
+
"metadata": {},
134
+
"outputs": [],
135
+
"source": [
136
+
"# Load and normalize one image as a singleton tensor batch\n",
"Finally we just pass the test image to the segmentation model.\n",
157
+
"\n",
158
+
"The segmentation model is coded as a function that takes a dictionary as input, because it wants to know both the input batch image data as well as the desired output segmentation resolution. We ask for full resolution output.\n",
159
+
"\n",
160
+
"Then we use the previously-defined visualize_result function to render the semgnatioon map."
161
+
]
162
+
},
163
+
{
164
+
"cell_type": "code",
165
+
"execution_count": null,
166
+
"metadata": {
167
+
"scrolled": false
168
+
},
169
+
"outputs": [],
170
+
"source": [
171
+
"# Run the segmentation at the highest resolution.\n",
0 commit comments