Wolfram Computation Meets Knowledge

ResNet-101 Trained on YFCC100m Geotagged Data

Determine the geolocation of a photograph

Released in 2017, this geolocation model classifies the location in which a photo was taken among more than 15,000 predefined locations around the world. The classes correspond to cells extracted from Google's S2 Geometry library.

Number of layers: 344 | Parameter count: 74,405,235 | Trained size: 299 MB

Training Set Information

Performance

Examples

Resource retrieval

Get the pre-trained net:

In[1]:=
NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"]
Out[1]=

Basic Usage

Obtain an estimate of the latitude and longitude of where a photo was taken:

In[2]:=
CloudGet["https://www.wolframcloud.com/objects/b3e927ff-de30-4c47-924a-73c29c8bc66f"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[3]=

Show a map of the area corresponding to the position:

In[4]:=
GeoGraphics[position]
Out[4]=

Mark the position on a world map:

In[5]:=
GeoGraphics[GeoMarker[position], GeoRange -> 4000000]
Out[5]=

Multiple Predictions

The net returns a probability distribution over all available locations. Obtain the 50 most probable locations for a given image and plot these locations on the world map, with the size of the location marker proportional to the probability:

In[6]:=
CloudGet["https://www.wolframcloud.com/objects/362379e0-5ab3-4508-b384-aee8030192b7"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[7]=

Fine Scale Predictions

In places with high population density, very fine-grained predictions are possible. Consider the following four landmarks in Paris:

In[8]:=
landmarks = 
 EntityValue[{Entity["Building", "EiffelTower::5h9w8"], 
   Entity["Building", "TheLouvre::vqy3g"], 
   Entity["Building", "NotreDameCathedral::95fcw"], 
   Entity["Building", "ArcDeTriomphe::92x88"]}, "Image", 
  "EntityAssociation"]
Out[8]=

Predict the locations of the four landmarks and mark the locations on the map:

In[9]:=
GeoListPlot[
 MapThread[
  GeoMarker[#1, #2, 
    "Scale" -> 0.01] &, {NetModel[
     "ResNet-101 Trained on YFCC100m Geotagged Data"][
    Values[landmarks]], Values[landmarks]}], 
 GeoRange -> Quantity[1.5, "Miles"]]
Out[10]=

Compare with the actual locations:

In[11]:=
GeoListPlot[
 Map[GeoMarker[EntityValue[#, "Position"], EntityValue[#, "Image"], 
    "Scale" -> 0.01] &, Keys[landmarks]], 
 GeoRange -> Quantity[1.5, "Miles"]]
Out[11]=

Region Density

Inspect the distribution of the available positions. Display a heat map of the location density on the map:

In[12]:=
GeoHistogram[
 NetExtract[NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"],
    "Output"][["Labels"]], 50, PlotStyle -> Opacity[0.4], 
 ImageSize -> Large]
Out[13]=

Net information

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

In[14]:=
NetInformation[
 NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], \
"ArraysElementCounts"]
Out[14]=

Obtain the total number of parameters:

In[15]:=
NetInformation[
 NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], \
"ArraysTotalElementCount"]
Out[15]=

Obtain the layer type counts:

In[16]:=
NetInformation[
 NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], \
"LayerTypeCounts"]
Out[16]=

Display the summary graphic:

In[17]:=
NetInformation[
 NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], \
"SummaryGraphic"]
Out[17]=

Export to MXNet

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

In[18]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], "MXNet"]
Out[19]=

Export also creates a net.params file containing parameters:

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

Get the size of the parameter file:

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

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

In[22]:=
ResourceObject[
  "ResNet-101 Trained on YFCC100m Geotagged Data"]["ByteCount"]
Out[23]=

Requirements

Wolfram Language 11.2 (September 2017) or above

Resource History

Reference