Pix2pix Photo-to-Street-Map Translation

Generate a street map from a satellite photo

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

Get the pre-trained net:

In[1]:=
NetModel["Pix2pix Photo-to-Street-Map Translation"]
Out[1]=

Basic usage

Obtain a satellite photo:

In[2]:=
img = ImageResize[
  GeoImage[Entity["City", {"LasVegas", "Nevada", "UnitedStates"}], GeoRange -> 200], {256, 256}]
Out[2]=

Use the net to draw the street map:

In[3]:=
map = NetModel["Pix2pix Photo-to-Street-Map Translation"][img]
Out[3]=

Evaluate accuracy

Overlap photo and prediction:

In[4]:=
ImageCompose[img, SetAlphaChannel[map, 0.8]]
Out[4]=

Obtain the actual street map:

In[5]:=
actualMap = ImageResize[
  GeoImage[Entity["City", {"LasVegas", "Nevada", "UnitedStates"}], "StreetMap", GeoRange -> 200], {256, 256}]
Out[5]=

Compare the generated street map with the actual street map:

In[6]:=
ImageAssemble[{map, actualMap}]
Out[6]=

Issues

More complex patterns are harder to render. Obtain a new photo and street map pair:

In[7]:=
{img, actualMap} = ImageResize[
    GeoImage[GeoPosition[{41.940360, 12.533762}], #, GeoRange -> 200], {256, 256}] & /@ {"Satellite", "StreetMap"}
Out[7]=

Compare the prediction with the actual street map:

In[8]:=
ImageAssemble[{NetModel["Pix2pix Photo-to-Street-Map Translation"][
   img], actualMap}]
Out[8]=

Net information

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

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

Obtain the total number of parameters:

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

Obtain the layer type counts:

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

Display the summary graphic:

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

Export to MXNet

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

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

Export also creates a net.params file containing parameters:

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

Get the size of the parameter file:

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

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

In[16]:=
ResourceObject["Pix2pix Photo-to-Street-Map Translation"]["ByteCount"]
Out[16]=

Represent the MXNet net as a graph:

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

Requirements

Wolfram Language 11.2 (September 2017) or above

Resource History

Reference