(Translated by https://www.hiragana.jp/)
Dilated ResNet-22 - Wolfram Neural Net Repository

Dilated ResNet-22 Trained on Cityscapes Data

Segment an image of a driving scenario into semantic component classes

Released in 2017, this architecure combines the technique of dilated convolutions with the paradigm of residual networks, outperforming their nonrelated counterparts in image classification and semantic segmentation.

Number of layers: 86 | Parameter count: 15,994,691 | Trained size: 64 MB |

Training Set Information

Performance

Examples

Resource retrieval

Get the pre-trained net:

In[1]:=
NetModel["Dilated ResNet-22 Trained on Cityscapes Data"]
Out[1]=

Evaluation function

Write an evaluation function to handle net reshaping and resampling of input and output:

In[2]:=
netevaluate[img_, device_ : "CPU"] := Block[
  {net, encData, dec, mean, var, prob},
  net = NetModel["Dilated ResNet-22 Trained on Cityscapes Data"];
  encData = Normal@NetExtract[net, "input_0"];
  dec = NetExtract[net, "Output"];
  {mean, var} = Lookup[encData, {"MeanImage", "VarianceImage"}];
  NetReplacePart[net,
    {"input_0" -> NetEncoder[{"Image", ImageDimensions@img, "MeanImage" -> mean, "VarianceImage" -> var}], "Output" -> dec}
    ][img, TargetDevice -> device]
  ]

Label list

Define the label list for this model. Integers in the model’s output correspond to elements in the label list:

In[3]:=
labels = {"road", "sidewalk", "building", "wall", "fence", "pole", "traffic light", "traffic sign", "vegetation", "terrain", "sky", "person", "rider", "car", "truck", "bus", "train", "motorcycle", "bicycle"};

Basic usage

Obtain a segmentation mask for a given image:

In[4]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/90161845-03f3-4235-adfc-5b9de58bec2b"]

Inspect which classes are detected:

In[5]:=
detected = DeleteDuplicates@Flatten@mask
Out[5]=
In[6]:=
labels[[detected]]
Out[6]=

Visualize the mask:

In[7]:=
Colorize[mask]
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

Reference