Wolfram Computation Meets Knowledge

Pix2pix Street-Map-to-Photo Translation

Generate a satellite photo from a street map

Released in 2016, this model is an application of a powerful method for general-purpose image-to-image translation using conditional adversarial networks. The automatic learning of the loss function with the adversarial networks technique allows the same paradigm to generalize across a wide range of image translation tasks. The architecture enables an efficient aggregation of features of multiple scales through skip connections with concatenations. This particular model was trained to generate a street map from a satellite photo.

Number of layers: 56 | Parameter count: 54,419,459 | Trained size: 218 MB

Training Set Information

Examples

Resource retrieval

Retrieve the resource object:

In[1]:=
ResourceObject["Pix2pix Street-Map-To-Photo Translation"]
Out[1]=

Get the pre-trained net:

In[2]:=
NetModel["Pix2pix Street-Map-To-Photo Translation"]
Out[2]=

Basic usage

Start with a street map:

In[3]:=
CloudGet["https://www.wolframcloud.com/objects/902a9970-3cda-41dc-9999-27b73e7f132e"] (* Evaluate this cell to copy the example input from a cloud object *)

Draw a satellite photo from a street map:

In[4]:=
NetModel["Pix2pix Street-Map-To-Photo Translation"][map]
Out[4]=

Evaluate accuracy

Overlap map and prediction:

In[5]:=
ImageCompose[NetModel["Pix2pix Street-Map-To-Photo Translation"][map],
  SetAlphaChannel[map, 0.6]]
Out[5]=

Compare the generated satellite photo with the actual satellite photo:

In[6]:=
CloudGet["https://www.wolframcloud.com/objects/127fbd45-b3c1-48b8-aeb3-9ef9e59859be"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[6]=

Net information

Inspect the number of parameters of all arrays in the net:

In[7]:=
NetInformation[
 NetModel["Pix2pix Street-Map-To-Photo Translation"], \
"ArraysElementCounts"]
Out[7]=

Obtain the total number of parameters:

In[8]:=
NetInformation[
 NetModel["Pix2pix Street-Map-To-Photo Translation"], \
"ArraysTotalElementCount"]
Out[8]=

Obtain the layer type counts:

In[9]:=
NetInformation[
 NetModel["Pix2pix Street-Map-To-Photo Translation"], \
"LayerTypeCounts"]
Out[9]=

Display the summary graphic:

In[10]:=
NetInformation[
 NetModel["Pix2pix Street-Map-To-Photo Translation"], \
"SummaryGraphic"]
Out[10]=

Export to MXNet

Export the net into a format that can be opened in MXNet:

In[11]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["Pix2pix Street-Map-To-Photo Translation"], "MXNet"]
Out[11]=

Export also creates a net.params file containing parameters:

In[12]:=
paramPath = FileNameJoin[{DirectoryName[jsonPath], "net.params"}]
Out[12]=

Get the size of the parameter file:

In[13]:=
FileByteCount[paramPath]
Out[13]=

The size is similar to the byte count of the resource object:

In[14]:=
ResourceObject["Pix2pix Street-Map-To-Photo Translation"]["ByteCount"]
Out[14]=

Represent the MXNet net as a graph:

In[15]:=
Import[jsonPath, {"MXNet", "NodeGraphPlot"}]
Out[15]=

Requirements

Wolfram Language 11.2 (September 2017) or above

Reference